Search in sources :

Example 11 with FluidTankInfo

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);
        }
    }
}
Also used : FluidTankInfo(net.minecraftforge.fluids.FluidTankInfo) TileEntityLiquidHopper(pneumaticCraft.common.tileentity.TileEntityLiquidHopper) RenderInfo(pneumaticCraft.client.util.RenderUtils.RenderInfo)

Example 12 with FluidTankInfo

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());
        }
    }
}
Also used : TileEntityRefinery(pneumaticCraft.common.tileentity.TileEntityRefinery) FluidTankInfo(net.minecraftforge.fluids.FluidTankInfo) RenderInfo(pneumaticCraft.client.util.RenderUtils.RenderInfo)

Example 13 with FluidTankInfo

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());
        }
    }
}
Also used : FluidTankInfo(net.minecraftforge.fluids.FluidTankInfo) TileEntityThermopneumaticProcessingPlant(pneumaticCraft.common.tileentity.TileEntityThermopneumaticProcessingPlant) RenderInfo(pneumaticCraft.client.util.RenderUtils.RenderInfo)

Example 14 with FluidTankInfo

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);
            }
        }
    }
}
Also used : IInventory(net.minecraft.inventory.IInventory) FluidTankInfo(net.minecraftforge.fluids.FluidTankInfo) IFluidContainerItem(net.minecraftforge.fluids.IFluidContainerItem) FluidStack(net.minecraftforge.fluids.FluidStack) ItemStack(net.minecraft.item.ItemStack) FluidContainerData(net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData) IFluidHandler(net.minecraftforge.fluids.IFluidHandler) TargetPoint(cpw.mods.fml.common.network.NetworkRegistry.TargetPoint)

Example 15 with FluidTankInfo

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;
}
Also used : FluidTankInfo(net.minecraftforge.fluids.FluidTankInfo)

Aggregations

FluidTankInfo (net.minecraftforge.fluids.FluidTankInfo)21 IFluidHandler (net.minecraftforge.fluids.IFluidHandler)11 FluidStack (net.minecraftforge.fluids.FluidStack)10 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)9 TileEntity (net.minecraft.tileentity.TileEntity)8 FluidIdentifier (logisticspipes.utils.FluidIdentifier)6 RenderInfo (pneumaticCraft.client.util.RenderUtils.RenderInfo)6 HashMap (java.util.HashMap)4 ISpecialTankAccessHandler (logisticspipes.interfaces.ISpecialTankAccessHandler)4 ISpecialTankHandler (logisticspipes.interfaces.ISpecialTankHandler)4 Map (java.util.Map)2 Entry (java.util.Map.Entry)2 LogisticsPipes (logisticspipes.LogisticsPipes)2 GuiIDs (logisticspipes.network.GuiIDs)2 MainProxy (logisticspipes.proxy.MainProxy)2 SimpleServiceLocator (logisticspipes.proxy.SimpleServiceLocator)2 RequestTree (logisticspipes.request.RequestTree)2 Textures (logisticspipes.textures.Textures)2 TextureType (logisticspipes.textures.Textures.TextureType)2 ItemIdentifier (logisticspipes.utils.item.ItemIdentifier)2