Jump to content

[1.7.10]Finding the item slot number from ItemToolTipEvent


starwarsmace

Recommended Posts

In my mod, I close the inventory gui, when I open my gui. Only problem is when, my gui opens when an item in the inventory is right-clicked, so that splits the stack and drops the items on the ground when its closed. Is there some way to find the slot from ItemToolTipEvent so later on the itemtossevent I can just add the stack back into the inventory. By the way in the javadoc for itemtossevent it says, cancelling the event will stop the EntityItem from being thrown but not stop the item from being removed from the inventory. Or is there some other way all together so I can avoid having the item from being thrown in the first place.

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

Link to comment
Share on other sites

I think what he's trying to say is, in his custom tile entity, he doesn't want people to throw stuff on the ground when the gui is closed. So if there is an item on the cursor it normally throws it into the world but he doesn't want that to happen. I don't know how this would be done. You probably wouldn't use the ItemToolTipEvent but rather some event that tracks which slot they click.

Link to comment
Share on other sites

okay.............

Yeah I entirely messed up with my question.

I have an info gui that pops up when you right click an item in an inventory(I use anything that extends GuiContainer). I use ItemToolTipEvent to do this because when the player hovers over the item it fires the event, so all I need to check for is whether the mouse is right clicked and then if it is I open my gui.

Now as all of you probably know, in minecraft when you right click an item it splits the stack and also when you close the inventory while youre "holding an item with your mouse" the item drops. Which is what happens when I close the inventory and open my gui.

Now all I need to do is to stop the item from dropping when the inventory is closed. One way I thought of is that, I could get the slot number of the item's original place in the ItemToolTipEvent, and then later in the ItemTossEvent add it back to that slot.

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

Link to comment
Share on other sites

Sorry, I forgot something in the post before this.

One way I thought of is that, I could get the slot number of the item's original place in the ItemToolTipEvent, and then later in the ItemTossEvent add it back to that slot.

The problem is how would I find the slot number? Or is there some other way to stop it from falling?

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

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.

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.