Jump to content

[1.10.2][Container][Slot] How does the method slotClick work? (rephrased)


Starless

Recommended Posts

This is a method from the

Container

class. It has the following signature:

 

public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player)

 

The first and last arguments are clear to me. The second and third arguments, as well as the return, not so much. The body of this method in the

Container

class is too long and too complicated to follow. I'm interested in overriding this method because I need slots with behaviour different than the vanilla ones. For that, I have to fully understand what this method does, because I think it has a very big potential for bugs and unintentional side effects.

 

EDIT: Let me rephrase that: How do I convert from this signature to the old signature where both

dragType

and

clickTypeIn

were

ints

? Such as:

 

public MyContainer extends Container
{
    @Override
    public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player)
    {
        int mouseButton = /* what? */;
        int modifier = /* what? */;
        return legacySlotClick(slotId, mouseButton, modifier, player);
    }

    protected ItemStack legacySlotClick(int slotId, int mouseButton, int modifier, EntityPlayer player)
    {
        
    }
}

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.