Added the ability for the blood altar to have its buffer tanks accessed

This commit is contained in:
WayofTime 2016-01-31 18:30:57 -05:00
parent 8d6bc20400
commit 932a767ecf
3 changed files with 116 additions and 44 deletions

View file

@ -3,6 +3,7 @@ Version 2.0.0-15
------------------------------------------------------
- Added blood lamp sigil array texture and reagent. Made it so the blood lamp sigil will place the light when right clicking on a block.
- Added magnetism sigil array texture and reagent.
- Added the ability for the blood altar to have its buffer tanks accessed (Untested)
------------------------------------------------------
Version 2.0.0-14

View file

@ -10,8 +10,11 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import WayofTime.bloodmagic.api.BlockStack;
import WayofTime.bloodmagic.api.BloodMagicAPI;
import WayofTime.bloodmagic.api.Constants;
@ -32,7 +35,7 @@ import WayofTime.bloodmagic.util.Utils;
import com.google.common.base.Enums;
import com.google.common.base.Strings;
public class BloodAltar
public class BloodAltar implements IFluidHandler
{
private TileAltar tileAltar;
private int internalCounter = 0;
@ -717,4 +720,106 @@ public class BloodAltar
{
return chargingFrequency == 0 ? 1 : chargingFrequency;
}
@Override
public int fill(EnumFacing from, FluidStack resource, boolean doFill)
{
if (resource == null || resource.getFluid() != BlockLifeEssence.getLifeEssence())
{
return 0;
}
if (!doFill)
{
if (fluidInput == null)
{
return Math.min(bufferCapacity, resource.amount);
}
if (!fluidInput.isFluidEqual(resource))
{
return 0;
}
return Math.min(bufferCapacity - fluidInput.amount, resource.amount);
}
if (fluidInput == null)
{
fluidInput = new FluidStack(resource, Math.min(bufferCapacity, resource.amount));
return fluidInput.amount;
}
if (!fluidInput.isFluidEqual(resource))
{
return 0;
}
int filled = bufferCapacity - fluidInput.amount;
if (resource.amount < filled)
{
fluidInput.amount += resource.amount;
filled = resource.amount;
} else
{
fluidInput.amount = bufferCapacity;
}
return filled;
}
@Override
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain)
{
if (resource == null || !resource.isFluidEqual(fluidOutput))
{
return null;
}
return drain(from, resource.amount, doDrain);
}
@Override
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain)
{
if (fluidOutput == null)
{
return null;
}
int drained = maxDrain;
if (fluidOutput.amount < drained)
{
drained = fluidOutput.amount;
}
FluidStack stack = new FluidStack(fluidOutput, drained);
if (doDrain)
{
fluidOutput.amount -= drained;
if (fluidOutput.amount <= 0)
{
fluidOutput = null;
}
}
return stack;
}
@Override
public boolean canFill(EnumFacing from, Fluid fluid)
{
return fluid == BlockLifeEssence.getLifeEssence();
}
@Override
public boolean canDrain(EnumFacing from, Fluid fluid)
{
return fluid == BlockLifeEssence.getLifeEssence();
}
@Override
public FluidTankInfo[] getTankInfo(EnumFacing from)
{
return new FluidTankInfo[] {};
}
}

View file

@ -8,12 +8,11 @@ import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import net.minecraftforge.fluids.IFluidTank;
import WayofTime.bloodmagic.altar.BloodAltar;
import WayofTime.bloodmagic.api.altar.EnumAltarTier;
import WayofTime.bloodmagic.api.altar.IBloodAltar;
public class TileAltar extends TileInventory implements IBloodAltar, ITickable, IFluidTank, IFluidHandler
public class TileAltar extends TileInventory implements IBloodAltar, ITickable, IFluidHandler
{
private BloodAltar bloodAltar;
@ -62,74 +61,41 @@ public class TileAltar extends TileInventory implements IBloodAltar, ITickable,
return slot == 0;
}
// IFluidHandler
@Override
public FluidTankInfo[] getTankInfo(EnumFacing from)
{
return new FluidTankInfo[0];
}
/* IFluidHandler */
@Override
public int fill(EnumFacing from, FluidStack resource, boolean doFill)
{
return 0;
return bloodAltar.fill(from, resource, doFill);
}
@Override
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain)
{
return null;
return bloodAltar.drain(from, resource, doDrain);
}
@Override
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain)
{
return null;
return bloodAltar.drain(from, maxDrain, doDrain);
}
@Override
public boolean canFill(EnumFacing from, Fluid fluid)
{
return false;
return bloodAltar.canFill(from, fluid);
}
@Override
public boolean canDrain(EnumFacing from, Fluid fluid)
{
return false;
}
// IFluidTank
@Override
public FluidStack getFluid()
{
return bloodAltar.getFluid();
return bloodAltar.canDrain(from, fluid);
}
@Override
public int getFluidAmount()
public FluidTankInfo[] getTankInfo(EnumFacing from)
{
return bloodAltar.getFluidAmount();
}
@Override
public FluidTankInfo getInfo()
{
return new FluidTankInfo(this);
}
@Override
public int fill(FluidStack resource, boolean doFill)
{
return 0;
}
@Override
public FluidStack drain(int maxDrain, boolean doDrain)
{
return null;
return bloodAltar.getTankInfo(from);
}
@Override