From 8c65f1f3471775faea6bfedfbb225602e27a4bc0 Mon Sep 17 00:00:00 2001 From: ljfa-ag Date: Wed, 4 Mar 2015 14:04:05 +0100 Subject: [PATCH] Make TEPedestal extend TEInventory --- .../common/tileEntity/TEPedestal.java | 124 +----------------- 1 file changed, 5 insertions(+), 119 deletions(-) diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEPedestal.java b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEPedestal.java index a6ce9b1f..dcb522f3 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEPedestal.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/tileEntity/TEPedestal.java @@ -13,18 +13,18 @@ import net.minecraft.network.Packet; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.Constants; -public class TEPedestal extends TileEntity implements IInventory +public class TEPedestal extends TEInventory { - private ItemStack[] inv; + public static final int sizeInv = 1; + private int resultID; private int resultDamage; - public static final int sizeInv = 1; private boolean isActive; public TEPedestal() { - this.inv = new ItemStack[1]; + super(sizeInv); resultID = 0; resultDamage = 0; isActive = false; @@ -34,18 +34,6 @@ public class TEPedestal extends TileEntity implements IInventory public void readFromNBT(NBTTagCompound par1NBTTagCompound) { super.readFromNBT(par1NBTTagCompound); - NBTTagList tagList = par1NBTTagCompound.getTagList("Inventory", Constants.NBT.TAG_COMPOUND); - - for (int i = 0; i < tagList.tagCount(); i++) - { - NBTTagCompound tag = (NBTTagCompound) tagList.getCompoundTagAt(i); - int slot = tag.getByte("Slot"); - - if (slot >= 0 && slot < inv.length) - { - inv[slot] = ItemStack.loadItemStackFromNBT(tag); - } - } resultID = par1NBTTagCompound.getInteger("resultID"); resultDamage = par1NBTTagCompound.getInteger("resultDamage"); @@ -56,121 +44,24 @@ public class TEPedestal extends TileEntity implements IInventory public void writeToNBT(NBTTagCompound par1NBTTagCompound) { super.writeToNBT(par1NBTTagCompound); - NBTTagList itemList = new NBTTagList(); - - for (int i = 0; i < inv.length; i++) - { - ItemStack stack = inv[i]; - - if (inv[i] != null) - { - NBTTagCompound tag = new NBTTagCompound(); - tag.setByte("Slot", (byte) i); - inv[i].writeToNBT(tag); - itemList.appendTag(tag); - } - } par1NBTTagCompound.setInteger("resultID", resultID); par1NBTTagCompound.setInteger("resultDamage", resultDamage); - par1NBTTagCompound.setTag("Inventory", itemList); par1NBTTagCompound.setBoolean("isActive", isActive); } - @Override - public int getSizeInventory() - { - return 1; - } - - @Override - public ItemStack getStackInSlot(int slot) - { - return inv[slot]; - } - - @Override - public ItemStack decrStackSize(int slot, int amt) - { - ItemStack stack = getStackInSlot(slot); - - if (stack != null) - { - if (stack.stackSize <= amt) - { - setInventorySlotContents(slot, null); - } else - { - stack = stack.splitStack(amt); - - if (stack.stackSize == 0) - { - setInventorySlotContents(slot, null); - } - } - } - - return stack; - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) - { - ItemStack stack = getStackInSlot(slot); - - if (stack != null) - { - setInventorySlotContents(slot, null); - } - - return stack; - } - - @Override - public void setInventorySlotContents(int slot, ItemStack itemStack) - { - inv[slot] = itemStack; - - if (itemStack != null && itemStack.stackSize > getInventoryStackLimit()) - { - itemStack.stackSize = getInventoryStackLimit(); - } - } - @Override public String getInventoryName() { return "TEPedestal"; } - @Override - public boolean hasCustomInventoryName() - { - return false; - } - @Override public int getInventoryStackLimit() { return 1; } - @Override - public boolean isUseableByPlayer(EntityPlayer entityPlayer) - { - return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this && entityPlayer.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64; - } - - @Override - public void openInventory() - { - } - - @Override - public void closeInventory() - { - } - //Logic for the actual block is under here @Override public void updateEntity() @@ -243,12 +134,7 @@ public class TEPedestal extends TileEntity implements IInventory @Override public boolean isItemValidForSlot(int slot, ItemStack itemstack) { - if (slot == 0) - { - return true; - } - - return false; + return slot == 0; } public void onItemDeletion()