Implement a functioning Blood Tank (#969)
Added a search bar to the Upgrade Tomes Creative Tab Updated some Altar fluid code (remove deprecated stuff) Moved Rendering classes into appropriate package Fix the localization errors on the Demon Crystals A few cleanups here and there
This commit is contained in:
parent
d1f4e95a7e
commit
aac2623440
40 changed files with 929 additions and 249 deletions
|
@ -1,70 +1,92 @@
|
|||
package WayofTime.bloodmagic.tile;
|
||||
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.tile.base.TileBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.fluids.*;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
|
||||
public class TileBloodTank extends TileBase implements IFluidHandler
|
||||
public class TileBloodTank extends TileBase
|
||||
{
|
||||
public static int capacity;
|
||||
public FluidTank tank;
|
||||
public int capacity;
|
||||
protected FluidTank tank;
|
||||
|
||||
public TileBloodTank()
|
||||
public static int[] capacities = { 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65336, 131072, 262144, 524288 };
|
||||
|
||||
public TileBloodTank(int meta)
|
||||
{
|
||||
capacity = 32 * FluidContainerRegistry.BUCKET_VOLUME;
|
||||
capacity = capacities[meta] * Fluid.BUCKET_VOLUME;
|
||||
tank = new FluidTank(capacity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill)
|
||||
public TileBloodTank()
|
||||
{
|
||||
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() };
|
||||
capacity = capacities[0] * Fluid.BUCKET_VOLUME;
|
||||
tank = new FluidTank(capacity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(NBTTagCompound tagCompound)
|
||||
{
|
||||
tank.readFromNBT(tagCompound.getCompoundTag("tank"));
|
||||
capacity = tagCompound.getInteger("capacity");
|
||||
super.deserialize(tagCompound);
|
||||
tank.readFromNBT(tagCompound.getCompoundTag(Constants.NBT.TANK));
|
||||
capacity = tagCompound.getInteger(Constants.NBT.ALTAR_CAPACITY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound serialize(NBTTagCompound tagCompound)
|
||||
{
|
||||
super.serialize(tagCompound);
|
||||
if (tank.getFluidAmount() != 0)
|
||||
tagCompound.setTag("tank", tank.writeToNBT(new NBTTagCompound()));
|
||||
tagCompound.setInteger("capacity", capacity);
|
||||
tagCompound.setTag(Constants.NBT.TANK, tank.writeToNBT(new NBTTagCompound()));
|
||||
tagCompound.setInteger(Constants.NBT.ALTAR_CAPACITY, capacity);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
public int getCapacity()
|
||||
{
|
||||
return capacity;
|
||||
}
|
||||
|
||||
public FluidTank getTank()
|
||||
{
|
||||
return tank;
|
||||
}
|
||||
|
||||
public Fluid getClientRenderFluid()
|
||||
{
|
||||
if (tank != null && tank.getFluid() != null)
|
||||
return tank.getFluid().getFluid();
|
||||
return null;
|
||||
}
|
||||
|
||||
public float getRenderHeight()
|
||||
{
|
||||
if (tank != null && tank.getFluidAmount() > 0)
|
||||
return (float) tank.getFluidAmount() / (float) getCapacity();
|
||||
return 0F;
|
||||
}
|
||||
|
||||
public int getComparatorOutput()
|
||||
{
|
||||
return tank.getFluidAmount() > 0 ? (int) (1 + ((double) tank.getFluidAmount() / (double) tank.getCapacity()) * 14) : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing)
|
||||
{
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing)
|
||||
{
|
||||
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)
|
||||
return (T) tank;
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue