Fixed weird stacking behavior when shift-clicking items out of the smeltry. Also fixed last bugs after deleting NewContainerGui.

This commit is contained in:
Qowyn committed 2014-09-29 21:30:52 +02:00
1 parent 59f5a9c9ea
commit cba923c26a
2 files changed
+16 -19

No files matched your search

@@ -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);
@@ -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;