public class DemoBlockEntity extends BlockEntity { public int number = 0; public DemoBlockEntity(BlockPos pos, BlockState state) { super(TutorialBlockEntityTypes.DEMO_BLOCK, pos, state); } @Override public void writeNbt(NbtCompound nbt, RegistryWrapper.WrapperLookup registryLookup) { nbt.putInt("number", number); super.writeNbt(nbt, registryLookup); } @Override public void readNbt(NbtCompound nbt, RegistryWrapper.WrapperLookup registryLookup) { super.readNbt(nbt); number = nbt.getInt("number", registryLookup); } }