Make TEAltar extend TEInventory
This commit is contained in:
parent
35da0fadeb
commit
3cabfff188
|
@ -36,10 +36,10 @@ import WayofTime.alchemicalWizardry.common.bloodAltarUpgrade.AltarUpgradeCompone
|
|||
import WayofTime.alchemicalWizardry.common.bloodAltarUpgrade.UpgradedAltars;
|
||||
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
|
||||
|
||||
public class TEAltar extends TileEntity implements IInventory, IFluidTank, IFluidHandler, IBloodAltar
|
||||
public class TEAltar extends TEInventory implements IFluidTank, IFluidHandler, IBloodAltar
|
||||
{
|
||||
public static final int sizeInv = 1;
|
||||
private ItemStack[] inv;
|
||||
|
||||
private int resultID;
|
||||
private int resultDamage;
|
||||
private int upgradeLevel;
|
||||
|
@ -73,7 +73,7 @@ public class TEAltar extends TileEntity implements IInventory, IFluidTank, IFlui
|
|||
|
||||
public TEAltar()
|
||||
{
|
||||
this.inv = new ItemStack[1];
|
||||
super(sizeInv);
|
||||
resultID = 0;
|
||||
resultDamage = 0;
|
||||
this.capacity = FluidContainerRegistry.BUCKET_VOLUME * 10;
|
||||
|
@ -131,18 +131,6 @@ public class TEAltar extends TileEntity implements IInventory, IFluidTank, IFlui
|
|||
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");
|
||||
|
@ -214,24 +202,9 @@ public class TEAltar extends TileEntity implements IInventory, IFluidTank, IFlui
|
|||
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);
|
||||
|
||||
if (fluid != null)
|
||||
{
|
||||
|
@ -275,101 +248,12 @@ public class TEAltar extends TileEntity implements IInventory, IFluidTank, IFlui
|
|||
par1NBTTagCompound.setInteger("cooldownAfterCrafting", cooldownAfterCrafting);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return inv.length;
|
||||
}
|
||||
|
||||
@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;
|
||||
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
|
||||
if (itemStack != null && itemStack.stackSize > getInventoryStackLimit())
|
||||
{
|
||||
itemStack.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName()
|
||||
{
|
||||
return "TEAltar";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
@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()
|
||||
{
|
||||
}
|
||||
|
||||
//IFluidTank methods
|
||||
@Override
|
||||
public FluidStack getFluid()
|
||||
|
|
Loading…
Reference in a new issue