use of net.minecraftforge.fluids.FluidTankInfo in project PneumaticCraft by MineMaarten.
the class ModelLiquidHopper method renderBottom.
@Override
protected void renderBottom(TileEntityOmnidirectionalHopper hopper) {
if (hopper != null) {
TileEntityLiquidHopper liquidHopper = (TileEntityLiquidHopper) hopper;
FluidTankInfo info = liquidHopper.getTankInfo(null)[0];
if (info.fluid != null && info.fluid.amount > 10) {
GL11.glDisable(GL11.GL_LIGHTING);
float percentageFull = Math.min(1, (float) info.fluid.amount / (info.capacity / 10));
RenderInfo renderInfo = new RenderInfo(-2 / 16F + 0.001F, 14 / 16F + 0.001F, 8 / 16F - percentageFull * 3.999F / 16F, 2 / 16F - 0.001F, 18 / 16F - 0.001F, 8 / 16F - 0.001F);
RenderUtils.INSTANCE.renderLiquid(info, renderInfo, liquidHopper.getWorldObj());
GL11.glEnable(GL11.GL_LIGHTING);
}
}
}
use of net.minecraftforge.fluids.FluidTankInfo in project PneumaticCraft by MineMaarten.
the class ModelRefinery method renderStatic.
@Override
public void renderStatic(float size, TileEntity te) {
outputTank.render(size);
inputTank.render(size);
machineLeft.render(size);
machineRight.render(size);
machineMiddle.render(size);
if (te != null) {
TileEntityRefinery refinery = (TileEntityRefinery) te;
FluidTankInfo info = new FluidTankInfo(refinery.getOilTank());
if (info.fluid != null && info.fluid.amount > 10) {
float percentageFull = (float) info.fluid.amount / info.capacity;
RenderInfo renderInfo = new RenderInfo(-4 / 16F + 0.01F, 22 / 16F - percentageFull * 13.999F / 16F, 3 / 16F + 0.01F, 4 / 16F - 0.01F, 22 / 16F, 8 / 16F - 0.01F);
RenderUtils.INSTANCE.renderLiquid(info, renderInfo, refinery.getWorldObj());
}
info = refinery.getTankInfo(null)[1];
if (info.fluid != null && info.fluid.amount > 10) {
float percentageFull = (float) info.fluid.amount / info.capacity;
RenderInfo renderInfo = new RenderInfo(-4 / 16F + 0.01F, 24 / 16F - percentageFull * 15.999F / 16F, -8 / 16F + 0.01F, 4 / 16F - 0.01F, 24 / 16F, -3 / 16F - 0.01F);
RenderUtils.INSTANCE.renderLiquid(info, renderInfo, refinery.getWorldObj());
}
}
}
use of net.minecraftforge.fluids.FluidTankInfo in project PneumaticCraft by MineMaarten.
the class ModelThermopneumaticProcessingPlant method renderStatic.
@Override
public void renderStatic(float size, TileEntity te) {
itemPart.render(size);
inputTank.render(size);
outputTank.render(size);
pipe1.render(size);
pipe2.render(size);
pipe3.render(size);
pipe4.render(size);
airBottom.render(size);
airBack.render(size);
airLeft.render(size);
airRight.render(size);
if (te != null) {
TileEntityThermopneumaticProcessingPlant processor = (TileEntityThermopneumaticProcessingPlant) te;
FluidTankInfo info = processor.getTankInfo(null)[0];
if (info.fluid != null && info.fluid.amount > 10) {
float percentageFull = (float) info.fluid.amount / info.capacity;
RenderInfo renderInfo = new RenderInfo(-8 / 16F + 0.01F, 24 / 16F - percentageFull * 9.999F / 16F, 1 / 16F + 0.01F, -1 / 16F - 0.01F, 24 / 16F - 0.01F, 8 / 16F - 0.01F);
RenderUtils.INSTANCE.renderLiquid(info, renderInfo, processor.getWorldObj());
}
info = processor.getTankInfo(null)[1];
if (info.fluid != null && info.fluid.amount > 10) {
float percentageFull = (float) info.fluid.amount / info.capacity;
RenderInfo renderInfo = new RenderInfo(1 / 16F + 0.01F, 24 / 16F - percentageFull * 9.999F / 16F, 1 / 16F + 0.01F, 8 / 16F - 0.01F, 24 / 16F - 0.01F, 8 / 16F - 0.01F);
RenderUtils.INSTANCE.renderLiquid(info, renderInfo, processor.getWorldObj());
}
}
}
use of net.minecraftforge.fluids.FluidTankInfo in project PneumaticCraft by MineMaarten.
the class TileEntityBase method processFluidItem.
protected void processFluidItem(int inputSlot, int outputSlot) {
IInventory inv = (IInventory) this;
IFluidHandler fluidHandler = (IFluidHandler) this;
FluidTankInfo tankInfo = fluidHandler.getTankInfo(ForgeDirection.UNKNOWN)[0];
if (inv.getStackInSlot(inputSlot) != null) {
ItemStack fluidContainer = inv.getStackInSlot(inputSlot);
if (tankInfo.fluid == null || tankInfo.fluid.isFluidEqual(fluidContainer)) {
FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(fluidContainer);
int amount = FluidContainerRegistry.BUCKET_VOLUME;
if (fluid == null) {
if (fluidContainer.getItem() instanceof IFluidContainerItem) {
IFluidContainerItem containerItem = (IFluidContainerItem) fluidContainer.getItem();
fluid = containerItem.getFluid(fluidContainer);
if (fluid != null && fluidHandler.canFill(ForgeDirection.UNKNOWN, fluid.getFluid())) {
amount = fluid != null ? fluid.amount : 0;
int availableSpace = tankInfo.capacity - (tankInfo.fluid != null ? tankInfo.fluid.amount : 0);
if (availableSpace >= amount) {
ItemStack singleFuelItem = fluidContainer.copy();
singleFuelItem.stackSize = 1;
FluidStack drainedStack = containerItem.drain(singleFuelItem, availableSpace, true);
if (fluidContainer.stackSize == 1 || inv.getStackInSlot(outputSlot) == null || canStack(singleFuelItem, inv.getStackInSlot(outputSlot))) {
fluidHandler.fill(ForgeDirection.UNKNOWN, drainedStack, true);
if (fluidContainer.stackSize == 1) {
inv.setInventorySlotContents(inputSlot, singleFuelItem);
} else {
inv.getStackInSlot(inputSlot).stackSize--;
if (inv.getStackInSlot(outputSlot) == null) {
inv.setInventorySlotContents(outputSlot, singleFuelItem);
} else {
inv.getStackInSlot(outputSlot).stackSize++;
}
}
}
}
}
}
} else if (fluidHandler.canFill(ForgeDirection.UNKNOWN, fluid.getFluid())) {
if (tankInfo.capacity - (tankInfo.fluid != null ? tankInfo.fluid.amount : 0) >= amount) {
ItemStack returnedItem = null;
FluidContainerData[] allFluidData = FluidContainerRegistry.getRegisteredFluidContainerData();
for (FluidContainerData fluidData : allFluidData) {
if (fluidData.filledContainer.isItemEqual(fluidContainer)) {
returnedItem = fluidData.emptyContainer;
break;
}
}
if (returnedItem == null || inv.getStackInSlot(outputSlot) == null || canStack(returnedItem, inv.getStackInSlot(outputSlot))) {
if (returnedItem != null) {
if (inv.getStackInSlot(outputSlot) == null) {
inv.setInventorySlotContents(outputSlot, returnedItem.copy());
} else {
inv.getStackInSlot(outputSlot).stackSize += returnedItem.stackSize;
}
}
fluidHandler.fill(ForgeDirection.UNKNOWN, new FluidStack(fluid.getFluid(), amount, fluid.tag), true);
inv.getStackInSlot(inputSlot).stackSize--;
if (inv.getStackInSlot(inputSlot).stackSize <= 0)
inv.setInventorySlotContents(inputSlot, null);
}
}
}
}
if (fluidContainer.getItem() instanceof IFluidContainerItem) {
if (((IFluidContainerItem) fluidContainer.getItem()).getFluid(fluidContainer) == null && (inv.getStackInSlot(outputSlot) == null || canStack(fluidContainer, inv.getStackInSlot(outputSlot)))) {
if (inv.getStackInSlot(outputSlot) == null) {
inv.setInventorySlotContents(outputSlot, fluidContainer);
} else {
inv.getStackInSlot(outputSlot).stackSize += fluidContainer.stackSize;
}
inv.setInventorySlotContents(inputSlot, null);
}
}
}
}
use of net.minecraftforge.fluids.FluidTankInfo in project MinecraftForge by MinecraftForge.
the class FluidTankProperties method convert.
public static FluidTankProperties[] convert(FluidTankInfo[] fluidTankInfos) {
FluidTankProperties[] properties = new FluidTankProperties[fluidTankInfos.length];
for (int i = 0; i < fluidTankInfos.length; i++) {
FluidTankInfo info = fluidTankInfos[i];
properties[i] = new FluidTankProperties(info.fluid, info.capacity);
}
return properties;
}
Aggregations