Search in sources :

Example 81 with FluidStack

use of net.minecraftforge.fluids.FluidStack in project Railcraft by Railcraft.

the class CartContentRendererTank method renderTank.

private void renderTank(RenderCart renderer, EntityCartTank cart, float light, float partialTicks, int x, int y, int z) {
    StandardTank tank = cart.getTankManager().get(0);
    if (tank != null) {
        FluidStack fluidStack = tank.getFluid();
        float cap = tank.getCapacity();
        if (cap > 0 && fluidStack != null && fluidStack.amount > 0) {
            OpenGL.glPushMatrix();
            OpenGL.glPushAttrib(GL11.GL_ENABLE_BIT);
            OpenGL.glEnable(GL11.GL_BLEND);
            OpenGL.glDisable(GL11.GL_LIGHTING);
            GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
            OpenGL.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
            OpenGL.glTranslatef(-0.5F, -0.501F + 0.0625f, -0.5F);
            float level = Math.min(fluidStack.amount / cap, cap);
            FluidModelRenderer.INSTANCE.renderFluid(fluidStack, Math.min(16, (int) Math.ceil(level * 16F)));
            if (cart.isFilling()) {
                float scale = 6F / 16F;
                OpenGL.glTranslatef(0.5F, 0F, 0.5F);
                OpenGL.glScalef(scale, 1F, scale);
                OpenGL.glTranslatef(-0.5F, 0F, -0.5F);
                FluidModelRenderer.INSTANCE.renderFluid(fluidStack, 16);
            }
            OpenGL.glDisable(GL11.GL_BLEND);
            OpenGL.glEnable(GL11.GL_LIGHTING);
            OpenGL.glPopAttrib();
            OpenGL.glPopMatrix();
        }
    }
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack) StandardTank(mods.railcraft.common.fluids.tanks.StandardTank)

Example 82 with FluidStack

use of net.minecraftforge.fluids.FluidStack in project Railcraft by Railcraft.

the class DetectorTank method testCarts.

@Override
public int testCarts(List<EntityMinecart> carts) {
    for (EntityMinecart cart : carts) {
        IFluidHandler fluidHandler = FluidTools.getFluidHandler(null, cart);
        if (fluidHandler != null) {
            AdvancedFluidHandler tank = new AdvancedFluidHandler(fluidHandler);
            boolean liquidMatches = false;
            Fluid filterFluid = getFilterFluid();
            FluidStack tankLiquid = tank.drain(1, false);
            if (filterFluid == null)
                liquidMatches = true;
            else if (Fluids.areEqual(filterFluid, tankLiquid))
                liquidMatches = true;
            else if (tank.canPutFluid(new FluidStack(filterFluid, 1)))
                liquidMatches = true;
            boolean quantityMatches = false;
            ButtonState state = buttonController.getButtonState();
            switch(state) {
                case VOID:
                    quantityMatches = true;
                    break;
                case EMPTY:
                    if (filterFluid != null && tank.isTankEmpty(filterFluid))
                        quantityMatches = true;
                    else if (filterFluid == null && tank.areTanksEmpty())
                        quantityMatches = true;
                    break;
                case NOT_EMPTY:
                    if (filterFluid != null && tank.getFluidQty(filterFluid) > 0)
                        quantityMatches = true;
                    else if (filterFluid == null && tank.isFluidInTank())
                        quantityMatches = true;
                    break;
                case FULL:
                    if (filterFluid != null && tank.isTankFull(filterFluid))
                        quantityMatches = true;
                    else if (filterFluid == null && tank.areTanksFull())
                        quantityMatches = true;
                    break;
                default:
                    float level = filterFluid != null ? tank.getFluidLevel(filterFluid) : tank.getFluidLevel();
                    switch(state) {
                        case ANALOG:
                            return (int) (FULL_POWER * level);
                        case QUARTER:
                            quantityMatches = level >= 0.25f;
                            break;
                        case HALF:
                            quantityMatches = level >= 0.5f;
                            break;
                        case MOST:
                            quantityMatches = level >= 0.75f;
                            break;
                        case LESS_THAN_QUARTER:
                            quantityMatches = level < 0.25f;
                            break;
                        case LESS_THAN_HALF:
                            quantityMatches = level < 0.5f;
                            break;
                        case LESS_THAN_MOST:
                            quantityMatches = level < 0.75f;
                            break;
                        case LESS_THAN_FULL:
                            quantityMatches = level < 1f;
                            break;
                    }
            }
            return liquidMatches && quantityMatches ? FULL_POWER : NO_POWER;
        }
    }
    return NO_POWER;
}
Also used : AdvancedFluidHandler(mods.railcraft.common.fluids.AdvancedFluidHandler) FluidStack(net.minecraftforge.fluids.FluidStack) Fluid(net.minecraftforge.fluids.Fluid) EntityMinecart(net.minecraft.entity.item.EntityMinecart) IMultiButtonState(mods.railcraft.common.gui.buttons.IMultiButtonState) IFluidHandler(net.minecraftforge.fluids.capability.IFluidHandler)

