Skip to content

Commit

Permalink
Fixed weird stacking behavior when shift-clicking items out of the sm…
Browse files Browse the repository at this point in the history
…eltry. Also fixed last bugs after deleting NewContainerGui.
  • Loading branch information
Qowyn committed Sep 29, 2014
1 parent 59f5a9c commit cba923c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
14 changes: 7 additions & 7 deletions src/main/java/tconstruct/smeltery/gui/SmelteryGui.java
Expand Up @@ -2,7 +2,6 @@

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;
Expand Down Expand Up @@ -34,10 +33,10 @@ public SmelteryGui(InventoryPlayer inventoryplayer, SmelteryLogic smeltery, Worl
{
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
Expand All @@ -63,7 +62,7 @@ protected void updateScrollbar (int mouseX, int mouseY, float par3)
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;
Expand Down Expand Up @@ -109,10 +108,11 @@ protected void updateScrollbar (int mouseX, int mouseY, float par3)
@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();
Expand Down Expand Up @@ -151,7 +151,7 @@ protected void drawGuiContainerBackgroundLayer (float f, int mouseX, int mouseY)
{
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);

Expand Down
21 changes: 9 additions & 12 deletions src/main/java/tconstruct/smeltery/inventory/SmelteryContainer.java
Expand Up @@ -29,29 +29,28 @@ public SmelteryContainer(InventoryPlayer inventoryplayer, SmelteryLogic smeltery
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));
}
}

Expand All @@ -73,12 +72,10 @@ public int updateRows (int invRow)
{
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;
Expand Down Expand Up @@ -217,7 +214,7 @@ protected boolean mergeItemStack (ItemStack inputStack, int startSlot, int endSl
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;

Expand Down

0 comments on commit cba923c

Please sign in to comment.