summaryrefslogtreecommitdiff
path: root/java/darkknight/jewelrycraft/container/JewelryInventory.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/darkknight/jewelrycraft/container/JewelryInventory.java')
-rw-r--r--java/darkknight/jewelrycraft/container/JewelryInventory.java118
1 files changed, 118 insertions, 0 deletions
diff --git a/java/darkknight/jewelrycraft/container/JewelryInventory.java b/java/darkknight/jewelrycraft/container/JewelryInventory.java
new file mode 100644
index 0000000..05accfa
--- /dev/null
+++ b/java/darkknight/jewelrycraft/container/JewelryInventory.java
@@ -0,0 +1,118 @@
+package darkknight.jewelrycraft.container;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+
+public class JewelryInventory implements IInventory
+{
+ public ItemStack[] inventory = new ItemStack[18];
+ public JewelryInventory()
+ {
+ }
+
+ @Override
+ public int getSizeInventory()
+ {
+ return inventory.length;
+ }
+
+ @Override
+ public ItemStack getStackInSlot(int slot)
+ {
+ return inventory[slot];
+ }
+
+ @Override
+ public ItemStack decrStackSize(int slot, int amount)
+ {
+ ItemStack stack = getStackInSlot(slot);
+ if (stack != null)
+ {
+ if (stack.stackSize > amount)
+ {
+ stack = stack.splitStack(amount);
+ markDirty();
+ }
+ else
+ {
+ setInventorySlotContents(slot, null);
+ }
+ }
+
+ return stack;
+ }
+
+ @Override
+ public ItemStack getStackInSlotOnClosing(int slot)
+ {
+ ItemStack stack = getStackInSlot(slot);
+ setInventorySlotContents(slot, null);
+ return stack;
+ }
+
+ @Override
+ public void setInventorySlotContents(int slot, ItemStack stack)
+ {
+ inventory[slot] = stack;
+ if (stack != null && stack.stackSize > getInventoryStackLimit())
+ {
+ stack.stackSize = getInventoryStackLimit();
+ }
+ markDirty();
+ }
+
+ @Override
+ public String getInventoryName()
+ {
+ return "Jewelry";
+ }
+
+ @Override
+ public boolean hasCustomInventoryName()
+ {
+ return false;
+ }
+
+ @Override
+ public int getInventoryStackLimit()
+ {
+ return 1;
+ }
+
+ @Override
+ public void markDirty()
+ {
+ for (int i = 0; i < getSizeInventory(); ++i)
+ {
+ if (getStackInSlot(i) != null && getStackInSlot(i).stackSize == 0)
+ {
+ inventory[i] = null;
+ }
+ }
+ }
+
+ @Override
+ public boolean isUseableByPlayer(EntityPlayer player)
+ {
+ return true;
+ }
+
+ @Override
+ public void openInventory()
+ {
+ }
+
+ @Override
+ public void closeInventory()
+ {
+ }
+
+ @Override
+ public boolean isItemValidForSlot(int slot, ItemStack stack)
+ {
+ return true;
+ }
+} \ No newline at end of file