Make TEAltar extend TEInventory
This commit is contained in:
parent
35da0fadeb
commit
3cabfff188
1 changed files with 3 additions and 119 deletions
|
@ -36,10 +36,10 @@ import WayofTime.alchemicalWizardry.common.bloodAltarUpgrade.AltarUpgradeCompone
|
||||||
import WayofTime.alchemicalWizardry.common.bloodAltarUpgrade.UpgradedAltars;
|
import WayofTime.alchemicalWizardry.common.bloodAltarUpgrade.UpgradedAltars;
|
||||||
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
|
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;
|
public static final int sizeInv = 1;
|
||||||
private ItemStack[] inv;
|
|
||||||
private int resultID;
|
private int resultID;
|
||||||
private int resultDamage;
|
private int resultDamage;
|
||||||
private int upgradeLevel;
|
private int upgradeLevel;
|
||||||
|
@ -73,7 +73,7 @@ public class TEAltar extends TileEntity implements IInventory, IFluidTank, IFlui
|
||||||
|
|
||||||
public TEAltar()
|
public TEAltar()
|
||||||
{
|
{
|
||||||
this.inv = new ItemStack[1];
|
super(sizeInv);
|
||||||
resultID = 0;
|
resultID = 0;
|
||||||
resultDamage = 0;
|
resultDamage = 0;
|
||||||
this.capacity = FluidContainerRegistry.BUCKET_VOLUME * 10;
|
this.capacity = FluidContainerRegistry.BUCKET_VOLUME * 10;
|
||||||
|
@ -131,18 +131,6 @@ public class TEAltar extends TileEntity implements IInventory, IFluidTank, IFlui
|
||||||
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
|
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
|
||||||
{
|
{
|
||||||
super.readFromNBT(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");
|
resultID = par1NBTTagCompound.getInteger("resultID");
|
||||||
resultDamage = par1NBTTagCompound.getInteger("resultDamage");
|
resultDamage = par1NBTTagCompound.getInteger("resultDamage");
|
||||||
|
@ -214,24 +202,9 @@ public class TEAltar extends TileEntity implements IInventory, IFluidTank, IFlui
|
||||||
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
|
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
|
||||||
{
|
{
|
||||||
super.writeToNBT(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("resultID", resultID);
|
||||||
par1NBTTagCompound.setInteger("resultDamage", resultDamage);
|
par1NBTTagCompound.setInteger("resultDamage", resultDamage);
|
||||||
par1NBTTagCompound.setTag("Inventory", itemList);
|
|
||||||
|
|
||||||
if (fluid != null)
|
if (fluid != null)
|
||||||
{
|
{
|
||||||
|
@ -275,101 +248,12 @@ public class TEAltar extends TileEntity implements IInventory, IFluidTank, IFlui
|
||||||
par1NBTTagCompound.setInteger("cooldownAfterCrafting", cooldownAfterCrafting);
|
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
|
@Override
|
||||||
public String getInventoryName()
|
public String getInventoryName()
|
||||||
{
|
{
|
||||||
return "TEAltar";
|
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
|
//IFluidTank methods
|
||||||
@Override
|
@Override
|
||||||
public FluidStack getFluid()
|
public FluidStack getFluid()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue