I am trying to remember some state in a block I made: ```java
private int burningTicksLeft = 0;
I update this value when the player interacts with my block in a certain way :```java
@Override
public ActionResult onRightClick(PlayerEntity player, World world, Hand hand, BlockHitResult hitResult) {
// [...]
else if (canLightStoveOn) {
// [...]
this.burnFuelAndSchedule(world, hitResult.getBlockPos(), blockEntity);
return ActionResult.SUCCESS;
}
return ActionResult.PASS;
}
// [...]
private void burnFuelAndSchedule(World world, BlockPos pos, StoveBlockEntity blockEntity) {
for (int i = 0; i < blockEntity.size(); ++i) {
this.burningTicksLeft += getCombustonFromStack(blockEntity.getStack(i));
}
blockEntity.clear();
blockEntity.markDirty();
if (this.burningTicksLeft > ModSettings.Timings.STOVE_HEAT_TRANSITION_DELAY) {
// [...]
} else {
world.scheduleBlockTick(pos, this, this.burningTicksLeft); // Used here for instance
}
}
However, my custom event onRightClick (which I created to cover all the cases when the player right clicks the block - sneaking doesn't trigger onUse for example - ) uses the UseBlockCallback of Fabric, which is called on both the client and the server.
Because of that, my member burningTicksLeft is updated twice, and in this example, doubled, since my loop is evaluated on both of the logical sides. According to this post, DataTracker is used for this exact purpose : synchronizing values on the client and the server. I used it while making custom entities, so I know its basic usage. It is reserved to Entitys however.
How should I solve this? Should I use two separate variables for each logical side? Did I misunderstood what data trackers are? Does Minecraft have a built-in way of doing this? (Using BlockStates feels ridiculous)