use of net.minecraftforge.fluids.FluidTankInfo in project LogisticsPipes by RS485.
the class BuildCraftTankHandler method getAvailableLiquid.
@Override
public Map<FluidIdentifier, Long> getAvailableLiquid(TileEntity tile) {
Map<FluidIdentifier, Long> map = new HashMap<>();
FluidTankInfo[] tanks = ((IFluidHandler) tile).getTankInfo(ForgeDirection.UNKNOWN);
for (FluidTankInfo tank : tanks) {
if (tank == null) {
continue;
}
FluidStack liquid;
if ((liquid = tank.fluid) != null && liquid.getFluidID() != 0) {
FluidIdentifier ident = FluidIdentifier.get(liquid);
if (((IFluidHandler) tile).drain(ForgeDirection.UNKNOWN, 1, false) != null) {
if (map.containsKey(ident)) {
long addition = map.get(ident) + tank.fluid.amount;
map.put(ident, addition);
} else {
map.put(ident, (long) tank.fluid.amount);
}
}
}
}
return map;
}
use of net.minecraftforge.fluids.FluidTankInfo in project LogisticsPipes by RS485.
the class FluidIdentifier method getFreeSpaceInsideTank.
public int getFreeSpaceInsideTank(IFluidHandler container, ForgeDirection dir) {
int free = 0;
FluidTankInfo[] tanks = container.getTankInfo(dir);
if (tanks != null && tanks.length > 0) {
for (FluidTankInfo tank : tanks) {
free += getFreeSpaceInsideTank(tank);
}
}
return free;
}
use of net.minecraftforge.fluids.FluidTankInfo in project Galacticraft by micdoodle8.
the class GCNEIHighlightHandler method handleTextData.
@Override
public List<String> handleTextData(ItemStack stack, World world, EntityPlayer player, MovingObjectPosition mop, List<String> currenttip, ItemInfo.Layout layout) {
if (stack != null) {
if (stack.getItem() == Item.getItemFromBlock(GCBlocks.fluidTank)) {
if (layout == ItemInfo.Layout.BODY) {
TileEntity tile = world.getTileEntity(mop.getBlockPos());
if (tile instanceof TileEntityFluidTank) {
TileEntityFluidTank tank = (TileEntityFluidTank) tile;
FluidTankInfo[] infos = tank.getTankInfo(EnumFacing.DOWN);
if (infos.length == 1) {
FluidTankInfo info = infos[0];
currenttip.add(info.fluid != null ? info.fluid.getLocalizedName() : "Empty");
currenttip.add((info.fluid != null ? info.fluid.amount : 0) + " / " + info.capacity);
}
}
}
} else if (stack.getItem() == Item.getItemFromBlock(GCBlocks.oxygenPipe) || stack.getItem() == Item.getItemFromBlock(GCBlocks.oxygenPipePull)) {
if (layout == ItemInfo.Layout.BODY) {
TileEntity tile = world.getTileEntity(mop.getBlockPos());
if (tile instanceof TileEntityFluidPipe) {
TileEntityFluidPipe pipe = (TileEntityFluidPipe) tile;
currenttip.add(((BlockFluidPipe) pipe.getBlockType()).getMode().toString());
if (pipe.hasNetwork()) {
FluidNetwork network = ((FluidNetwork) pipe.getNetwork());
currenttip.add("Network: " + (network.buffer != null ? network.buffer.amount : 0) + " / " + network.getCapacity());
} else {
currenttip.add("Pipe: " + (pipe.getBuffer() != null ? pipe.getBuffer().amount + " / " + pipe.buffer.getCapacity() : "None"));
}
}
}
}
}
return currenttip;
}
use of net.minecraftforge.fluids.FluidTankInfo in project BuildCraft by BuildCraft.
the class TileTank method getTankInfo.
@Override
public FluidTankInfo[] getTankInfo(EnumFacing direction) {
if (isNotReady())
return new FluidTankInfo[0];
FluidTank compositeTank = new FluidTank(tank.getCapacity());
TileTank tile = getBottomTank();
if (tile != null && tile.tank.getFluid() != null) {
compositeTank.setFluid(tile.tank.getFluid().copy());
} else {
return new FluidTankInfo[] { compositeTank.getInfo() };
}
int capacity = tile.tank.getCapacity();
tile = getTankAbove(tile);
while (tile != null) {
FluidStack liquid = tile.tank.getFluid();
if (liquid == null || liquid.amount == 0) {
// NOOP
} else if (!compositeTank.getFluid().isFluidEqual(liquid)) {
break;
} else {
compositeTank.getFluid().amount += liquid.amount;
}
capacity += tile.tank.getCapacity();
tile = getTankAbove(tile);
}
compositeTank.setCapacity(capacity);
return new FluidTankInfo[] { compositeTank.getInfo() };
}
use of net.minecraftforge.fluids.FluidTankInfo in project PneumaticCraft by MineMaarten.
the class SemiBlockRequester method amountRequested.
@Override
public int amountRequested(FluidStack stack) {
int totalRequestingAmount = getTotalRequestedAmount(stack);
if (totalRequestingAmount > 0) {
TileEntity te = getTileEntity();
if (te instanceof IFluidHandler) {
int count = 0;
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
FluidTankInfo[] infos = ((IFluidHandler) te).getTankInfo(d);
if (infos != null) {
for (FluidTankInfo info : infos) {
if (info.fluid != null && info.fluid.getFluid() == stack.getFluid()) {
count += info.fluid.amount;
}
}
if (count > 0)
break;
}
}
count += getIncomingFluid(stack.getFluid());
int requested = Math.max(0, Math.min(stack.amount, totalRequestingAmount - count));
return requested;
}
}
return 0;
}
Aggregations