From 420faddca46e70e3a70def168fb4e452ef193b0d Mon Sep 17 00:00:00 2001 From: OnyxDarkKnight Date: Sat, 21 Feb 2015 21:31:16 +0000 Subject: Added just a butt ton of stuff, also thanks to pau101 for helping me with the Hand Pedestal animation :) --- .../container/ContainerJewelryTab.java | 96 +++++++++++++--------- 1 file changed, 59 insertions(+), 37 deletions(-) (limited to 'java/darkknight/jewelrycraft/container/ContainerJewelryTab.java') diff --git a/java/darkknight/jewelrycraft/container/ContainerJewelryTab.java b/java/darkknight/jewelrycraft/container/ContainerJewelryTab.java index e33976a..701b338 100644 --- a/java/darkknight/jewelrycraft/container/ContainerJewelryTab.java +++ b/java/darkknight/jewelrycraft/container/ContainerJewelryTab.java @@ -1,65 +1,87 @@ 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.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import darkknight.jewelrycraft.JewelrycraftMod; +import darkknight.jewelrycraft.item.ItemBracelet; +import darkknight.jewelrycraft.item.ItemEarrings; +import darkknight.jewelrycraft.item.ItemNecklace; +import darkknight.jewelrycraft.item.ItemRing; public class ContainerJewelryTab extends Container { - public ContainerJewelryTab(EntityPlayer player, InventoryPlayer inv) + + /** + * @param player + * @param inv + * @param extra + */ + public ContainerJewelryTab(EntityPlayer player, IInventory inv, IInventory extra) { int x, y; // Rings - for (x = 0; x <= 9; x++) - this.addSlotToContainer(new SlotRing(new JewelryInventory(), x, 8 + x * 18, 7)); - + for(x = 0; x <= 9; x++) + addSlotToContainer(new SlotRing(extra, x, 8 + x * 18, 7)); + // Bracelets + for(x = 10; x <= 13; x++) + addSlotToContainer(new SlotBracelet(extra, x, 8 + (x - 10) * 18, 26)); + // Necklaces + for(x = 14; x <= 16; x++) + addSlotToContainer(new SlotNecklace(extra, x, 8 + (x - 14) * 18, 45)); + // Earrings + addSlotToContainer(new SlotEarrings(extra, 17, 8, 64)); // Hotbar - for (x = 0; x < 9; ++x) - this.addSlotToContainer(new Slot(inv, x, 17 + x * 18, 142)); - + for(x = 0; x < 9; ++x) + addSlotToContainer(new Slot(inv, x, 17 + x * 18, 142)); // Inventory - for (x = 0; x < 3; ++x) - for (y = 0; y < 9; ++y) - this.addSlotToContainer(new Slot(inv, 9 + y + x * 9, 17 + y * 18, 84 + x * 18)); - + for(x = 0; x < 3; ++x) + for(y = 0; y < 9; ++y) + addSlotToContainer(new Slot(inv, 9 + y + x * 9, 17 + y * 18, 84 + x * 18)); } + /** + * @param player + * @return + */ @Override public boolean canInteractWith(EntityPlayer player) { return true; } + /** + * @param player + * @param slotID + * @return + */ @Override - public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { 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(); -// } -// } -// + Slot slot = (Slot)inventorySlots.get(slotID); + if (slot != null && slot.getHasStack()){ + ItemStack itemstack1 = slot.getStack(); + itemstack = itemstack1.copy(); + if (slotID < 18){ + if (!mergeItemStack(itemstack1, 18, 18 + 36, true)) return null; + slot.onSlotChange(itemstack1, itemstack); + }else if (itemstack1.getItem() instanceof ItemRing){ + if (!mergeItemStack(itemstack1, 0, 10, false)) return null; + }else if (itemstack1.getItem() instanceof ItemBracelet){ + if (!mergeItemStack(itemstack1, 10, 14, false)) return null; + }else if (itemstack1.getItem() instanceof ItemNecklace){ + if (!mergeItemStack(itemstack1, 14, 17, false)) return null; + }else if (itemstack1.getItem() instanceof ItemEarrings){ + if (!mergeItemStack(itemstack1, 17, 18, false)) return null; + }else{ + if (!mergeItemStack(itemstack1, 18, 54, true)) return null; + slot.onSlotChange(itemstack1, itemstack); + } + if (itemstack1.stackSize == 0) slot.putStack((ItemStack)null); + else slot.onSlotChanged(); + } return itemstack; } } -- cgit v1.2.3