From 59929c9c82b84dcf660e557d83a8befee76e8f5c Mon Sep 17 00:00:00 2001 From: pahimar Date: Tue, 14 May 2013 16:15:50 -0400 Subject: [PATCH] Some container shift clicking work --- .../tileentity/TileEntityAludelRenderer.java | 2 +- .../ee3/inventory/ContainerAludel.java | 33 ++++++++++++++++++- .../ee3/inventory/ContainerGlassBell.java | 30 ++++++++++++++++- .../ee3/tileentity/TileAlchemicalChest.java | 2 +- .../pahimar/ee3/tileentity/TileAludel.java | 2 +- .../ee3/tileentity/TileCalcinator.java | 2 +- .../pahimar/ee3/tileentity/TileGlassBell.java | 2 +- 7 files changed, 66 insertions(+), 7 deletions(-) diff --git a/ee3_common/com/pahimar/ee3/client/renderer/tileentity/TileEntityAludelRenderer.java b/ee3_common/com/pahimar/ee3/client/renderer/tileentity/TileEntityAludelRenderer.java index b8f3a720..f9d5e0d8 100644 --- a/ee3_common/com/pahimar/ee3/client/renderer/tileentity/TileEntityAludelRenderer.java +++ b/ee3_common/com/pahimar/ee3/client/renderer/tileentity/TileEntityAludelRenderer.java @@ -87,7 +87,7 @@ public class TileEntityAludelRenderer extends TileEntitySpecialRenderer { ghostEntityItem.hoverStart = 0.0F; ghostEntityItem.setEntityItemStack(tileAludel.getStackInSlot(TileAludel.INPUT_INVENTORY_INDEX)); - GL11.glTranslatef((float) x + 0.5F, (float) y + 1.2F, (float) z + 0.5F); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.25F, (float) z + 0.5F); GL11.glScalef(scaleFactor, scaleFactor, scaleFactor); GL11.glRotatef(rotationAngle, 0.0F, 1.0F, 0.0F); diff --git a/ee3_common/com/pahimar/ee3/inventory/ContainerAludel.java b/ee3_common/com/pahimar/ee3/inventory/ContainerAludel.java index 08a569ea..c19d3dff 100644 --- a/ee3_common/com/pahimar/ee3/inventory/ContainerAludel.java +++ b/ee3_common/com/pahimar/ee3/inventory/ContainerAludel.java @@ -51,6 +51,37 @@ public class ContainerAludel extends Container { @Override public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) { - return null; + ItemStack itemStack = null; + Slot slot = (Slot) inventorySlots.get(slotIndex); + + if (slot != null && slot.getHasStack()) + { + ItemStack slotItemStack = slot.getStack(); + itemStack = slotItemStack.copy(); + + if (slotIndex < TileAludel.INVENTORY_SIZE) { + + if (!this.mergeItemStack(slotItemStack, TileAludel.INVENTORY_SIZE + 1, inventorySlots.size(), true)) { + return null; + } + } + else { + /* + * TODO: Depending on the slowItemStack, attempt to merge it into acceptable slots + */ + if (!this.mergeItemStack(slotItemStack, 0, TileAludel.INVENTORY_SIZE - 1, false)) { + return null; + } + } + + if (slotItemStack.stackSize == 0) { + slot.putStack((ItemStack) null); + } + else { + slot.onSlotChanged(); + } + } + + return itemStack; } } diff --git a/ee3_common/com/pahimar/ee3/inventory/ContainerGlassBell.java b/ee3_common/com/pahimar/ee3/inventory/ContainerGlassBell.java index cf28ead6..7f9d119a 100644 --- a/ee3_common/com/pahimar/ee3/inventory/ContainerGlassBell.java +++ b/ee3_common/com/pahimar/ee3/inventory/ContainerGlassBell.java @@ -48,7 +48,35 @@ public class ContainerGlassBell extends Container { @Override public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) { + + ItemStack itemStack = null; + Slot slot = (Slot) inventorySlots.get(slotIndex); - return null; + if (slot != null && slot.getHasStack()) + { + ItemStack slotItemStack = slot.getStack(); + itemStack = slotItemStack.copy(); + + if (slotIndex < TileGlassBell.INVENTORY_SIZE) { + + if (!this.mergeItemStack(slotItemStack, 1, inventorySlots.size(), true)) { + return null; + } + } + else { + if (!this.mergeItemStack(slotItemStack, 0, TileGlassBell.INVENTORY_SIZE, false)) { + return null; + } + } + + if (slotItemStack.stackSize == 0) { + slot.putStack((ItemStack) null); + } + else { + slot.onSlotChanged(); + } + } + + return itemStack; } } diff --git a/ee3_common/com/pahimar/ee3/tileentity/TileAlchemicalChest.java b/ee3_common/com/pahimar/ee3/tileentity/TileAlchemicalChest.java index a3dad9c4..0b578742 100644 --- a/ee3_common/com/pahimar/ee3/tileentity/TileAlchemicalChest.java +++ b/ee3_common/com/pahimar/ee3/tileentity/TileAlchemicalChest.java @@ -33,7 +33,7 @@ public class TileAlchemicalChest extends TileEE implements IInventory { /** Server sync counter (once per 20 ticks) */ private int ticksSinceSync; - private final int INVENTORY_SIZE = 13 * 4; + public static final int INVENTORY_SIZE = 13 * 4; /** * The ItemStacks that hold the items currently being used in the Alchemical diff --git a/ee3_common/com/pahimar/ee3/tileentity/TileAludel.java b/ee3_common/com/pahimar/ee3/tileentity/TileAludel.java index 6f5bfdd9..ae2646c9 100644 --- a/ee3_common/com/pahimar/ee3/tileentity/TileAludel.java +++ b/ee3_common/com/pahimar/ee3/tileentity/TileAludel.java @@ -27,7 +27,7 @@ public class TileAludel extends TileEE implements IInventory { */ private ItemStack[] inventory; - private final int INVENTORY_SIZE = 4; + public static final int INVENTORY_SIZE = 4; public static final int INPUT_INVENTORY_INDEX = 0; public static final int DUST_INVENTORY_INDEX = 1; diff --git a/ee3_common/com/pahimar/ee3/tileentity/TileCalcinator.java b/ee3_common/com/pahimar/ee3/tileentity/TileCalcinator.java index 0bd6ce9f..60d9dac2 100644 --- a/ee3_common/com/pahimar/ee3/tileentity/TileCalcinator.java +++ b/ee3_common/com/pahimar/ee3/tileentity/TileCalcinator.java @@ -23,7 +23,7 @@ public class TileCalcinator extends TileEE implements IInventory { */ private ItemStack[] inventory; - private final int INVENTORY_SIZE = 3; + public static final int INVENTORY_SIZE = 3; public static final int FUEL_INVENTORY_INDEX = 0; public static final int INPUT_INVENTORY_INDEX = 1; diff --git a/ee3_common/com/pahimar/ee3/tileentity/TileGlassBell.java b/ee3_common/com/pahimar/ee3/tileentity/TileGlassBell.java index 2541d1e8..915785bf 100644 --- a/ee3_common/com/pahimar/ee3/tileentity/TileGlassBell.java +++ b/ee3_common/com/pahimar/ee3/tileentity/TileGlassBell.java @@ -18,7 +18,7 @@ public class TileGlassBell extends TileEE implements IInventory { */ private ItemStack[] inventory; - private final int INVENTORY_SIZE = 1; + public static final int INVENTORY_SIZE = 1; public static final int DISPLAY_SLOT_INVENTORY_INDEX = 0;