I'm trying to make a mod with some sword that should emit sound only once at its equip. Detection of slot change works like this: last item in player's hand being written to static variable lastSlotItem, and then if equipped item on next tick != lastSlotItem means that slot is changed. And by some unknown reason onPlayerTick is being called like this:
First change tick: item == sword
Second change tick: item == previous item (why does it goes back to prev. item on this tick?)
Third change tick: item == sword (again)
There's my code:
onPlayerTick:
preInit:
And even if i trying to handle slot change detection with onUpdate override in my sword class it does the same thing.
Sword Class: