From 73ca377dc01f859dabd7b07738cb7aeb762272b1 Mon Sep 17 00:00:00 2001 From: OnyxDarkKnight Date: Thu, 29 Jan 2015 18:28:37 +0000 Subject: Made lots of changes --- .../jewelrycraft/container/JewelryInventory.java | 118 +++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 java/darkknight/jewelrycraft/container/JewelryInventory.java (limited to 'java/darkknight/jewelrycraft/container/JewelryInventory.java') 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 -- cgit v1.2.3