71 lines
1.8 KiB
Java
71 lines
1.8 KiB
Java
![]() |
package WayofTime.bloodmagic.tile;
|
||
|
|
||
|
import net.minecraft.nbt.NBTTagCompound;
|
||
|
import net.minecraft.tileentity.TileEntity;
|
||
|
import net.minecraft.util.EnumFacing;
|
||
|
import net.minecraftforge.fluids.*;
|
||
|
|
||
|
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)
|
||
|
{
|
||
|
return new FluidTankInfo[]{tank.getInfo()};
|
||
|
}
|
||
|
|
||
|
@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);
|
||
|
if (tank.getFluidAmount() != 0) tagCompound.setTag("tank", tank.writeToNBT(new NBTTagCompound()));
|
||
|
tagCompound.setInteger("capacity", capacity);
|
||
|
}
|
||
|
}
|