Search in sources :

Example 6 with FluidTankInfo

use of net.minecraftforge.fluids.FluidTankInfo in project PneumaticCraft by MineMaarten.

the class ModelPlasticMixer method renderStatic.

@Override
public void renderStatic(float size, TileEntity te) {
    Shape2.render(size);
    Shape3b.render(size);
    Shape1.render(size);
    Shape3.render(size);
    Shape4b.render(size);
    Shape4.render(size);
    if (te != null) {
        TileEntityPlasticMixer mixer = (TileEntityPlasticMixer) te;
        FluidTankInfo info = mixer.getTankInfo(null)[0];
        if (info.fluid != null && info.fluid.amount > 10) {
            float percentageFull = (float) info.fluid.amount / info.capacity;
            RenderInfo renderInfo = new RenderInfo(-6 / 16F + 0.01F, 22 / 16F - percentageFull * 13.999F / 16F, -6 / 16F + 0.01F, 6 / 16F - 0.01F, 22 / 16F, 6 / 16F - 0.01F);
            RenderUtils.INSTANCE.renderLiquid(info, renderInfo, mixer.getWorldObj());
        }
    }
}
Also used : FluidTankInfo(net.minecraftforge.fluids.FluidTankInfo) TileEntityPlasticMixer(pneumaticCraft.common.tileentity.TileEntityPlasticMixer) RenderInfo(pneumaticCraft.client.util.RenderUtils.RenderInfo)

Example 7 with FluidTankInfo

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;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) FluidTankInfo(net.minecraftforge.fluids.FluidTankInfo) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) IFluidHandler(net.minecraftforge.fluids.IFluidHandler)

Example 8 with FluidTankInfo

use of net.minecraftforge.fluids.FluidTankInfo in project PneumaticCraft by MineMaarten.

the class ProgWidgetLiquidInventoryCondition method getEvaluator.

@Override
protected DroneAIBlockCondition getEvaluator(IDroneBase drone, IProgWidget widget) {
    return new DroneAIBlockCondition(drone, (ProgWidgetAreaItemBase) widget) {

        @Override
        protected boolean evaluate(ChunkPosition pos) {
            TileEntity te = drone.getWorld().getTileEntity(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ);
            int count = 0;
            if (te instanceof IFluidHandler) {
                List<FluidStack> visitedStacks = new ArrayList<FluidStack>();
                IFluidHandler inv = (IFluidHandler) te;
                for (int i = 0; i < 6; i++) {
                    if (((ISidedWidget) widget).getSides()[i]) {
                        FluidTankInfo[] info = inv.getTankInfo(ForgeDirection.getOrientation(i));
                        if (info != null) {
                            for (FluidTankInfo inf : info) {
                                if (inf.fluid != null && !visitedStacks.contains(visitedStacks) && ProgWidgetLiquidFilter.isLiquidValid(inf.fluid.getFluid(), widget, 1)) {
                                    visitedStacks.add(inf.fluid);
                                    count += inf.fluid.amount;
                                }
                            }
                        }
                    }
                }
            } else {
                Fluid fluid = FluidRegistry.lookupFluidForBlock(drone.getWorld().getBlock(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ));
                if (fluid != null && ProgWidgetLiquidFilter.isLiquidValid(fluid, widget, 1) && FluidUtils.isSourceBlock(drone.getWorld(), pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ)) {
                    count += 1000;
                }
            }
            return ((ICondition) widget).getOperator() == ICondition.Operator.EQUALS ? count == ((ICondition) widget).getRequiredCount() : count >= ((ICondition) widget).getRequiredCount();
        }
    };
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) FluidTankInfo(net.minecraftforge.fluids.FluidTankInfo) DroneAIBlockCondition(pneumaticCraft.common.ai.DroneAIBlockCondition) FluidStack(net.minecraftforge.fluids.FluidStack) ChunkPosition(net.minecraft.world.ChunkPosition) Fluid(net.minecraftforge.fluids.Fluid) ArrayList(java.util.ArrayList) IFluidHandler(net.minecraftforge.fluids.IFluidHandler)

Example 9 with FluidTankInfo

use of net.minecraftforge.fluids.FluidTankInfo in project ImmersiveEngineering by BluSunrize.

the class MultiFluidTank method getInfo.

