2016-02-18 17:25:11 +01:00
|
|
|
package WayofTime.bloodmagic.tile;
|
|
|
|
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraft.util.EnumFacing;
|
2016-02-25 08:54:18 -05:00
|
|
|
import net.minecraftforge.fluids.Fluid;
|
|
|
|
import net.minecraftforge.fluids.FluidContainerRegistry;
|
|
|
|
import net.minecraftforge.fluids.FluidStack;
|
|
|
|
import net.minecraftforge.fluids.FluidTank;
|
|
|
|
import net.minecraftforge.fluids.FluidTankInfo;
|
|
|
|
import net.minecraftforge.fluids.IFluidHandler;
|
2016-02-18 17:25:11 +01:00
|
|
|
|
|
|
|
public class TileBloodTank extends TileEntity implements IFluidHandler
|
|
|
|
{
|
|
|
|
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
|
|
|
|
public void readFromNBT(NBTTagCompound tagCompound)
|
|
|
|
{
|
|
|
|
super.readFromNBT(tagCompound);
|
|
|
|
tank.readFromNBT(tagCompound.getCompoundTag("tank"));
|
|
|
|
capacity = tagCompound.getInteger("capacity");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void writeToNBT(NBTTagCompound tagCompound)
|
|
|
|
{
|
|
|
|
super.writeToNBT(tagCompound);
|
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);
|
|
|
|
}
|
|
|
|
}
|