diff --git a/src/main/java/crazypants/enderio/machine/gui/AbstractMachineContainer.java b/src/main/java/crazypants/enderio/machine/gui/AbstractMachineContainer.java index 681fb79f..ba74e13b 100644 --- a/src/main/java/crazypants/enderio/machine/gui/AbstractMachineContainer.java +++ b/src/main/java/crazypants/enderio/machine/gui/AbstractMachineContainer.java @@ -47,10 +47,12 @@ public abstract class AbstractMachineContainer } } + @Override public Point getPlayerInventoryOffset() { return new Point(8,84); } + @Override public Point getUpgradeOffset() { return new Point(12,60); } @@ -66,17 +68,17 @@ public abstract class AbstractMachineContainer protected abstract void addMachineSlots(InventoryPlayer playerInv); @Override - public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) { + public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotNumber) { SlotDefinition slotDef = getInv().getSlotDefinition(); ItemStack copystack = null; - Slot slot = (Slot) inventorySlots.get(slotIndex); + Slot slot = (Slot) inventorySlots.get(slotNumber); if(slot != null && slot.getHasStack()) { ItemStack origStack = slot.getStack(); copystack = origStack.copy(); boolean merged = false; - for(SlotRange range : getTargetSlotsForTransfer(slotIndex, slot)) { + for(SlotRange range : getTargetSlotsForTransfer(slotNumber, slot)) { if(mergeItemStack(origStack, range.start, range.end, range.reverse)) { merged = true; break; @@ -87,7 +89,7 @@ public abstract class AbstractMachineContainer return null; } - if(slotDef.isOutputSlot(slotIndex)) { + if (slotDef.isOutputSlot(slot.getSlotIndex())) { slot.onSlotChange(origStack, copystack); } @@ -153,20 +155,20 @@ public abstract class AbstractMachineContainer } } - protected List getTargetSlotsForTransfer(int slotIndex, Slot slot) { + protected List getTargetSlotsForTransfer(int slotNumber, Slot slot) { if (slot.inventory == getInv()) { SlotDefinition slotDef = getInv().getSlotDefinition(); - if (slotDef.isInputSlot(slot.slotNumber) || slotDef.isUpgradeSlot(slot.slotNumber)) { + if (slotDef.isInputSlot(slot.getSlotIndex()) || slotDef.isUpgradeSlot(slot.getSlotIndex())) { return Collections.singletonList(getPlayerInventorySlotRange(false)); } - if (slotDef.isOutputSlot(slot.slotNumber)) { + if (slotDef.isOutputSlot(slot.getSlotIndex())) { return Collections.singletonList(getPlayerInventorySlotRange(true)); } - } else if (slotIndex >= startPlayerSlot) { + } else if (slotNumber >= startPlayerSlot) { List res = new ArrayList(); addInputSlotRanges(res); addUpgradeSlotRanges(res); - addPlayerSlotRanges(res, slotIndex); + addPlayerSlotRanges(res, slotNumber); return res; } return Collections.emptyList(); diff --git a/src/main/java/crazypants/enderio/machine/gui/GuiMachineBase.java b/src/main/java/crazypants/enderio/machine/gui/GuiMachineBase.java index 62648938..abbaabf4 100644 --- a/src/main/java/crazypants/enderio/machine/gui/GuiMachineBase.java +++ b/src/main/java/crazypants/enderio/machine/gui/GuiMachineBase.java @@ -99,9 +99,9 @@ public abstract class GuiMachineBase extends Gu recipeButton.visible = true; } - renderSlotHighlights(); - super.drawGuiContainerBackgroundLayer(par1, par2, par3); + + renderSlotHighlights(); } public void renderSlotHighlights() { @@ -116,14 +116,14 @@ public abstract class GuiMachineBase extends Gu public void renderSlotHighlights(IoMode mode) { SlotDefinition slotDef = tileEntity.getSlotDefinition(); - if(slotDef.getNumInputSlots() > 0 && (mode == IoMode.PULL || mode == IoMode.PUSH_PULL)) { - for (int slot = slotDef.getMinInputSlot(); slot <= slotDef.getMaxInputSlot(); slot++) { - renderSlotHighlight(slot, PULL_COLOR); - } - } - if(slotDef.getNumOutputSlots() > 0 && (mode == IoMode.PUSH || mode == IoMode.PUSH_PULL)) { - for (int slot = slotDef.getMinOutputSlot(); slot <= slotDef.getMaxOutputSlot(); slot++) { - renderSlotHighlight(slot, PUSH_COLOR); + + for (Slot invSlot : (List) inventorySlots.inventorySlots) { + if (invSlot.inventory == tileEntity) { + if ((mode == IoMode.PULL || mode == IoMode.PUSH_PULL) && slotDef.isInputSlot(invSlot.getSlotIndex())) { + renderSlotHighlight(invSlot, PULL_COLOR); + } else if ((mode == IoMode.PUSH || mode == IoMode.PUSH_PULL) && slotDef.isOutputSlot(invSlot.getSlotIndex())) { + renderSlotHighlight(invSlot, PUSH_COLOR); + } } } } @@ -133,6 +133,10 @@ public abstract class GuiMachineBase extends Gu renderSlotHighlight(col, invSlot.xDisplayPosition, invSlot.yDisplayPosition, 16, 16); } + protected void renderSlotHighlight(Slot invSlot, Vector4f col) { + renderSlotHighlight(col, invSlot.xDisplayPosition, invSlot.yDisplayPosition, 16, 16); + } + protected void renderSlotHighlight(Vector4f col, int x, int y, int width, int height) { GL11.glEnable(GL11.GL_BLEND); RenderUtil.renderQuad2D(getGuiLeft() + x, getGuiTop() + y, 0, width, height, col);