From cba923c26a173ece911be824dd8079981ab02332 Mon Sep 17 00:00:00 2001 From: Qowyn Date: Mon, 29 Sep 2014 21:22:41 +0200 Subject: [PATCH] Fixed weird stacking behavior when shift-clicking items out of the smeltry. Also fixed last bugs after deleting NewContainerGui. --- .../tconstruct/smeltery/gui/SmelteryGui.java | 14 ++++++------- .../smeltery/inventory/SmelteryContainer.java | 21 ++++++++----------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/main/java/tconstruct/smeltery/gui/SmelteryGui.java b/src/main/java/tconstruct/smeltery/gui/SmelteryGui.java index 62961ef2..2f7671e9 100644 --- a/src/main/java/tconstruct/smeltery/gui/SmelteryGui.java +++ b/src/main/java/tconstruct/smeltery/gui/SmelteryGui.java @@ -2,7 +2,6 @@ package tconstruct.smeltery.gui; import java.util.*; -import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.*; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.player.InventoryPlayer; @@ -34,10 +33,10 @@ public class SmelteryGui extends ActiveContainerGui { super((ActiveContainer) smeltery.getGuiContainer(inventoryplayer, world, x, y, z)); logic = smeltery; - xSize = 248; smeltery.updateFuelDisplay(); columns = ((SmelteryContainer) this.inventorySlots).columns; + xSize = 254 + (columns - 3) * 22; // Adjust for column count } @Override @@ -63,7 +62,7 @@ public class SmelteryGui extends ActiveContainerGui boolean mouseDown = Mouse.isButtonDown(0); int lefto = this.guiLeft; int topo = this.guiTop; - int xScroll = lefto + 67; + int xScroll = lefto + 67 + (columns - 3) * 22; // Adjust for column count int yScroll = topo + 8; int scrollWidth = xScroll + 14; int scrollHeight = yScroll + 144; @@ -109,10 +108,11 @@ public class SmelteryGui extends ActiveContainerGui @Override protected void drawGuiContainerForegroundLayer (int mouseX, int mouseY) { - fontRendererObj.drawString(StatCollector.translateToLocal("crafters.Smeltery"), 86, 5, 0x404040); - fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 90, (ySize - 96) + 2, 0x404040); + int baseX = 86 + (columns - 3) * 22; + fontRendererObj.drawString(StatCollector.translateToLocal("crafters.Smeltery"), baseX, 5, 0x404040); + fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), baseX + 4, (ySize - 96) + 2, 0x404040); - int cornerX = (width - xSize) / 2 + 36; + int cornerX = (width - xSize) / 2 + 36 + (columns - 3) * 22; int cornerY = (height - ySize) / 2; int[] fluidHeights = calcLiquidHeights(); @@ -151,7 +151,7 @@ public class SmelteryGui extends ActiveContainerGui { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(background); - int cornerX = (width - xSize) / 2 + 36; + int cornerX = (width - xSize) / 2 + 36 + (columns - 3) * 22; int cornerY = (height - ySize) / 2; drawTexturedModalRect(cornerX + 46, cornerY, 0, 0, 176, ySize); diff --git a/src/main/java/tconstruct/smeltery/inventory/SmelteryContainer.java b/src/main/java/tconstruct/smeltery/inventory/SmelteryContainer.java index 2851e058..3bce0146 100644 --- a/src/main/java/tconstruct/smeltery/inventory/SmelteryContainer.java +++ b/src/main/java/tconstruct/smeltery/inventory/SmelteryContainer.java @@ -29,29 +29,28 @@ public class SmelteryContainer extends ActiveContainer int totalSlots = smeltery.getBlockCapacity(); int y = 0; - int xleft = 2; - xleft -= 22 * (columns - 3); // we have to shift the whole thing to the left if we have more than 3 columns - for (int i = 0; i < totalSlots; i++) { int x = i % columns; - this.addDualSlotToContainer(new ActiveSlot(smeltery, x + y * columns, xleft + x * 22, 8 + y * 18, y < 8)); + this.addDualSlotToContainer(new ActiveSlot(smeltery, x + y * columns, 2 + x * 22, 8 + y * 18, y < 8)); if (x == columns - 1) y++; } + + int baseX = 90 + (columns - 3) * 22; /* Player inventory */ - for (int column = 0; column < 3; column++) + for (int row = 0; row < 3; row++) { - for (int row = 0; row < 9; row++) + for (int column = 0; column < 9; column++) { - this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 90 + row * 18, 84 + column * 18)); + this.addSlotToContainer(new Slot(inventoryplayer, column + row * 9 + 9, baseX + column * 18, 84 + row * 18)); } } for (int column = 0; column < 9; column++) { - this.addSlotToContainer(new Slot(inventoryplayer, column, 90 + column * 18, 142)); + this.addSlotToContainer(new Slot(inventoryplayer, column, baseX + column * 18, 142)); } } @@ -73,12 +72,10 @@ public class SmelteryContainer extends ActiveContainer { slot.setActive(false); } - int xleft = 2; - xleft -= 22 * (columns - 3); // we have to shift the whole thing to the left if we have more than 3 columns int xPos = (iter - basePos) % columns; int yPos = (iter - basePos) / columns; - slot.xDisplayPosition = xleft + 22 * xPos; + slot.xDisplayPosition = 2 + 22 * xPos; slot.yDisplayPosition = 8 + 18 * yPos; } return slotRow; @@ -217,7 +214,7 @@ public class SmelteryContainer extends ActiveContainer slot = (Slot) this.inventorySlots.get(slotPos); slotStack = slot.getStack(); - if (slotStack != null && ItemStack.areItemStacksEqual(slotStack, inputStack)) + if (slotStack != null && slotStack.isItemEqual(inputStack) && ItemStack.areItemStackTagsEqual(slotStack, inputStack)) { int l = slotStack.stackSize + inputStack.stackSize;