summaryrefslogtreecommitdiff
path: root/common/darkknight/jewelrycraft/container/ContainerRingChest.java
diff options
context:
space:
mode:
authorOnyxDarkKnight <sor1n.iliutza16@gmail.com>2013-12-26 00:50:16 +0200
committerOnyxDarkKnight <sor1n.iliutza16@gmail.com>2013-12-26 00:50:16 +0200
commit1a3455b24d90b0def912c28467cbc51662d660e0 (patch)
tree90232ffe1b1a52ab43594b438cfac44ad3c0b60e /common/darkknight/jewelrycraft/container/ContainerRingChest.java
parent1997f4547812121223836dcacfcb31ea63acdda6 (diff)
Major changes. Thanks domi for helping me with the chest linking ring :)
Diffstat (limited to 'common/darkknight/jewelrycraft/container/ContainerRingChest.java')
-rw-r--r--common/darkknight/jewelrycraft/container/ContainerRingChest.java71
1 files changed, 71 insertions, 0 deletions
diff --git a/common/darkknight/jewelrycraft/container/ContainerRingChest.java b/common/darkknight/jewelrycraft/container/ContainerRingChest.java
new file mode 100644
index 0000000..2728941
--- /dev/null
+++ b/common/darkknight/jewelrycraft/container/ContainerRingChest.java
@@ -0,0 +1,71 @@
+package darkknight.jewelrycraft.container;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.Container;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntityChest;
+
+public class ContainerRingChest extends Container
+{
+ public TileEntityChest theChest;
+
+ public ContainerRingChest(InventoryPlayer inv, TileEntityChest chest)
+ {
+ theChest = chest;
+
+ int x, y;
+
+ for (x = 0; x < 9; x++)
+ addSlotToContainer(new SlotRingChest(inv, x, 8 + (18 * x), 142, x == inv.currentItem));
+ for (y = 0; y < 3; y++)
+ for (x = 0; x < 9; x++)
+ addSlotToContainer(new Slot(inv, x + 9 + (y * 9), 8 + (18 * x), 84 + (y * 18)));
+
+ for (y = 0; y < 3; y++)
+ for (x = 0; x < 9; x++)
+ addSlotToContainer(new SlotRingChest(chest, 26 - (x + (y * 9)), 8 + (18 * (8 - x)), 17 + ((2 - y) * 18), false));
+ }
+ @Override
+ public boolean canInteractWith(EntityPlayer player)
+ {
+ return true;
+ }
+
+ @Override
+ public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2)
+ {
+ ItemStack itemstack = null;
+ Slot slot = (Slot)this.inventorySlots.get(par2);
+
+ if (slot != null && slot.getHasStack())
+ {
+ ItemStack itemstack1 = slot.getStack();
+ itemstack = itemstack1.copy();
+
+ if (par2 < 27)
+ {
+ if (!this.mergeItemStack(itemstack1, 27, this.inventorySlots.size(), true))
+ {
+ return null;
+ }
+ }
+ else if (!this.mergeItemStack(itemstack1, 0, 27, false))
+ {
+ return null;
+ }
+
+ if (itemstack1.stackSize == 0)
+ {
+ slot.putStack((ItemStack)null);
+ }
+ else
+ {
+ slot.onSlotChanged();
+ }
+ }
+
+ return itemstack;
+ }
+}