Posted August 25, 20169 yr I have a Bug with my GUI Container...I want to make a Machine but there is a Bug with the Slots. I have a little Video from the Bug, here you can see: And here is the Code: TileEntity: public class TileEntityChemicalMixer extends TileEntity{ public InventoryBasic INVENTORY; public TileEntityChemicalMixer(){ INVENTORY = new InventoryBasic("Chemical Mixer", false, 3); } @Override public void writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); NBTTagList list = new NBTTagList(); for(int i = 0; i < INVENTORY.getSizeInventory(); i++){ if(INVENTORY.getStackInSlot(i) != null){ NBTTagCompound tag = new NBTTagCompound(); tag.setByte("Slot", (byte) i); INVENTORY.getStackInSlot(i).writeToNBT(tag); list.appendTag(tag); } } compound.setTag("ItemStacks", list); } @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); NBTTagList list = compound.getTagList("ItemStacks", 10); this.INVENTORY = new InventoryBasic("Chemical Mixer", false, 3); for(int i = 0; i < list.tagCount(); i++){ NBTTagCompound tag = list.getCompoundTagAt(i); byte b = tag.getByte("Slot"); if(b >= 0 && b < INVENTORY.getSizeInventory()){ INVENTORY.setInventorySlotContents(b, ItemStack.loadItemStackFromNBT(tag)); } } } } Container: public class ContainerChemicalMixer extends Container{ private TileEntityChemicalMixer tileentiy; public ContainerChemicalMixer(IInventory inv, TileEntityChemicalMixer tileentity) { this.tileentiy = tileentity; this.addSlotToContainer(new Slot(inv, 0, 30, 17)); this.addSlotToContainer(new Slot(inv, 0, 130, 17)); // Player Inventory, Slot 9-35, Slot IDs 9-35 for (int y = 0; y < 3; ++y) { for (int x = 0; x < 9; ++x) { this.addSlotToContainer(new Slot(inv, x + y * 9 + 9, 8 + x * 18, 84 + y * 18)); } } // Player Inventory, Slot 0-8, Slot IDs 36-44 for (int x = 0; x < 9; ++x) { this.addSlotToContainer(new Slot(inv, x, 8 + x * 18, 142)); } } @Override public boolean canInteractWith(EntityPlayer playerIn) { return true; } } And GUI: public class GuiChemicalMixer extends GuiContainer{ public static final ResourceLocation BACKGROUND = new ResourceLocation(Main.MODID + ":textures/gui/chemicalmixergui.png"); public GuiChemicalMixer(Container inventorySlotsIn) { super(inventorySlotsIn); this.ySize = 166; this.xSize = 176; } @Override protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { mc.renderEngine.bindTexture(BACKGROUND); int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; drawTexturedModalRect(k, l, 0, 0, xSize, ySize); } }
August 25, 20169 yr Issue is here: this.addSlotToContainer(new Slot(inv, 0, 30, 17)); this.addSlotToContainer(new Slot(inv, 0, 130, 17)); // Player Inventory, Slot 0-8, Slot IDs 36-44 for (int x = 0; x < 9; ++x) { this.addSlotToContainer(new Slot(inv, x, 8 + x * 18, 142)); } The Slot takes in the parameters IInventory, Index, xPos, yPos. You have to declare the two top slots as something else. You declare the player's hotbar with the id's 0->8, not as the commented 36-44. The player's inventory 9->35. I'd recommend setting the two "main" slots to 36 & 37 respectively. Also previously known as eAndPi. "Pi, is there a station coming up where we can board your train of thought?" -Kronnn Published Mods: Underworld Handy links: Vic_'s Forge events Own WIP Tutorials.
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.