Search the Community
Showing results for tags '1.11.'.
-
Hey everyone, so im currently having some trouble with my container. Its 1 slot to charge an item and only items that are an instance of IEnergyContainerItem can be shift clicked into it. The problem is i cant seem to figure out how to get transferStackInSlot correct, iv looked at some code from other mods and tried to make my own: @Override public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) { ItemStack itemstack = null; Slot slot = (Slot)this.inventorySlots.get(par2); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); if (par2 != 0) { if (itemstack1.getItem() instanceof IEnergyContainerItem) { if (!this.mergeItemStack(itemstack1, 0, 0+1, false)) { return null; } } else if (par2 >= 1 && par2 < 28) { if (!this.mergeItemStack(itemstack1, 28, 37, false)) { return null; } } else if (par2 >= 28 && par2 < 37 && !this.mergeItemStack(itemstack1, 1, 28, false)) { return null; } } else if (!this.mergeItemStack(itemstack1,1, 37, false)) { return null; } if (itemstack1.func_190916_E() == 0) { slot.putStack((ItemStack)null); } else { slot.onSlotChanged(); } if (itemstack1.func_190916_E() == itemstack.func_190916_E()) { return null; } slot.func_190901_a(par1EntityPlayer, itemstack1); } return itemstack; } What iv been getting is either it doesn't actually work or with this one it crashes with this crash report: java.lang.NullPointerException: Updating screen events at net.minecraft.inventory.Container.slotClick(Container.java:256) at net.minecraft.client.multiplayer.PlayerControllerMP.windowClick(PlayerControllerMP.java:594) at net.minecraft.client.gui.inventory.GuiContainer.handleMouseClick(GuiContainer.java:687) at net.minecraft.client.gui.inventory.GuiContainer.mouseClicked(GuiContainer.java:429) at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:611) at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:576) at net.minecraft.client.Minecraft.runTick(Minecraft.java:1792) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1119) at net.minecraft.client.Minecraft.run(Minecraft.java:407) at net.minecraft.client.main.Main.main(Main.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:26) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) Can anyone tell me what i'm doing wrong/how i can actually do this to suite my needs/how to make it better