Search in sources :

Example 26 with FluidTank

use of net.minecraftforge.fluids.capability.templates.FluidTank in project Electrodynamics by aurilisdev.

the class TileElectrolyticSeparator method tickServer.

public void tickServer(ComponentTickable tickable) {
    // ensures only one fluid per output
    AbstractFluidHandler<?> handler = getComponent(ComponentType.FluidHandler);
    FluidTank oxygen = handler.getOutputTanks()[0];
    FluidTank hydrogen = handler.getOutputTanks()[1];
    FluidUtilities.outputToPipe(this, new FluidTank[] { oxygen }, OXYGEN_DIRECTION);
    FluidUtilities.outputToPipe(this, new FluidTank[] { hydrogen }, HYDROGEN_DIRECTION);
}
Also used : FluidTank(net.minecraftforge.fluids.capability.templates.FluidTank)

Example 27 with FluidTank

use of net.minecraftforge.fluids.capability.templates.FluidTank in project Beyond-Earth by MrScautHD.

the class FluidMultiTank method drain.

@Override
public FluidStack drain(int maxDrain, FluidAction action) {
    FluidStack drained = null;
    for (FluidTank tank : this.getTankList()) {
        if (drained == null) {
            FluidStack amount = tank.drain(maxDrain, action);
            if (!amount.isEmpty()) {
                drained = amount;
                maxDrain -= amount.getAmount();
            }
        } else {
            FluidStack test = drained.copy();
            test.setAmount(maxDrain);
            int amount = tank.drain(test, action).getAmount();
            drained.grow(amount);
            maxDrain -= amount;
        }
    }
    return drained;
}
Also used : FluidTank(net.minecraftforge.fluids.capability.templates.FluidTank) FluidStack(net.minecraftforge.fluids.FluidStack)

Example 28 with FluidTank

use of net.minecraftforge.fluids.capability.templates.FluidTank in project Beyond-Earth by MrScautHD.

the class FluidMultiTank method fill.

@Override
public int fill(FluidStack resource, FluidAction action) {
    resource = resource.copy();
    FluidStack filled = resource.copy();
    filled.setAmount(0);
    for (FluidTank tank : this.getTankList()) {
        int amount = tank.fill(resource, action);
        filled.grow(amount);
        resource.shrink(amount);
    }
    return filled.getAmount();
}
Also used : FluidTank(net.minecraftforge.fluids.capability.templates.FluidTank) FluidStack(net.minecraftforge.fluids.FluidStack)

Example 29 with FluidTank

use of net.minecraftforge.fluids.capability.templates.FluidTank in project TinkersConstruct by SlimeKnights.

the class AdvancementsProvider method getTankWith.

/**
 * Gets a tank filled with the given fluid
 */
private static FluidTank getTankWith(Fluid fluid, int capacity) {
    FluidTank tank = new FluidTank(capacity);
    tank.fill(new FluidStack(fluid, capacity), FluidAction.EXECUTE);
    return tank;
}
Also used : FluidTank(net.minecraftforge.fluids.capability.templates.FluidTank) FluidStack(net.minecraftforge.fluids.FluidStack)

Example 30 with FluidTank

use of net.minecraftforge.fluids.capability.templates.FluidTank in project TinkersConstruct by SlimeKnights.

the class TankItemFluidHandler method fill.

@Override
public int fill(FluidStack resource, FluidAction action) {
    FluidTank tank = getTank();
    int didFill = tank.fill(resource, action);
    if (didFill > 0 && action.execute()) {
        updateContainer(tank);
    }
    return didFill;
}
Also used : FluidTank(net.minecraftforge.fluids.capability.templates.FluidTank)

Aggregations

FluidTank (net.minecraftforge.fluids.capability.templates.FluidTank)35 FluidStack (net.minecraftforge.fluids.FluidStack)20 IFluidHandler (net.minecraftforge.fluids.capability.IFluidHandler)8 ItemStack (net.minecraft.world.item.ItemStack)7 BlockPos (net.minecraft.core.BlockPos)6 Direction (net.minecraft.core.Direction)6 ComponentInventory (electrodynamics.prefab.tile.components.type.ComponentInventory)5 CompoundTag (net.minecraft.nbt.CompoundTag)5 ArrayList (java.util.ArrayList)4 BucketItem (net.minecraft.world.item.BucketItem)4 Level (net.minecraft.world.level.Level)4 BlockEntity (net.minecraft.world.level.block.entity.BlockEntity)4 ComponentDirection (electrodynamics.prefab.tile.components.type.ComponentDirection)3 Nonnull (javax.annotation.Nonnull)3 Nullable (javax.annotation.Nullable)3 ItemStack (net.minecraft.item.ItemStack)3 BlockState (net.minecraft.world.level.block.state.BlockState)3 AABB (net.minecraft.world.phys.AABB)3 VertexConsumer (com.mojang.blaze3d.vertex.VertexConsumer)2 Iterate (com.simibubi.create.foundation.utility.Iterate)2