mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-24 05:54:27 +00:00
Merge pull request #2984 from HenryLoenwind/shiftAgain
Fix: Shift-Click handling, second try
This commit is contained in:
commit
95d9fb402d
2 files changed
+25
-19
No files matched your search
@@ -47,10 +47,12 @@ public abstract class AbstractMachineContainer<T extends AbstractMachineEntity>
|
||||
}
|
||||
}
|
||||
|
||||
@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<T extends AbstractMachineEntity>
|
||||
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<T extends AbstractMachineEntity>
|
||||
return null;
|
||||
}
|
||||
|
||||
if(slotDef.isOutputSlot(slotIndex)) {
|
||||
if (slotDef.isOutputSlot(slot.getSlotIndex())) {
|
||||
slot.onSlotChange(origStack, copystack);
|
||||
}
|
||||
|
||||
@@ -153,20 +155,20 @@ public abstract class AbstractMachineContainer<T extends AbstractMachineEntity>
|
||||
}
|
||||
}
|
||||
|
||||
protected List<SlotRange> getTargetSlotsForTransfer(int slotIndex, Slot slot) {
|
||||
protected List<SlotRange> 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<SlotRange> res = new ArrayList<SlotRange>();
|
||||
addInputSlotRanges(res);
|
||||
addUpgradeSlotRanges(res);
|
||||
addPlayerSlotRanges(res, slotIndex);
|
||||
addPlayerSlotRanges(res, slotNumber);
|
||||
return res;
|
||||
}
|
||||
return Collections.emptyList();
|
||||
|
||||
@@ -99,9 +99,9 @@ public abstract class GuiMachineBase<T extends AbstractMachineEntity> extends Gu
|
||||
recipeButton.visible = true;
|
||||
}
|
||||
|
||||
renderSlotHighlights();
|
||||
|
||||
super.drawGuiContainerBackgroundLayer(par1, par2, par3);
|
||||
|
||||
renderSlotHighlights();
|
||||
}
|
||||
|
||||
public void renderSlotHighlights() {
|
||||
@@ -116,14 +116,14 @@ public abstract class GuiMachineBase<T extends AbstractMachineEntity> 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<Slot>) 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<T extends AbstractMachineEntity> 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);
|
||||
|
||||
Reference in new issue
Block a user