I'm using offHandItem.count-- to consume the offhand "repairing" ingredient every time i left click on a certain block and it works fine until you consume the last ingredient in the offhand which for some reason the game continues to "consume" the item into the negatives even though you ran out of the ingredient
BlockEvents.leftClicked('kubejs:reforging_station', event => {
let offHandItem = event.player.getHeldItem('off_hand');
let item = event.player.getHeldItem('main_hand');
let pData = event.player.persistentData;
if (pData.timestall != 1) {
return;
}
pData.timestall = 0;
event.server.schedule(1200, () => {
pData.timestall = 1;
});
if (!air && (item.hasTag('kubejs:trinkets_gold') && event.player.offHandItem == 'minecraft:gold_ingot')) {
event.server.runCommandSilent(`execute as ${event.player.username} run playsound minecraft:block.anvil.use block @s ${event.player.x} ${event.player.y} ${event.player.z} 0.5 0.5`);
offHandItem.count--
event.player.tell(offHandItem)
}
})```



