I've recently been trying to update my Structure Generation Toolhttps://github.com/coolAlias/StructureGenerationTool to be compatible with multi-player; as such, I've changed to a KeyHandler and storing the Item variables in NBT.
Each key press changes a variable in the item's NBT, but this is only client side. I know I can send packets, but I was hoping not to spam packets because the data is only needed when the item is used. I've been trying to send a packet from client to server onItemUse, which works, but it's too late to the party and the Item activates with the data from the previous time instead of the current data.
I played around with synchronized variable and wait/notify, but it results in thread lock since the server side is waiting for the information but it can't get it until the onItemUse method is called client side, which obviously doesn't happen while the thread is waiting.
Here's my item code with my failed attempts:
And my PacketHandler with custom packet class: