Search in sources :

Example 6 with SmartTank

use of com.enderio.core.common.fluid.SmartTank in project EnderIO by SleepyTrousers.

the class ReservoirTankWrapper method getInputTank.

@Override
public FluidTank getInputTank(FluidStack forFluidType) {
    FluidTank parentTank = parents.get(0).getInputTank(forFluidType);
    if (parentTank == null) {
        return null;
    }
    int free = parentTank.getCapacity() - parentTank.getFluidAmount();
    for (NNIterator<EnumFacing> itr = NNList.FACING.fastIterator(); itr.hasNext(); ) {
        TileEntity neighbor = world.getTileEntity(pos.offset(itr.next()));
        if (neighbor instanceof ITankAccess) {
            FluidTank tank2 = ((ITankAccess) neighbor).getInputTank(forFluidType);
            if (tank2 != null) {
                free += tank2.getCapacity() - tank2.getFluidAmount();
                parents.add(((ITankAccess) neighbor));
            }
        }
    }
    if (free < Fluid.BUCKET_VOLUME) {
        free = Fluid.BUCKET_VOLUME;
    }
    return tank = new SmartTank(parentTank.getFluid(), free);
}
Also used : FluidTank(net.minecraftforge.fluids.FluidTank) TileEntity(net.minecraft.tileentity.TileEntity) ITankAccess(com.enderio.core.api.common.util.ITankAccess) EnumFacing(net.minecraft.util.EnumFacing) SmartTank(com.enderio.core.common.fluid.SmartTank)

Example 7 with SmartTank

use of com.enderio.core.common.fluid.SmartTank in project EnderIO by SleepyTrousers.

the class KillerJoeRenderMapper method renderFuel.

private List<BakedQuad> renderFuel(ItemStack stack) {
    if (stack.hasTagCompound()) {
        SmartTank tank = ItemTankHelper.getTank(stack);
        HalfBakedList buffer = TankRenderHelper.mkTank(tank, 2.51, 1, 14, false);
        if (buffer != null) {
            List<BakedQuad> quads = new ArrayList<BakedQuad>();
            buffer.bake(quads);
            return quads;
        }
    }
    return null;
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) ArrayList(java.util.ArrayList) SmartTank(com.enderio.core.common.fluid.SmartTank) HalfBakedList(crazypants.enderio.base.render.util.HalfBakedQuad.HalfBakedList)

Example 8 with SmartTank

use of com.enderio.core.common.fluid.SmartTank in project EnderIO by SleepyTrousers.

the class GuiCombustionGenerator method drawGuiContainerBackgroundLayer.

@Override
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    bindGuiTexture();
    int sx = (width - xSize) / 2;
    int sy = (height - ySize) / 2;
    drawTexturedModalRect(sx, sy, 0, 0, xSize, ySize);
    TileCombustionGenerator gen = getTileEntity();
    CombustionMath math = gen.getMath();
    FontRenderer fr = getFontRenderer();
    int output = 0;
    if (gen.isActive()) {
        output = math.getEnergyPerTick();
    }
    String txt = Lang.GUI_COMBGEN_OUTPUT.get(LangPower.RFt(output));
    int sw = fr.getStringWidth(txt);
    fr.drawStringWithShadow(txt, guiLeft + xSize / 2 - sw / 2, guiTop + fr.FONT_HEIGHT / 2 + 3, ColorUtil.getRGB(Color.WHITE));
    int x = guiLeft + 48;
    int y = guiTop + 21;
    final SmartTank coolantTank = gen.getCoolantTank();
    if (!coolantTank.isEmpty()) {
        x = guiLeft + 114;
        // right tank
        final int fluidAmount = coolantTank.getFluidAmount();
        final FluidStack fluid = coolantTank.getFluid();
        if (fluidAmount > CENTER) {
            RenderUtil.renderGuiTank(fluid, coolantTank.getCapacity() - CENTER, fluidAmount - CENTER, x, y, zLevel, 15, 47);
        }
        if (gen.isActive()) {
            txt = LangFluid.tMB(math.getTicksPerCoolant());
            sw = fr.getStringWidth(txt);
            fr.drawStringWithShadow(txt, x - sw / 2 + 7, y + fr.FONT_HEIGHT / 2 + 47, ColorUtil.getRGB(Color.WHITE));
        }
        // center coolant chamber
        RenderUtil.renderGuiTank(fluid, CENTER, Math.min(fluidAmount, CENTER), guiLeft + 72, guiTop + 28, zLevel, 33, 33);
        // draw some gui over the top again to make the center shape
        bindGuiTexture();
        drawTexturedModalRect(guiLeft + 72, guiTop + 28, 0, 223, 33, 33);
    }
    final SmartTank fuelTank = gen.getFuelTank();
    if (!fuelTank.isEmpty()) {
        // left tank
        x = guiLeft + 48;
        final int fluidAmount = fuelTank.getFluidAmount();
        final FluidStack fluid = fuelTank.getFluid();
        if (fluidAmount > CENTER) {
            RenderUtil.renderGuiTank(fluid, fuelTank.getCapacity() - CENTER, fluidAmount - CENTER, x, y, zLevel, 15, 47);
        }
        if (gen.isActive()) {
            txt = LangFluid.tMB(math.getTicksPerFuel());
            sw = fr.getStringWidth(txt);
            fr.drawStringWithShadow(txt, x - sw / 2 + 7, y + fr.FONT_HEIGHT / 2 + 47, ColorUtil.getRGB(Color.WHITE));
        }
        // center tank
        RenderUtil.renderGuiTank(fluid, CENTER, Math.min(fluidAmount, CENTER), guiLeft + 81, guiTop + 38, zLevel, 14, 14);
    }
    bindGuiTexture();
    super.drawGuiContainerBackgroundLayer(par1, par2, par3);
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack) FontRenderer(net.minecraft.client.gui.FontRenderer) SmartTank(com.enderio.core.common.fluid.SmartTank)

Example 9 with SmartTank

use of com.enderio.core.common.fluid.SmartTank in project EnderIO by SleepyTrousers.

the class TOPCompatibility method mkTankLines.

private void mkTankLines(ProbeMode mode, EioBox eiobox, TOPData data) {
    if (data.tankData != null && !data.tankData.isEmpty()) {
        if (mode != ProbeMode.NORMAL || TopConfig.showTanksByDefault.get()) {
            for (ITankData tank : data.tankData) {
                SmartTank smartTank = new SmartTank(1000);
                String content1;
                String content2;
                final FluidStack fluid = tank.getContent();
                if (fluid != null) {
                    FluidStack fluid2 = fluid.copy();
                    fluid2.amount = fluid.amount * 1000 / tank.getCapacity();
                    smartTank.setFluid(fluid2);
                    content1 = NullHelper.first(fluid.getLocalizedName(), "(???)");
                    // TODO lang-format those numbers
                    content2 = loc("top.tank.content", "" + fluid.amount, "" + tank.getCapacity());
                } else {
                    content1 = loc("top.tank.content.empty");
                    // TODO lang-format those numbers
                    content2 = loc("top.tank.content", "0", "" + tank.getCapacity());
                }
                switch(tank.getTankType()) {
                    case INPUT:
                        content1 = loc("top.tank.header.input", content1);
                        break;
                    case OUTPUT:
                        content1 = loc("top.tank.header.output", content1);
                        break;
                    case STORAGE:
                        content1 = loc("top.tank.header.storage", content1);
                        break;
                }
                // sic!
                ItemStack stack = new ItemStack(ModObject.blockFusedQuartz.getBlockNN());
                ItemTankHelper.setTank(stack, smartTank);
                NbtValue.FAKE.setBoolean(stack, true);
                eiobox.get().horizontal(eiobox.center()).item(stack).vertical(eiobox.getProbeinfo().defaultLayoutStyle().spacing(-1)).text(content1).text(content2);
            }
        } else {
            eiobox.addMore();
        }
    }
}
Also used : ITankData(com.enderio.core.api.common.util.ITankAccess.ITankData) FluidStack(net.minecraftforge.fluids.FluidStack) SmartTank(com.enderio.core.common.fluid.SmartTank) ItemStack(net.minecraft.item.ItemStack)

Example 10 with SmartTank

use of com.enderio.core.common.fluid.SmartTank in project EnderIO by SleepyTrousers.

the class TankItemFluidCapability method drain.

@Override
@Nullable
public FluidStack drain(int maxDrain, boolean doDrain) {
    if (container.getCount() != 1) {
        return null;
    }
    SmartTank tank = EnumTankType.loadTank(container);
    FluidStack ret = tank.drain(maxDrain, doDrain);
    EnumTankType.saveTank(container, tank);
    return ret;
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack) SmartTank(com.enderio.core.common.fluid.SmartTank) Nullable(javax.annotation.Nullable)

Aggregations

SmartTank (com.enderio.core.common.fluid.SmartTank)10 FluidStack (net.minecraftforge.fluids.FluidStack)4 HalfBakedList (crazypants.enderio.base.render.util.HalfBakedQuad.HalfBakedList)3 ArrayList (java.util.ArrayList)3 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)3 ItemQuadCollector (crazypants.enderio.base.render.util.ItemQuadCollector)2 Nullable (javax.annotation.Nullable)2 FontRenderer (net.minecraft.client.gui.FontRenderer)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 ITankAccess (com.enderio.core.api.common.util.ITankAccess)1 ITankData (com.enderio.core.api.common.util.ITankAccess.ITankData)1 EnderWidget (com.enderio.core.client.render.EnderWidget)1 ItemStack (net.minecraft.item.ItemStack)1 TileEntity (net.minecraft.tileentity.TileEntity)1 EnumFacing (net.minecraft.util.EnumFacing)1 FluidTank (net.minecraftforge.fluids.FluidTank)1