Change Item Durability
roziscoding opened this issue ยท 1 comments
I'm trying to set a Trinket's durability through the tick
method, and I can see, through logging, that the damage is being updated, but it's not rendered on the UI.
This is my code:
@Override
public void tick(PlayerEntity player, ItemStack stack) {
boolean shouldIncreaseStackDamage = this.damage >= 1;
System.out.format("Processing damage. Current damage level: %.2f. shouldIncreaseStackDamage: %s\n", this.damage, shouldIncreaseStackDamage);
if (shouldIncreaseStackDamage) {
this.damage = 0;
stack.setDamage(stack.getDamage() + 1);
System.out.format("Current item damage: %s\n", stack.getDamage());
return;
}
System.out.format("Setting internal damage level to %.2f\n", this.damage + 0.1);
this.damage += 0.1;
TrinketsApi.getTrinketsInventory(player).markDirty();
}
I'd love to get some help with it, if possible.