tutorial:blockentity
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorial:blockentity [2023/06/03 17:57] – fixed typos terra | tutorial:blockentity [2024/06/13 08:56] (current) – update outdated read nbt method s1lverposting | ||
---|---|---|---|
Line 19: | Line 19: | ||
Please ensure that the constructor only takes the two parameters, otherwise the method reference '' | Please ensure that the constructor only takes the two parameters, otherwise the method reference '' | ||
- | You can simply add variables | + | Block entities support a variety of methods |
===== Registering your BlockEntity ===== | ===== Registering your BlockEntity ===== | ||
Line 31: | Line 30: | ||
Registries.BLOCK_ENTITY_TYPE, | Registries.BLOCK_ENTITY_TYPE, | ||
new Identifier(" | new Identifier(" | ||
- | | + | |
); | ); | ||
</ | </ | ||
Line 73: | Line 72: | ||
// Serialize the BlockEntity | // Serialize the BlockEntity | ||
@Override | @Override | ||
- | public void writeNbt(NbtCompound nbt) { | + | public void writeNbt(NbtCompound nbt, RegistryWrapper.WrapperLookup wrapper) { |
// Save the current value of the number to the nbt | // Save the current value of the number to the nbt | ||
nbt.putInt(" | nbt.putInt(" | ||
- | super.writeNbt(nbt); | + | super.writeNbt(nbt, wrapper); |
} | } | ||
} | } | ||
Line 87: | Line 86: | ||
// Deserialize the BlockEntity | // Deserialize the BlockEntity | ||
@Override | @Override | ||
- | public void readNbt(NbtCompound nbt) { | + | public void readNbt(NbtCompound nbt, RegistryWrapper.WrapperLookup wrapper) { |
- | super.readNbt(nbt); | + | super.readNbt(nbt, wrapper); |
| | ||
number = nbt.getInt(" | number = nbt.getInt(" |
tutorial/blockentity.txt · Last modified: 2024/06/13 08:56 by s1lverposting