Posted April 12, 20196 yr I'm really confused, I was having issues trying to add my own inventory into the gui, so I decided to focus on the adding the player inventory, I copied my working code from my other item and now it duplicates my hotbar for some reason? I haven't had this problem before. After playing around with things, I figured out it translated my hotbar upward, pushing things into inappropriate item slots (building blocks into armor slots for example) and if there isn't any room left just overwrites what was there. This is my container code: package com.mekelaina.duelcraft.container; import com.mekelaina.duelcraft.card.CardCollection; import com.mekelaina.duelcraft.gui.GuiBinder; import com.mekelaina.duelcraft.items.ItemCard; import com.mekelaina.duelcraft.items.ItemDeckbox; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.SlotItemHandler; public class ContainerBinder extends CommonContainer { private int refX; private int refY; private InventoryPlayer playerInv; IItemHandler binderInv; //private GuiBinder GuiInstance; private static final int SLOT_WIDTH = 18; private static final int XSTART_DECKBOX = 140; private static final int YSTART_DECKBOX = 32; private static final int XSTART_BINDER = XSTART_DECKBOX + 112; private static final int YSTART_BINDER = YSTART_DECKBOX; private static final int XSTART_MID = XSTART_DECKBOX + 42; private static final int YSTART_MID = YSTART_DECKBOX + 13; private static final int numRows = 5; public ContainerBinder(InventoryPlayer playerInv, IItemHandler binderInv, int numSlots) { super(numSlots); this.playerInv = playerInv; this.binderInv = binderInv; int numColumns = numSlots / numRows; int xPosition; int yPosition; int index = 0; //int x = 0, y = 0; /*for(int x = 0; x < 10; x++) { for( int y = 0; y < 10; y++) { if(x < 5 && y < 5) { index = x + (y * 5); xPosition = XSTART_BINDER + ((x) * SLOT_WIDTH); yPosition = YSTART_BINDER + ((y) * SLOT_WIDTH); this.addSlotToContainer(new SlotItemHandler(binderInv, index, xPosition, yPosition) { @Override public boolean isItemValid(ItemStack stack) { if(stack.getItem() instanceof ItemCard && stack.hasTagCompound()) { NBTTagCompound nbt = stack.getTagCompound(); if(nbt.hasKey("Card_ID")) { String id = nbt.getString("Card_ID"); return !CardCollection.CARD_LIST.get(id).isExtraDeck(); } return true; } return false; } }); } else { } } } */ /*x++; y++;*/ /* xPosition = XSTART_MID + 50; yPosition = YSTART_MID + 10; index = x + (y * 5); index++; this.addSlotToContainer(new SlotItemHandler(binderInv, index, xPosition, yPosition) { @Override public boolean isItemValid(ItemStack stack) { if(stack.getItem() instanceof ItemDeckbox && stack.hasTagCompound()) { NBTTagCompound nbt = stack.getTagCompound(); if(nbt.hasKey("Card_ID")) { String id = nbt.getString("Card_ID"); return !CardCollection.CARD_LIST.get(id).isExtraDeck(); } return true; } return false; } });*/ // Player inventory for (int y = 0; y < 3; ++y) { for (int x = 0; x < 9; ++x) { this.addSlotToContainer(new Slot(playerInv, x + y * 9 + 9, (x * 18) + XSTART_DECKBOX, YSTART_DECKBOX + y * 18)); // x + y * 9 + 9 // 0 + 0 * 9 + 9 = 9 // 1 + 0 * 9 + 9 = 10 // 2 + 0 * 9 + 9 = 11 // 3 + 0 * 9 + 9 = 12 // 4 + 0 * 9 + 9 = 13 // 5 + 0 * 9 + 9 = 14 // 6 + 0 * 9 + 9 = 15 // 7 + 0 * 9 + 9 = 16 // 8 + 0 * 9 + 9 = 17 // 0 + 1 * 9 + 9 = 18 // 1 + 1 * 9 + 9 = 19 // 2 + 1 * 9 + 9 = 20 // 3 + 1 * 9 + 9 = 21 // 4 + 1 * 9 + 9 = 22 // 5 + 1 * 9 + 9 = 23 // 6 + 1 * 9 + 9 = 24 // 7 + 1 * 9 + 9 = 25 // 8 + 1 * 9 + 9 = 26 // ... } } // Hot bar for (int z = 0; z < 9; ++z) { this.addSlotToContainer(new Slot(playerInv, z, (z * 18) + XSTART_DECKBOX, YSTART_DECKBOX + 100)); } } public void setRefValues(int x, int y) { refX = x; refY = y; } }
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.