From f33b1e37b01245070e0a031e107dd6b063df25dc Mon Sep 17 00:00:00 2001 From: Sollace Date: Fri, 21 Sep 2018 17:52:47 +0200 Subject: [PATCH] Add the player's inventory to the bag of holding --- .../inventory/ContainerOfHolding.java | 21 +++++++++++++------ .../unicopia/inventory/gui/GuiOfHolding.java | 7 +++++-- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/inventory/ContainerOfHolding.java b/src/main/java/com/minelittlepony/unicopia/inventory/ContainerOfHolding.java index f42fd631..a9e2058a 100644 --- a/src/main/java/com/minelittlepony/unicopia/inventory/ContainerOfHolding.java +++ b/src/main/java/com/minelittlepony/unicopia/inventory/ContainerOfHolding.java @@ -25,18 +25,27 @@ public class ContainerOfHolding extends Container implements IWorldNameable { final int LEFT_MARGIN = 8; final int TOP_MARGIN = 18; - final int inventoryRows = (int)Math.ceil(inventory.getSizeInventory() / 9); + final int containerRows = (int)Math.ceil(inventory.getSizeInventory() / 9); + final int inventoryRows = (int)Math.ceil((player.inventory.getSizeInventory() - 9) / 9); for (int i = 0; i < inventory.getSizeInventory(); i++) { - int slotX = i % 9; - int slotY = (int)Math.floor(i / 9); + int slotX = (i % 9) * 18; + int slotY = (int)Math.floor(i / 9) * 18; - addSlotToContainer(new SlotOfHolding(inventory, i, LEFT_MARGIN + slotX * 18, TOP_MARGIN + slotY * 18)); + addSlotToContainer(new SlotOfHolding(inventory, i, LEFT_MARGIN + slotX, TOP_MARGIN + slotY)); } - int hotbarY = TOP_MARGIN + (inventoryRows * 18) + 4; + int inventoryY = (containerRows * 18) + 8; + int hotbarY = inventoryY + TOP_MARGIN + (inventoryRows * 18) + 4; - for (int i = 0; i < 9; ++i) { + for (int i = 9; i < player.inventory.getSizeInventory() - 5; i++) { + int slotX = (i % 9) * 18; + int slotY = (int)Math.floor(i / 9) * 18; + + addSlotToContainer(new Slot(player.inventory, i, LEFT_MARGIN + slotX, inventoryY + slotY)); + } + + for (int i = 0; i < 9; i++) { addSlotToContainer(new Slot(player.inventory, i, LEFT_MARGIN + i * 18, hotbarY)); } } diff --git a/src/main/java/com/minelittlepony/unicopia/inventory/gui/GuiOfHolding.java b/src/main/java/com/minelittlepony/unicopia/inventory/gui/GuiOfHolding.java index 0e7f0289..69c2cd77 100644 --- a/src/main/java/com/minelittlepony/unicopia/inventory/gui/GuiOfHolding.java +++ b/src/main/java/com/minelittlepony/unicopia/inventory/gui/GuiOfHolding.java @@ -15,12 +15,14 @@ public class GuiOfHolding extends GuiContainer { private static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("textures/gui/container/generic_54.png"); private final int inventoryRows; + private final int playerRows; private final Scrollbar scrollbar = new Scrollbar(); public GuiOfHolding(IInteractionObject interaction) { super(interaction.createContainer(Minecraft.getMinecraft().player.inventory, Minecraft.getMinecraft().player)); + playerRows = Minecraft.getMinecraft().player.inventory.getSizeInventory() / 9; inventoryRows = (inventorySlots.inventorySlots.size() / 9) - 1; } @@ -101,9 +103,10 @@ public class GuiOfHolding extends GuiContainer { int midY = (height - ySize) / 2; drawTexturedModalRect(midX, midY, 0, 0, xSize, 18); - for (int i = 0; i < inventoryRows; i++) { + for (int i = 0; i < inventoryRows - (playerRows - 1); i++) { drawTexturedModalRect(midX, midY + (18 * (i + 1)), 0, 18, xSize, 18); } - drawTexturedModalRect(midX, midY + inventoryRows * 18 + 17, 0, 193, xSize, 30); + + drawTexturedModalRect(midX, midY + (18 * (inventoryRows - (playerRows - 2))) - 1, 0, 131, xSize, 98); } }