diff options
| author | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2015-01-29 18:28:37 +0000 |
|---|---|---|
| committer | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2015-01-29 18:28:37 +0000 |
| commit | 73ca377dc01f859dabd7b07738cb7aeb762272b1 (patch) | |
| tree | 9c0acccbfbf78e813fb838ab566c96a40c5f36bb /java/darkknight/jewelrycraft/container/JewelryInventory.java | |
| parent | 06f62473f0622efe6decc32b70516a7c5d3d3572 (diff) | |
Made lots of changes
Diffstat (limited to 'java/darkknight/jewelrycraft/container/JewelryInventory.java')
| -rw-r--r-- | java/darkknight/jewelrycraft/container/JewelryInventory.java | 118 |
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 |
