Search in sources :

Example 21 with IFluidTank

use of net.minecraftforge.fluids.IFluidTank in project gregtech6 by GregTech6.

the class TileEntityBase01Root method drain.

public FluidStack drain(MultiTileEntityMultiBlockPart aPart, byte aDirection, int aAmountToDrain, boolean aDoDrain) {
    if (aAmountToDrain <= 0)
        return null;
    IFluidTank tTank = getFluidTankDrainable(aPart, UT.Code.side(aDirection), null);
    if (tTank == null || tTank.getFluid() == null || tTank.getFluidAmount() == 0)
        return null;
    FluidStack rDrained = tTank.drain(aAmountToDrain, aDoDrain);
    if (rDrained != null && aDoDrain)
        updateInventory();
    return rDrained;
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack) IFluidTank(net.minecraftforge.fluids.IFluidTank)

Example 22 with IFluidTank

use of net.minecraftforge.fluids.IFluidTank in project gregtech6 by GregTech6.

the class TileEntityBase01Root method fill.

public int fill(MultiTileEntityMultiBlockPart aPart, byte aDirection, FluidStack aFluid, boolean aDoFill) {
    if (aFluid == null || aFluid.amount <= 0)
        return 0;
    IFluidTank tTank = getFluidTankFillable(aPart, UT.Code.side(aDirection), aFluid);
    if (tTank == null)
        return 0;
    int rFilledAmount = tTank.fill(aFluid, aDoFill);
    if (rFilledAmount > 0 && aDoFill)
        updateInventory();
    return rFilledAmount;
}
Also used : IFluidTank(net.minecraftforge.fluids.IFluidTank)

Example 23 with IFluidTank

use of net.minecraftforge.fluids.IFluidTank in project gregtech6 by GregTech6.

the class TileEntityBase01Root method fill.

public int fill(ForgeDirection aDirection, FluidStack aFluid, boolean aDoFill) {
    if (aFluid == null || aFluid.amount <= 0)
        return 0;
    IFluidTank tTank = getFluidTankFillable(UT.Code.side(aDirection), aFluid);
    if (tTank == null)
        return 0;
    int rFilledAmount = tTank.fill(aFluid, aDoFill);
    if (rFilledAmount > 0 && aDoFill)
        updateInventory();
    return rFilledAmount;
}
Also used : IFluidTank(net.minecraftforge.fluids.IFluidTank)

Example 24 with IFluidTank

use of net.minecraftforge.fluids.IFluidTank in project gregtech6 by GregTech6.

the class Recipe method isRecipeInputEqual.

public int isRecipeInputEqual(int aMaxProcessCount, IFluidTank[] aFluidInputs, ItemStack... aInputs) {
    if (aMaxProcessCount <= 0)
        return 0;
    if (mFluidInputs.length > 0 && (aFluidInputs == null || aFluidInputs.length < 1))
        return 0;
    if (mInputs.length > 0 && (aInputs == null || aInputs.length < 1))
        return 0;
    int rProcessCount = 0;
    while (rProcessCount < aMaxProcessCount) {
        for (FluidStack tFluid : mFluidInputs) if (tFluid != null) {
            boolean temp = T;
            for (IFluidTank tTank : aFluidInputs) {
                FluidStack aFluid = tTank.getFluid();
                if (aFluid != null && aFluid.isFluidEqual(tFluid) && aFluid.amount >= tFluid.amount) {
                    temp = F;
                    break;
                }
            }
            if (temp)
                return rProcessCount;
        }
        if (!checkStacksEqual(F, F, aInputs))
            return rProcessCount;
        for (FluidStack tFluid : mFluidInputs) if (tFluid != null)
            for (IFluidTank tTank : aFluidInputs) {
                FluidStack aFluid = tTank.getFluid();
                if (aFluid != null && aFluid.isFluidEqual(tFluid) && (aFluid.amount >= tFluid.amount)) {
                    tTank.drain(tFluid.amount, T);
                    break;
                }
            }
        checkStacksEqual(T, F, aInputs);
        rProcessCount++;
    }
    return rProcessCount;
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack) IFluidTank(net.minecraftforge.fluids.IFluidTank)

Example 25 with IFluidTank

