summaryrefslogtreecommitdiff
path: root/src/main/java/gmail/Lance5057/containers
diff options
context:
space:
mode:
authorLance5057 <Lance5057@gmail.com>2015-02-25 03:30:35 -0600
committerLance5057 <Lance5057@gmail.com>2015-02-25 03:30:35 -0600
commit44f9836bd1542e381f8fd0a57c76d7a4b2f0008a (patch)
treea33601a9097e517a8eca3ff63ae4a9ddb8bccee8 /src/main/java/gmail/Lance5057/containers
parent11e81b501260a94bff6dac0cc699f6928c8fbb52 (diff)
Crest Mount finally stores items properly!
Diffstat (limited to 'src/main/java/gmail/Lance5057/containers')
-rw-r--r--src/main/java/gmail/Lance5057/containers/Container_CrestMount.java136
1 files changed, 21 insertions, 115 deletions
diff --git a/src/main/java/gmail/Lance5057/containers/Container_CrestMount.java b/src/main/java/gmail/Lance5057/containers/Container_CrestMount.java
index 5dd4f19..283eb4e 100644
--- a/src/main/java/gmail/Lance5057/containers/Container_CrestMount.java
+++ b/src/main/java/gmail/Lance5057/containers/Container_CrestMount.java
@@ -9,40 +9,32 @@ import net.minecraft.item.ItemStack;
public class Container_CrestMount extends Container
{
- private static final int INV_START = TileEntity_CrestMount.invSize, INV_END = INV_START+26,
- HOTBAR_START = INV_END+1, HOTBAR_END = HOTBAR_START+8;
- public final TileEntity_CrestMount inventory;
-
- public Container_CrestMount(EntityPlayer par1Player, InventoryPlayer inventoryPlayer, TileEntity_CrestMount TileEntity_CrestMount)
- {
- this.inventory = TileEntity_CrestMount;
-
- int i;
-
- for (i = 0; i < TileEntity_CrestMount.invSize; ++i)
- {
- this.addSlotToContainer(new Slot(this.inventory, i, 80 + (18 * (int)(i/4)), 8 + (18*(i%4))));
- }
-
- for (i = 0; i < 3; ++i)
- {
- for (int j = 0; j < 9; ++j)
- {
- this.addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
- }
- }
-
- for (i = 0; i < 9; ++i)
- {
- this.addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 142));
- }
+ public Container_CrestMount(InventoryPlayer inventoryPlayer, TileEntity_CrestMount TileEntity_CrestMount)
+ {
+ addSlotToContainer(new Slot(TileEntity_CrestMount, 0, 0, 0));
+ addSlotToContainer(new Slot(TileEntity_CrestMount, 1, 0, 16));
+ addSlotToContainer(new Slot(TileEntity_CrestMount, 2, 0, 32));
+ addSlotToContainer(new Slot(TileEntity_CrestMount, 3, 0, 48));
+
+ for (int x = 0; x < 9; x++)
+ {
+ addSlotToContainer(new Slot(inventoryPlayer, x, 8 + 18 * x, 142));
+ }
+
+ for (int y = 0; y < 3; y++)
+ {
+ for (int x = 0; x < 9; x++)
+ {
+ addSlotToContainer(new Slot(inventoryPlayer, x + y * 9 + 9, 8 + 18 * x, 84 + y * 18));
+ }
+ }
}
@Override
public boolean canInteractWith(EntityPlayer player) {
- return inventory.isUseableByPlayer(player);
+ return true;
}
/**
@@ -51,93 +43,7 @@ public class Container_CrestMount extends Container
*/
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 item is in our custom Inventory or armor slot
- if (par2 < INV_START)
- {
- // try to place in player inventory / action bar
- if (!this.mergeItemStack(itemstack1, INV_START, HOTBAR_END + 1, true))
- {
- return null;
- }
-
- slot.onSlotChange(itemstack1, itemstack);
- }
- // Item is in inventory / hotbar, try to place in custom inventory or armor slots
- else
- {
- /* If your inventory only stores certain instances of Items,
- * you can implement shift-clicking to your inventory like this:
- // Check that the item is the right type
- if (itemstack1.getItem() instanceof ItemCustom)
- {
- // Try to merge into your custom inventory slots
- // We use 'InventoryItem.INV_SIZE' instead of INV_START just in case
- // you also add armor or other custom slots
- if (!this.mergeItemStack(itemstack1, 0, InventoryItem.INV_SIZE, false))
- {
- return null;
- }
- }
- // If you added armor slots, check them here as well:
- // Item being shift-clicked is armor - try to put in armor slot
- if (itemstack1.getItem() instanceof ItemArmor)
- {
- int type = ((ItemArmor) itemstack1.getItem()).armorType;
- if (!this.mergeItemStack(itemstack1, ARMOR_START + type, ARMOR_START + type + 1, false))
- {
- return null;
- }
- }
- * Otherwise, you have basically 2 choices:
- * 1. shift-clicking between action bar and inventory
- * 2. shift-clicking between player inventory and custom inventory
- * I've implemented number 1:
- */
- // item is in player's inventory, but not in action bar
- if (par2 >= INV_START && par2 < HOTBAR_START)
- {
- // place in action bar
- if (!this.mergeItemStack(itemstack1, HOTBAR_START, HOTBAR_END + 1, false))
- {
- return null;
- }
- }
- // item in action bar - place in player inventory
- else if (par2 >= HOTBAR_START && par2 < HOTBAR_END + 1)
- {
- if (!this.mergeItemStack(itemstack1, INV_START, INV_END + 1, false))
- {
- return null;
- }
- }
- }
-
- if (itemstack1.stackSize == 0)
- {
- slot.putStack((ItemStack) null);
- }
- else
- {
- slot.onSlotChanged();
- }
-
- if (itemstack1.stackSize == itemstack.stackSize)
- {
- return null;
- }
-
- slot.onPickupFromSlot(par1EntityPlayer, itemstack1);
- }
-
- return itemstack;
+ return null;
}
}