Need help making a machine

VictiniX888

New Member
Jul 29, 2019
285
-2
0
Right, I'm making a machine that's supposed to... do stuff. That's not important.
What's important is the GUI.

I made the GUI and all, and made the container too. I can shift-click things into and out of the slots, but I can't take anything out of it by only clicking. Sometimes it even crashes when I try to do that.

Also, when I shift-click things into the machine, a "ghost" of the item stays in my inventory.

I'd appreciate if someone could at least point me in the right direction on fixing these.

Source:
https://github.com/VictiniX888/DirtHammer/tree/experimental

Mod (for testing or stuff)
https://github.com/VictiniX888/DirtHammer/releases/download/0.1.1/dirthammer-0.1.1.jar
 

ljfa

New Member
Jul 29, 2019
2,761
-46
0
I don't know why taking stuff out by clicking wouldn't work - that's weird indeed.

As for shift clicking, the details of transferStackInSlot are a bit intricate. I can just say, look at how vanilla does it and make sure that your code has exactly the same structure as the vanilla code. I'm not sure but I think you might need to rearrange some of the calls to mergeItemStack.

In any case, using a debugger might help you understand better how it works.
 
  • Like
Reactions: Type1Ninja

VictiniX888

New Member
Jul 29, 2019
285
-2
0
I don't know why taking stuff out by clicking wouldn't work - that's weird indeed.

As for shift clicking, the details of transferStackInSlot are a bit intricate. I can just say, look at how vanilla does it and make sure that your code has exactly the same structure as the vanilla code. I'm not sure but I think you might need to rearrange some of the calls to mergeItemStack.

In any case, using a debugger might help you understand better how it works.
I kinda just took and changed it a bit from the Furnace, shouldn't be all that different...

http://pastebin.com/uYak91qW
Try using this instead of the transferStackInSlot method you have in the container class.
Well now shiftclicking works perfectly, but I still can't get stuff out by clicking normally

EDIT: Used Hlaaftana's code, and also directly copied over some Furnace code. And then it works. Apparently there was something wrong with decrStackSize too I mixed up the params in decrStackSize. >.>
 
Last edited: