Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

  • Author

bump

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

  • Author

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.

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.

Guest
This topic is now closed to further replies.

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.