I want to say that I am a newbie and a simpleton in modding. I've been working on this for a long time, but I can't find a solution. The point is, I've created an NPC that has an anvil function. However, I can't move items in the inventory while in the anvil menu. They just go back to where I took them from. And when I click on empty inventory slots, items randomly move around the inventory and sometimes get duplicated. As far as I understand, this is related to synchronization between the client and server. I can't get this synchronization to work properly. Although I managed to do it for other functions. I encountered a similar problem when I wanted to implement trading with villagers in the same way. But back then, I ended up creating the trading function from scratch, as I couldn't solve the desynchronization issue.
If you have an idea why synchronization is not working, advice or a possible solution to the problem, I will be very grateful to you.
My Code: