Search in sources :

Example 76 with FluidStack

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

the class AdvancedFluidHandler method getFluidLevel.

public float getFluidLevel() {
    int amount = 0;
    int capacity = 0;
    for (IFluidTankProperties tank : getTankProperties()) {
        FluidStack liquid = tank.getContents();
        amount += liquid == null ? 0 : liquid.amount;
        capacity += tank.getCapacity();
    }
    return capacity == 0 ? 0 : amount / capacity;
}
Also used : IFluidTankProperties(net.minecraftforge.fluids.capability.IFluidTankProperties) FluidStack(net.minecraftforge.fluids.FluidStack)

Example 77 with FluidStack

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

the class StandardTank method refreshTooltip.

protected void refreshTooltip() {
    toolTip.clear();
    int amount = getFluidAmount();
    FluidStack fluidStack = getFluid();
    if (!Fluids.isEmpty(fluidStack)) {
        toolTip.add(getFluidNameToolTip(fluidStack.getFluid()));
    }
    toolTip.add(new ToolTipLine(String.format(Locale.ENGLISH, "%,d / %,d", amount, getCapacity())));
}
Also used : ToolTipLine(mods.railcraft.common.gui.tooltips.ToolTipLine) FluidStack(net.minecraftforge.fluids.FluidStack)

Example 78 with FluidStack

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

the class TileBoiler method update.

@Override
public void update() {
    super.update();
    if (Game.isHost(worldObj)) {
        if (explode) {
            worldObj.createExplosion(null, getX(), getY(), getZ(), 5f + 0.1f * getNumTanks(), true);
            explode = false;
            return;
        }
        TileBoilerFirebox mBlock = (TileBoilerFirebox) getMasterBlock();
        if (mBlock != null) {
            StandardTank tank = mBlock.tankManager.get(TANK_STEAM);
            FluidStack steam = tank.getFluid();
            if (steam != null && (!mBlock.boiler.isBoiling() || steam.amount >= tank.getCapacity() / 2))
                mBlock.tankManager.push(tileCache, getOutputFilter(), EnumFacing.VALUES, TANK_STEAM, TRANSFER_RATE);
        }
    }
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack) StandardTank(mods.railcraft.common.fluids.tanks.StandardTank)

Example 79 with FluidStack

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

the class FluidGaugeWidget method draw.

//TODO: test render
@Override
public void draw(GuiContainerRailcraft gui, int guiX, int guiY, int mouseX, int mouseY) {
    if (tank == null)
        return;
    FluidStack fluidStack = tank.getFluid();
    if (fluidStack == null || fluidStack.amount <= 0)
        return;
    TextureAtlasSprite fluidIcon = FluidRenderer.getFluidTexture(fluidStack, FluidRenderer.FlowState.STILL);
    if (fluidIcon == null)
        return;
    float scale = Math.min(fluidStack.amount, tank.getCapacity()) / (float) tank.getCapacity();
    gui.bindTexture(FluidRenderer.getFluidSheet(fluidStack));
    FluidRenderer.setColorForFluid(fluidStack);
    for (int col = 0; col < w / 16; col++) {
        for (int row = 0; row <= h / 16; row++) {
            gui.drawTexturedModalRect(guiX + x + col * 16, guiY + y + row * 16 - 1, fluidIcon, 16, 16);
        }
    }
    OpenGL.glColor4f(1, 1, 1, 1);
    gui.bindTexture(gui.texture);
    gui.drawTexturedModalRect(guiX + x, guiY + y - 1, x, y - 1, w, h - (int) Math.floor(h * scale) + 1);
    gui.drawTexturedModalRect(guiX + x, guiY + y, u, v, w, h);
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite)

Example 80 with FluidStack

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

the class FluidGaugeWidget method writeServerSyncData.

@Override
public void writeServerSyncData(IContainerListener listener, RailcraftOutputStream data) throws IOException {
    super.writeServerSyncData(listener, data);
    FluidStack fluidStack = tank.getFluid();
    //        Game.log(Level.INFO, "fluid write {0}", tank.getFluidAmount());
    lastSyncedFluidStack = fluidStack == null ? null : fluidStack.copy();
    data.writeFluidStack(fluidStack);
}
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