Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Understanding transferStackInSlot method


TheEpicTekkit
 Share

Recommended Posts

Hello.

 

I would like help understanding the unnecessarily complicated and undocumented method:

transferStackInSlot(EntityPlayer player, int slotIndex)

I have looked around for tutorials on how to use this method, and only found things like a custom furnace, which has pretty much the exact same code as the vanilla furnace, and a badly explained transferStackInSlot method. I have also looked at the code of some mods such as EnderIO on Github and just found more confusion.

 

I think that the best documentation on transferStackInSlot that I have found is this.

 

What I would like is for someone to explain this method and how to implement it. I want to actually understand the code, and not have a tutorial that tells me what to write with no explanation, like a lot of tutorials do. I understand that the EntityPlayer parameter is the player using the inventory (obviously), the slotIndex is the slot that was shift-clicked, and the methods goal is to handle shift-clicking of slots, but I don't understand things like the mergeItemStack method, what the ItemStack that transferStackInSlot returns represents, or how to implement this method.

 

Furthermore, if I can understand this method properly, I would like to be able to implement a generic version of this method that automatically works for all containers. EnderIO seems to have it setup this way. But currently, I am trying to implement this for a machine with one input slot, 3 output slots, and a battery slot.

 

Thanks.

I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.

Link to comment
Share on other sites

Thanks for this. I haven't had much time to read through this method, but it looks pretty nice. Though I am looking for an explanation of how the transferStackInSlot method works and how it is used. I don't want to just have code to copy and paste, because I wont learn anything from that.

I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.

Link to comment
Share on other sites

Not to sound rude (seriously) but there is nothing that's gonna explain (this particular) method better than reading it and its callbacks. You'd be better off just analysing it. My guess is that anyone who'd attempt to "explain" it, when diesieben alredy gave you self-explainatory code would end up with something like this (which won't really help): :D

/** Moves Element e to Collection C. */
public void moveElementToCollection(Element e, Collection C)
{ ... }

 

Unless you are asking about Containers, Inventories and Slots themselves, then that would be a totally different answer or should I say - essay (there is a lot to talk about). :)

 

But, since it's support, where lies the problem?

1.7.10 is no longer supported by forge, you are on your own.

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

 Share



×
×
  • Create New...

Important Information

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