Example 83 with FluidStack

use of net.minecraftforge.fluids.FluidStack in project Railcraft by Railcraft.

the class TrainTransferHelper method canAcceptPushedFluid.

private boolean canAcceptPushedFluid(EntityMinecart requester, EntityMinecart cart, Fluid fluid) {
    IFluidHandler fluidHandler = FluidTools.getFluidHandler(EnumFacing.UP, cart);
    if (fluidHandler == null)
        return false;
    if (cart instanceof IFluidCart)
        return ((IFluidCart) cart).canAcceptPushedFluid(requester, fluid);
    AdvancedFluidHandler advancedFluidHandler = new AdvancedFluidHandler(fluidHandler);
    return advancedFluidHandler.canPutFluid(new FluidStack(fluid, 1));
}
Also used : AdvancedFluidHandler(mods.railcraft.common.fluids.AdvancedFluidHandler) FluidStack(net.minecraftforge.fluids.FluidStack) IFluidCart(mods.railcraft.api.carts.IFluidCart) IFluidHandler(net.minecraftforge.fluids.capability.IFluidHandler)

Example 84 with FluidStack

use of net.minecraftforge.fluids.FluidStack in project Railcraft by Railcraft.

the class FluidFuelProvider method getMoreFuel.

@Override
public double getMoreFuel() {
    FluidStack fuel = fuelTank.drain(FluidTools.BUCKET_VOLUME, false);
    if (fuel == null)
        return 0;
    double heatValue = FuelManager.getBoilerFuelValue(fuel.getFluid());
    if (heatValue > 0) {
        fuelTank.drain(FluidTools.BUCKET_VOLUME, true);
        if (fuel.amount < FluidTools.BUCKET_VOLUME)
            heatValue *= (double) fuel.amount / (double) FluidTools.BUCKET_VOLUME;
    }
    return heatValue;
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack)

Example 85 with FluidStack

use of net.minecraftforge.fluids.FluidStack in project Railcraft by Railcraft.

the class IBoilerContainer method onFillWater.

static void onFillWater(IBoilerContainer tileBoiler) {
    SteamBoiler boiler = tileBoiler.getBoiler();
    if (boiler != null && boiler.isSuperHeated() && Steam.BOILERS_EXPLODE) {
        FluidStack water = boiler.getTankWater().getFluid();
        if (Fluids.isEmpty(water)) {
            boiler.setHeat(Steam.SUPER_HEATED - 1);
            tileBoiler.explode();
        }
    }
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack)

Aggregations

FluidStack (net.minecraftforge.fluids.FluidStack)188 ItemStack (net.minecraft.item.ItemStack)63 TileEntity (net.minecraft.tileentity.TileEntity)30 Fluid (net.minecraftforge.fluids.Fluid)28 IFluidHandler (net.minecraftforge.fluids.IFluidHandler)25 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)19 ArrayList (java.util.ArrayList)18 IFluidHandler (net.minecraftforge.fluids.capability.IFluidHandler)16 Block (net.minecraft.block.Block)12 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)12 FluidTankInfo (net.minecraftforge.fluids.FluidTankInfo)10 Item (net.minecraft.item.Item)9 BlockPos (net.minecraft.util.math.BlockPos)9 HashMap (java.util.HashMap)6 FluidIdentifier (logisticspipes.utils.FluidIdentifier)6 StandardTank (mods.railcraft.common.fluids.tanks.StandardTank)6 EntityPlayer (net.minecraft.entity.player.EntityPlayer)6 PipeFluidTransportLogistics (logisticspipes.transport.PipeFluidTransportLogistics)5 IBlockState (net.minecraft.block.state.IBlockState)5 EnumFacing (net.minecraft.util.EnumFacing)5