@Override
public FluidTankInfo getInfo() {
    FluidStack fs = getFluid();
    int capacity = this.capacity - getFluidAmount();
    if (fs != null)
        capacity += fs.amount;
    return new FluidTankInfo(fs, capacity);
}
Also used : FluidTankInfo(net.minecraftforge.fluids.FluidTankInfo) FluidStack(net.minecraftforge.fluids.FluidStack)

Example 10 with FluidTankInfo

use of net.minecraftforge.fluids.FluidTankInfo in project PneumaticCraft by MineMaarten.

the class ModelLiquidHopper method renderMain.

@Override
protected void renderMain(TileEntityOmnidirectionalHopper hopper) {
    if (hopper != null) {
        TileEntityLiquidHopper liquidHopper = (TileEntityLiquidHopper) hopper;
        FluidTankInfo info = liquidHopper.getTankInfo(null)[0];
        int fluidAmount = info.fluid != null ? info.fluid.amount - info.capacity / 10 : 0;
        if (fluidAmount > 10) {
            GL11.glDisable(GL11.GL_LIGHTING);
            float percentageFull = Math.min(1, fluidAmount / (info.capacity * 0.3F));
            RenderInfo renderInfo = new RenderInfo(-4 / 16F + 0.001F, 12 / 16F + 0.001F, 4 / 16F - percentageFull * 5.999F / 16F, 4 / 16F - 0.001F, 20 / 16F - 0.001F, 4 / 16F - 0.001F);
            RenderUtils.INSTANCE.renderLiquid(info, renderInfo, liquidHopper.getWorldObj());
            fluidAmount -= info.capacity * 0.3F;
            if (fluidAmount > 10) {
                percentageFull = Math.min(1, fluidAmount / (info.capacity * 0.3F));
                renderInfo = new RenderInfo(-6 / 16F + 0.001F, 10 / 16F + 0.001F, -2 / 16F - percentageFull * 0.999F / 16F, 6 / 16F - 0.001F, 22 / 16F - 0.001F, -2 / 16F - 0.001F);
                RenderUtils.INSTANCE.renderLiquid(info, renderInfo, liquidHopper.getWorldObj());
                fluidAmount -= info.capacity * 0.3F;
                if (fluidAmount > 10) {
                    percentageFull = Math.min(1, fluidAmount / (info.capacity * 0.3F));
                    renderInfo = new RenderInfo(6 / 16F + 0.001F, 8 / 16F + 0.001F, -2 / 16F - percentageFull * 5.999F / 16F, 8 / 16F - 0.001F, 24 / 16F - 0.001F, -2 / 16F - 0.001F);
                    RenderUtils.INSTANCE.renderLiquid(info, renderInfo, liquidHopper.getWorldObj());
                    renderInfo = new RenderInfo(-8 / 16F + 0.001F, 8 / 16F + 0.001F, -2 / 16F - percentageFull * 5.999F / 16F, -6 / 16F - 0.001F, 24 / 16F - 0.001F, -2 / 16F - 0.001F);
                    RenderUtils.INSTANCE.renderLiquid(info, renderInfo, liquidHopper.getWorldObj());
                    renderInfo = new RenderInfo(-6 / 16F + 0.001F, 22 / 16F + 0.001F, -2 / 16F - percentageFull * 5.999F / 16F, 6 / 16F - 0.001F, 24 / 16F - 0.001F, -2 / 16F - 0.001F);
                    RenderUtils.INSTANCE.renderLiquid(info, renderInfo, liquidHopper.getWorldObj());
                    renderInfo = new RenderInfo(-6 / 16F + 0.001F, 8 / 16F + 0.001F, -2 / 16F - percentageFull * 5.999F / 16F, 6 / 16F - 0.001F, 10 / 16F - 0.001F, -2 / 16F - 0.001F);
                    RenderUtils.INSTANCE.renderLiquid(info, renderInfo, liquidHopper.getWorldObj());
                }
            }
            FMLClientHandler.instance().getClient().getTextureManager().bindTexture(getModelTexture(hopper));
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glColor4d(1, 1, 1, 1);
        }
    }
}
Also used : FluidTankInfo(net.minecraftforge.fluids.FluidTankInfo) TileEntityLiquidHopper(pneumaticCraft.common.tileentity.TileEntityLiquidHopper) RenderInfo(pneumaticCraft.client.util.RenderUtils.RenderInfo)

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