Search in sources :

Example 1 with IFluidTank

use of net.minecraftforge.fluids.IFluidTank in project ForestryMC by ForestryMC.

the class TankWidget method getToolTip.

@Override
public ToolTip getToolTip(int mouseX, int mouseY) {
    IFluidTank tank = getTank();
    if (!(tank instanceof StandardTank)) {
        return null;
    }
    StandardTank standardTank = (StandardTank) tank;
    return standardTank.getToolTip();
}
Also used : IFluidTank(net.minecraftforge.fluids.IFluidTank) StandardTank(forestry.core.fluids.StandardTank)

Example 2 with IFluidTank

use of net.minecraftforge.fluids.IFluidTank in project Binnie by ForestryMC.

the class MachineUtil method liquidInTank.

public boolean liquidInTank(final int tankIndex, final int amount) {
    IFluidTank tank = this.getTank(tankIndex);
    FluidStack drain = tank.drain(amount, false);
    return drain != null && drain.amount == amount;
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack) IFluidTank(net.minecraftforge.fluids.IFluidTank)

Example 3 with IFluidTank

use of net.minecraftforge.fluids.IFluidTank in project Metalworks by canitzp.

the class TileBase method writeCapabilities.

protected void writeCapabilities(NBTTagCompound nbt, @Nullable EnumFacing side) {
    IItemHandler inventory = this.getInventory(side);
    if (inventory != null && inventory instanceof IItemHandlerModifiable) {
        nbt.setTag("Inventory", CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.writeNBT(inventory, side));
    }
    IFluidHandler tank = getTank(side);
    if (tank != null && tank instanceof IFluidTank) {
        nbt.setTag("FluidTank", CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.writeNBT(tank, side));
    }
    IEnergyStorage energy = getEnergy(side);
    if (energy != null && energy instanceof EnergyStorage) {
        nbt.setTag("Energy", CapabilityEnergy.ENERGY.writeNBT(energy, side));
    }
}
Also used : IItemHandlerModifiable(net.minecraftforge.items.IItemHandlerModifiable) IItemHandler(net.minecraftforge.items.IItemHandler) EnergyStorage(net.minecraftforge.energy.EnergyStorage) IEnergyStorage(net.minecraftforge.energy.IEnergyStorage) IEnergyStorage(net.minecraftforge.energy.IEnergyStorage) IFluidHandler(net.minecraftforge.fluids.capability.IFluidHandler) IFluidTank(net.minecraftforge.fluids.IFluidTank)

Example 4 with IFluidTank

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

the class GuiLogisticsBase method actionPerformed.

@Override
public void actionPerformed(IGuiWidget widget) {
    super.actionPerformed(widget);
    if (widget instanceof WidgetFluidStack) {
        boolean leftClick = Mouse.isButtonDown(0);
        boolean middleClick = Mouse.isButtonDown(2);
        boolean shift = PneumaticCraft.proxy.isSneakingInGui();
        IFluidTank tank = logistics.getTankFilter(widget.getID());
        if (tank.getFluidAmount() > 0) {
            if (middleClick) {
                logistics.setFilter(widget.getID(), (FluidStack) null);
            } else if (leftClick) {
                tank.drain(shift ? tank.getFluidAmount() / 2 : 1000, true);
                if (tank.getFluidAmount() < 1000) {
                    tank.drain(1000, true);
                }
            } else {
                tank.fill(new FluidStack(tank.getFluid().getFluid(), shift ? tank.getFluidAmount() : 1000), true);
            }
            NetworkHandler.sendToServer(new PacketSetLogisticsFluidFilterStack(logistics, tank.getFluid(), widget.getID()));
        } else {
            fluidSearchGui = new GuiLogisticsLiquidFilter(this);
            editingSlot = widget.getID();
            mc.displayGuiScreen(fluidSearchGui);
        }
    }
}
Also used : PacketSetLogisticsFluidFilterStack(pneumaticCraft.common.network.PacketSetLogisticsFluidFilterStack) WidgetFluidStack(pneumaticCraft.client.gui.widget.WidgetFluidStack) FluidStack(net.minecraftforge.fluids.FluidStack) WidgetFluidStack(pneumaticCraft.client.gui.widget.WidgetFluidStack) IFluidTank(net.minecraftforge.fluids.IFluidTank)

Example 5 with IFluidTank

use of net.minecraftforge.fluids.IFluidTank in project GregTech by GregTechCE.

the class MetaTileEntity method pushFluidsIntoNearbyHandlers.

public void pushFluidsIntoNearbyHandlers(EnumFacing... allowedFaces) {
    for (EnumFacing nearbyFacing : allowedFaces) {
        TileEntity tileEntity = getWorld().getTileEntity(getPos().offset(nearbyFacing));
        if (tileEntity == null)
            continue;
        IFluidHandler fluidHandler = tileEntity.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, nearbyFacing.getOpposite());
        if (fluidHandler == null)
            continue;
        for (int tankIndex = 0; tankIndex < exportFluids.getTanks(); tankIndex++) {
            IFluidTank tank = exportFluids.getTankAt(tankIndex);
            FluidStack fluidStack = tank.getFluid();
            if (fluidStack != null && fluidHandler.fill(fluidStack, false) != 0) {
                int filledAmount = fluidHandler.fill(fluidStack, true);
                tank.drain(filledAmount, true);
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) FluidStack(net.minecraftforge.fluids.FluidStack) EnumFacing(net.minecraft.util.EnumFacing) IFluidHandler(net.minecraftforge.fluids.capability.IFluidHandler) IFluidTank(net.minecraftforge.fluids.IFluidTank)

Aggregations

IFluidTank (net.minecraftforge.fluids.IFluidTank)14 FluidStack (net.minecraftforge.fluids.FluidStack)7 IFluidHandler (net.minecraftforge.fluids.capability.IFluidHandler)3 EnergyStorage (net.minecraftforge.energy.EnergyStorage)2 IEnergyStorage (net.minecraftforge.energy.IEnergyStorage)2 IItemHandler (net.minecraftforge.items.IItemHandler)2 IItemHandlerModifiable (net.minecraftforge.items.IItemHandlerModifiable)2 IToolPipette (forestry.api.core.IToolPipette)1 StandardTank (forestry.core.fluids.StandardTank)1 ToolTip (forestry.core.gui.tooltips.ToolTip)1 TankWidget (forestry.core.gui.widgets.TankWidget)1 Widget (forestry.core.gui.widgets.Widget)1 Nullable (javax.annotation.Nullable)1 WidgetFluidStack (me.desht.pneumaticcraft.client.gui.widget.WidgetFluidStack)1 PacketSetLogisticsFluidFilterStack (me.desht.pneumaticcraft.common.network.PacketSetLogisticsFluidFilterStack)1 Minecraft (net.minecraft.client.Minecraft)1 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)1 TextureManager (net.minecraft.client.renderer.texture.TextureManager)1 TextureMap (net.minecraft.client.renderer.texture.TextureMap)1 Item (net.minecraft.item.Item)1