Posted June 18, 201312 yr Hey guys. I have a problem which is exactly what the title says. I have made a Container and opening it up works fine. I have not tested putting something in and taking it out again because well I have bind player's Inventory and a custom inventory and try to let items be switched between them. I guess I have to override some method in the Container. Here are my 2 files: MHItemChestContainer: http://paste.minecraftforge.net/view/1c70ae3b InventoryMHItemChest: http://paste.minecraftforge.net/view/3d880296 If you need anything else, just ask for it Thanks for your time
June 18, 201312 yr Your transferStackInSlot function is returning null. If this is happening on shift-click then you should consider putting some code in there. Mine looks like this. /** * Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that. */ public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) { ItemStack var3 = null; Slot var4 = (Slot)this.inventorySlots.get(par2); if (var4 != null && var4.getHasStack()) { ItemStack var5 = var4.getStack(); var3 = var5.copy(); if (par2 == 2) { if (!this.mergeItemStack(var5, 3, 39, true)) { return null; } var4.onSlotChange(var5, var3); } else if (par2 != 1 && par2 != 0) { if (MillRecipes.smelting().getSmeltingResult(var5) != null) { if (!this.mergeItemStack(var5, 0, 1, false)) { return null; } } else if (TileEntityMill.isItemFuel(var5)) { if (!this.mergeItemStack(var5, 1, 2, false)) { return null; } } else if (par2 >= 3 && par2 < 30) { if (!this.mergeItemStack(var5, 30, 39, false)) { return null; } } else if (par2 >= 30 && par2 < 39 && !this.mergeItemStack(var5, 3, 30, false)) { return null; } } else if (!this.mergeItemStack(var5, 3, 39, false)) { return null; } if (var5.stackSize == 0) { var4.putStack((ItemStack)null); } else { var4.onSlotChanged(); } if (var5.stackSize == var3.stackSize) { return null; } var4.onPickupFromSlot(par1EntityPlayer, var5); } return var3; } "The Gentle Way... My @$$!" -average new judo student upon learning the meaning of the word Judo in Japanese
June 18, 201312 yr Author It's happening all the time no matter if I shift-click or click normally. Though I will try to put parts of your code in. Thanks for sharing If you have something against that please answer. Sincerely Me
June 18, 201312 yr Author Nothing has changed with the new, of c I changed the code to fulfill my expectations, code. Well I hope you (community) can keep the great support coming Me
June 18, 201312 yr Not sure if this is helpful or not, but it sounds a lot like the MC bug that can happen in full screen mode. That is usually fixed by going to windowed mode, and/or hitting the ALT key a couple times while in an inventory gui. I'd check that just to be sure you rule out a runtime bug and not the code. "The Gentle Way... My @$$!" -average new judo student upon learning the meaning of the word Judo in Japanese
June 18, 201312 yr Author Nope I tried it out and nothing I really tried to stick to this tutorial: http://www.minecraftforge.net/wiki/Containers_and_GUIs but well it seems not to work...
June 18, 201312 yr Author Actually it was a problem with the GUI. The GUIContainer class features a ySize-variable which defines wheter you have clicked "out of the GUI". If yes then the ItemStack you have in-hand is thrown away. As my GUI was a bit bigger than the default sitze of 176*166 I clicked "out of the Gui" and the items got thrown away. One mystery less in the world ^^ Appreciated your help Me
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.