2016-02-18 17:25:11 +01:00
|
|
|
package WayofTime.bloodmagic.tile;
|
|
|
|
|
2016-09-07 17:46:06 -07:00
|
|
|
import WayofTime.bloodmagic.tile.base.TileBase;
|
2016-02-18 17:25:11 +01:00
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
import net.minecraft.util.EnumFacing;
|
2016-03-17 13:00:44 -07:00
|
|
|
import net.minecraftforge.fluids.*;
|
2016-02-18 17:25:11 +01:00
|
|
|
|
2016-09-07 17:46:06 -07:00
|
|
|
public class TileBloodTank extends TileBase implements IFluidHandler
|
2016-02-18 17:25:11 +01:00
|
|
|
{
|
|
|
|
public static int capacity;
|
|
|
|
public FluidTank tank;
|
|
|
|
|
|
|
|
public TileBloodTank()
|
|
|
|
{
|
|
|
|
capacity = 32 * FluidContainerRegistry.BUCKET_VOLUME;
|
|
|
|
tank = new FluidTank(capacity);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int fill(EnumFacing from, FluidStack resource, boolean doFill)
|
|
|
|
{
|
|
|
|
return tank.fill(resource, doFill);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain)
|
|
|
|
{
|
|
|
|
return tank.drain(resource.amount, doDrain);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain)
|
|
|
|
{
|
|
|
|
return tank.drain(maxDrain, doDrain);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canFill(EnumFacing from, Fluid fluid)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canDrain(EnumFacing from, Fluid fluid)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public FluidTankInfo[] getTankInfo(EnumFacing from)
|
|
|
|
{
|
2016-03-16 18:41:06 -04:00
|
|
|
return new FluidTankInfo[] { tank.getInfo() };
|
2016-02-18 17:25:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-09-07 17:46:06 -07:00
|
|
|
public void deserialize(NBTTagCompound tagCompound)
|
2016-02-18 17:25:11 +01:00
|
|
|
{
|
|
|
|
tank.readFromNBT(tagCompound.getCompoundTag("tank"));
|
|
|
|
capacity = tagCompound.getInteger("capacity");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-09-07 17:46:06 -07:00
|
|
|
public NBTTagCompound serialize(NBTTagCompound tagCompound)
|
2016-02-18 17:25:11 +01:00
|
|
|
{
|
2016-03-16 18:41:06 -04:00
|
|
|
if (tank.getFluidAmount() != 0)
|
|
|
|
tagCompound.setTag("tank", tank.writeToNBT(new NBTTagCompound()));
|
2016-02-18 17:25:11 +01:00
|
|
|
tagCompound.setInteger("capacity", capacity);
|
2016-05-19 17:43:33 -07:00
|
|
|
return tagCompound;
|
2016-02-18 17:25:11 +01:00
|
|
|
}
|
|
|
|
}
|