Jump to content

[1.13.2] Server Desync Inventory Action Mimics


Recommended Posts

I have been spending a good portion and still am of my mc development hobby developing server plugins. However, I thought I'd pursue another new and interesting project to start understanding how to take my experience and begin working on modifying the client itself. However, I want this mod to strictly work as a utility, therefore I would like it to work on public dedi servers and not just singleplayer. Since I am very new to the forge API, I thought I would start off reasonably basic. I want to see how I can mimic a few functions of key presses that occur automatically when a player joins a server. For example, I have been trying to get the client to automatically move the item stack in the 1st slot into the 2nd slot automatically when the 1st slot is highlighted/selected in the hotbar (via scroll). Unfortunately, I can not tell if when I do have the item moved to the second slot by first copying it to the second slot and then removing the original contents in the 1st slot, that the server is either out of sync, or if it is aware of this change but doesn't see it as a valid action and therefore cancels it. I am 90% sure I am missing a packet here, but due to my limited experience with client modifications, I am not sure what packets I am looking for. So far I have simply tried forcing a synchronization of my inventory contents with the server after I have done the action with the player.inventoryContainer#detectAndSendChanges(), but the server still appears to cancel the activity. So either I am doing it wrong, or the server is cancelling the activity since I am doing the action of moving the item to the other slot very differently then what is expected. I would like to actually analyze the classes that handle these sorts of activities in the inventory, such as in my case, mimicking the pressing of the number 2 on the keyboard to move the item in the slot selected into the second slot, but I haven't had any luck finding any such class since I do not know where to look.

Any help here would be most appreciated.

Edited by geekles
A title with more useful information
Link to comment
Share on other sites

15 hours ago, diesieben07 said:

detectAndSendChanges is used by the server to detect changes in the inventory and send them to the client.

Most of the slot interaction happens through GuiContainer#handleMouseClick, which calls PlayerControllerMP#windowClick.

I looked into the PlayerControllerMP class and tried out the method you mentioned (#windowClick). Although took me quite a bit of testing to get it to work and understand what was happening, I finally have it so that I can move any item in my inventory to a particular slot without the server falling out of sync of such movements. 


Edited by geekles
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

By using this site, you agree to our Terms of Use.