Jump to content

[1.10.2] Problems with custom slot in GUI on both client and server


Recommended Posts

Posted

On the client, for some reason, the GUI makes a "ghost" copy of the sword when I shift click/drag the sword from the player's inventories to the custom slot. How do I know that is a "ghost" sword? Simple, when I drag the sword from it's resting place to the player's inventories, it magically disappears.

 

SHIFT CLICK FROM PLAYER INVENTORY TO CUSTOM SLOT.gif

 

 

 

DRAG FROM PLAYER INVENTORY TO CUSTOM SLOT.gif

 

 

 

DRAGGING FROM CUSTOM SLOT.gif

 

 

 

SHIFT CLICK FROM CUSTOM SLOT.gif

 

 

 

In multiplayer, this weird magical stuffs doesn't happen except for 3 things.

[*]When I shift click the sword in the player's inventories, the sword is moved into the custom slot but instantly gets kicked out of the slot.

[*]When I drag the sword in the player's inventories, the sword is accepted in the custom slot, no getting kicked out of the slot.

[*]When I shift click the sword in the custom slot, it moves into the player's inventory BUT the sword's stack in the custom slot indicates 0. Screenshot of that provided:

 

Screenshot:

 

 

 

Well, now for the code, Gist here.

width=620 height=260http://www.startrek.com/uploads/assets/articles/61c89a9d73c284bda486afaeaf01cdb27180359b.jpg[/img]

Till next time. Thank you for delivering funny scenes to Star Trek as Chekov :) . Will always remember you

Posted

No lol, it's a GUI meant to be opened with a keybind. GUI opening with a keybind works, the problem is my sword dragging/shift clicking into the custom slot. Look at the gifs in the spoilers and you will understand what I mean.

width=620 height=260http://www.startrek.com/uploads/assets/articles/61c89a9d73c284bda486afaeaf01cdb27180359b.jpg[/img]

Till next time. Thank you for delivering funny scenes to Star Trek as Chekov :) . Will always remember you

Posted

Look at your transferStackInSlot and mergeItemStack.

 

If you'd like, you can look to my Git for Thing's Mod. I use a right clickable chest-like item thing, and you can reference the transferStackInSlot and mergeItemStack.

 

Ask if you need more help.

I Love To Help People. Unless They Are The Kind Of People Who Just Doesn't Know Anything. Those People Need Some Serious Help. This Could Help But......

https://www.youtube.com/watch?v=6t0GlXWx_PY

 

ThingsMod Git: https://github.com/EscapeMC/Things-Mod-1.10.2

 

TeamMadness Mod Git: https://github.com/EscapeMC/TeamMadness-Mod-1.10.2

 

If I somehow help you, please click the "Thank You" button. If I am a total waste of time, please click the "Applaud" button.

Posted

It's too bad some of the more experienced modders haven't chimed in. I'm grasping at straws here, but you might try adding your custom slot last. That fixed a lot of problems for me, but I think that was because I was trying to replace the standard player inventory which is relied on in both survival and creative inventories, with different numbers of slots. I also noticed you reuse the variable i to add both the hot bar slots and the regular inventory slots. Probably not an issue, but it would be cleaner to use a different variable anyway.

 

The shift-click problems definitely point to problems with transferStackInSlot. You could try putting a break point in and follow the program as it traces through the logic of that method.

Posted

It's too bad some of the more experienced modders haven't chimed in. I'm grasping at straws here, but you might try adding your custom slot last. That fixed a lot of problems for me, but I think that was because I was trying to replace the standard player inventory which is relied on in both survival and creative inventories, with different numbers of slots. I also noticed you reuse the variable i to add both the hot bar slots and the regular inventory slots. Probably not an issue, but it would be cleaner to use a different variable anyway.

 

The shift-click problems definitely point to problems with transferStackInSlot. You could try putting a break point in and follow the program as it traces through the logic of that method.

 

Yeah, I should use a different variable for the int. What do you mean adding my custom slot last? You mean moving it to the last line of the constructor?

width=620 height=260http://www.startrek.com/uploads/assets/articles/61c89a9d73c284bda486afaeaf01cdb27180359b.jpg[/img]

Till next time. Thank you for delivering funny scenes to Star Trek as Chekov :) . Will always remember you

Posted

Yes, move to last line of constructor. It changes the index of the slot in the player's overall inventory. If you do that, you will also need to adjust your constants and all the index numbers in transferStackInSlot as well.

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.

Guest
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.

Announcements



×
×
  • Create New...

Important Information

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