Posted August 25, 20178 yr For some reason, when I open my GUI, it moves the items in the player's inventory to different places. I don't know why this happens and this did not happen with code from 1.11.2. Is there some change from 1.11.2 to 1.12 for this to be the case? public ContainerIvVillagerInfo(IvVillager villager, IInventory playerInv){ this.villager = villager; this.handler = this.villager.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); int xPos = 8; int yPos = 153; for (int y = 0; y < 3; ++y) { for (int x = 0; x < 9; ++x) { this.addSlotToContainer(new Slot(playerInv, x + y * 9 + 9, xPos + x * 18, yPos + y * 18)); } } for (int x = 0; x < 9; ++x) { this.addSlotToContainer(new Slot(playerInv, x, xPos + x * 18, yPos + 58)); } } @Override public boolean canInteractWith(EntityPlayer player) { return villager.getDistanceToEntity(player) < 8; } @Override public ItemStack transferStackInSlot(EntityPlayer playerIn, int fromSlot) { ItemStack previous = ItemStack.EMPTY; Slot slot = (Slot) this.inventorySlots.get(fromSlot); if (slot != null && slot.getHasStack()) { ItemStack current = slot.getStack(); previous = current.copy(); if (fromSlot < this.handler.getSlots()) { // From the block breaker inventory to player's inventory if (!this.mergeItemStack(current, handler.getSlots(), handler.getSlots() + 36, true)) return ItemStack.EMPTY; } else { // From the player's inventory to block breaker's inventory if (!this.mergeItemStack(current, 0, handler.getSlots(), false)) return ItemStack.EMPTY; } if (current.getCount() == 0) //Use func_190916_E() instead of stackSize 1.11 only 1.11.2 use getCount() slot.putStack(ItemStack.EMPTY); //Use ItemStack.field_190927_a instead of (ItemStack)null for a blank item stack. In 1.11.2 use ItemStack.EMPTY else slot.onSlotChanged(); if (current.getCount() == previous.getCount()) slot.onTake(playerIn, current); } return previous; } }
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.