Add the player's inventory to the bag of holding

This commit is contained in:
Sollace 2018-09-21 17:52:47 +02:00
parent 7b4e98cf88
commit f33b1e37b0
2 changed files with 20 additions and 8 deletions

View file

@ -25,18 +25,27 @@ public class ContainerOfHolding extends Container implements IWorldNameable {
final int LEFT_MARGIN = 8; final int LEFT_MARGIN = 8;
final int TOP_MARGIN = 18; 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++) { for (int i = 0; i < inventory.getSizeInventory(); i++) {
int slotX = i % 9; int slotX = (i % 9) * 18;
int slotY = (int)Math.floor(i / 9); 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)); addSlotToContainer(new Slot(player.inventory, i, LEFT_MARGIN + i * 18, hotbarY));
} }
} }

View file

@ -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 static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("textures/gui/container/generic_54.png");
private final int inventoryRows; private final int inventoryRows;
private final int playerRows;
private final Scrollbar scrollbar = new Scrollbar(); private final Scrollbar scrollbar = new Scrollbar();
public GuiOfHolding(IInteractionObject interaction) { public GuiOfHolding(IInteractionObject interaction) {
super(interaction.createContainer(Minecraft.getMinecraft().player.inventory, Minecraft.getMinecraft().player)); super(interaction.createContainer(Minecraft.getMinecraft().player.inventory, Minecraft.getMinecraft().player));
playerRows = Minecraft.getMinecraft().player.inventory.getSizeInventory() / 9;
inventoryRows = (inventorySlots.inventorySlots.size() / 9) - 1; inventoryRows = (inventorySlots.inventorySlots.size() / 9) - 1;
} }
@ -101,9 +103,10 @@ public class GuiOfHolding extends GuiContainer {
int midY = (height - ySize) / 2; int midY = (height - ySize) / 2;
drawTexturedModalRect(midX, midY, 0, 0, xSize, 18); 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 + (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);
} }
} }