use of net.minecraftforge.fluids.IFluidTank in project gregtech6 by GregTech6.

the class MultiTileEntityMixingBowl method onTick2.

@Override
public void onTick2(long aTimer, boolean aIsServerSide) {
    if (aIsServerSide) {
        if (SERVER_TIME % 600 == 10 && worldObj.isRaining() && getRainOffset(0, 1, 0)) {
            BiomeGenBase tBiome = getBiome();
            if (tBiome.rainfall > 0 && tBiome.temperature >= 0.2) {
                Block tInFront = getBlockAtSide(SIDE_TOP);
                if (!(tInFront instanceof BlockLiquid) && !(tInFront instanceof IFluidBlock) && !tInFront.isSideSolid(worldObj, xCoord, yCoord + 1, zCoord, FORGE_DIR_OPPOSITES[SIDE_TOP]) && !tInFront.isSideSolid(worldObj, xCoord, yCoord + 1, zCoord, FORGE_DIR[SIDE_TOP])) {
                    FluidStack tWater = FL.Water.make((long) Math.max(1, tBiome.rainfall * 200) * (worldObj.isThundering() ? 2 : 1));
                    if (tWater != null) {
                        IFluidTank tTank = getFluidTankFillable2(SIDE_TOP, tWater);
                        if (tTank != null)
                            tTank.fill(tWater, T);
                    }
                }
            }
        }
        boolean tBreak = F;
        mDisplay = 0;
        for (FluidTankGT tTank : mTanksOutput) if (tTank.has()) {
            mDisplay = (short) (-2 - tTank.getFluid().getFluidID());
            tBreak = T;
            break;
        }
        if (!tBreak) {
            for (FluidTankGT tTank : mTanksInput) if (tTank.has()) {
                mDisplay = (short) (-2 - tTank.getFluid().getFluidID());
                tBreak = T;
                break;
            }
            if (!tBreak) {
                ItemStack tStack;
                for (int i = 0; i < 7; i++) if (ST.valid(tStack = slot(6 - i))) {
                    OreDictItemData tData = OM.data_(tStack);
                    if (tData == null || tData.mMaterial == null) {
                        mDisplay = -1;
                    } else {
                        mDisplay = tData.mMaterial.mMaterial.mID;
                    }
                    tBreak = T;
                    break;
                }
            }
        }
    }
}
Also used : BlockLiquid(net.minecraft.block.BlockLiquid) FluidStack(net.minecraftforge.fluids.FluidStack) FluidTankGT(gregapi.fluid.FluidTankGT) OreDictItemData(gregapi.oredict.OreDictItemData) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) Block(net.minecraft.block.Block) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) BiomeGenBase(net.minecraft.world.biome.BiomeGenBase) ItemStack(net.minecraft.item.ItemStack) IFluidTank(net.minecraftforge.fluids.IFluidTank)

Aggregations

IFluidTank (net.minecraftforge.fluids.IFluidTank)58 FluidStack (net.minecraftforge.fluids.FluidStack)30 IFluidHandler (net.minecraftforge.fluids.capability.IFluidHandler)10 FluidTank (net.minecraftforge.fluids.FluidTank)9 Nullable (javax.annotation.Nullable)6 Block (net.minecraft.block.Block)6 ItemStack (net.minecraft.item.ItemStack)6 TileEntity (net.minecraft.tileentity.TileEntity)5 NBTBase (net.minecraft.nbt.NBTBase)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)4 NBTTagList (net.minecraft.nbt.NBTTagList)4 INBTSerializable (net.minecraftforge.common.util.INBTSerializable)4 Recipe (gregtech.api.recipes.Recipe)3 ArrayList (java.util.ArrayList)3 IItemHandlerModifiable (net.minecraftforge.items.IItemHandlerModifiable)3 FluidTankTileEntity (com.simibubi.create.content.contraptions.fluids.tank.FluidTankTileEntity)2 FluidTankGT (gregapi.fluid.FluidTankGT)2 OreDictItemData (gregapi.oredict.OreDictItemData)2 FuelRecipe (gregtech.api.recipes.recipes.FuelRecipe)2 BlockLiquid (net.minecraft.block.BlockLiquid)2