Search in sources :

Example 1 with FluidTankGT

use of gregapi.fluid.FluidTankGT in project gregtech6 by GregTech6.

the class MultiTileEntityJuicer method readFromNBT2.

@Override
public void readFromNBT2(NBTTagCompound aNBT) {
    super.readFromNBT2(aNBT);
    if (aNBT.hasKey(NBT_RECIPEMAP))
        mRecipes = RecipeMap.RECIPE_MAPS.get(aNBT.getString(NBT_RECIPEMAP));
    mTanks = new FluidTankGT[mRecipes.mOutputFluidCount];
    for (int i = 0; i < mTanks.length; i++) mTanks[i] = new FluidTankGT(1000000).readFromNBT(aNBT, NBT_TANK + "." + i);
}
Also used : FluidTankGT(gregapi.fluid.FluidTankGT)

Example 2 with FluidTankGT

use of gregapi.fluid.FluidTankGT 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)

Example 3 with FluidTankGT

use of gregapi.fluid.FluidTankGT in project gregtech6 by GregTech6.

the class MultiTileEntityMixingBowl method readFromNBT2.

@Override
public void readFromNBT2(NBTTagCompound aNBT) {
    super.readFromNBT2(aNBT);
    if (aNBT.hasKey(NBT_RECIPEMAP))
        mRecipes = RecipeMap.RECIPE_MAPS.get(aNBT.getString(NBT_RECIPEMAP));
    int tCapacity = 1000;
    if (aNBT.hasKey(NBT_TANK_CAPACITY))
        tCapacity = UT.Code.bindInt(aNBT.getLong(NBT_TANK_CAPACITY));
    mTanksInput = new FluidTankGT[mRecipes.mInputFluidCount];
    for (int i = 0; i < mTanksInput.length; i++) mTanksInput[i] = new FluidTankGT(tCapacity).readFromNBT(aNBT, NBT_TANK + ".in." + i);
    mTanksOutput = new FluidTankGT[mRecipes.mOutputFluidCount];
    for (int i = 0; i < mTanksOutput.length; i++) mTanksOutput[i] = new FluidTankGT(tCapacity).readFromNBT(aNBT, NBT_TANK + ".out." + i);
}
Also used : FluidTankGT(gregapi.fluid.FluidTankGT)

Example 4 with FluidTankGT

use of gregapi.fluid.FluidTankGT in project gregtech6 by GregTech6.

the class MultiTileEntityMixingBowl method onBlockActivated3.

@Override
public boolean onBlockActivated3(EntityPlayer aPlayer, byte aSide, float aHitX, float aHitY, float aHitZ) {
    if (isServerSide()) {
        ItemStack aStack = aPlayer.getCurrentEquippedItem();
        if (SIDES_TOP[aSide]) {
            float[] tCoords = UT.Code.getFacingCoordsClicked(aSide, aHitX, aHitY, aHitZ);
            if (tCoords[0] <= PX_P[2] && tCoords[1] <= PX_P[2])
                return T;
            if (!UT.Entities.isPlayer(aPlayer))
                return T;
            if (ToolsGT.contains(TOOL_mixer, aStack))
                return F;
            ItemStack[] tInputItems = ST.array(slot(0), slot(1), slot(2), slot(3), slot(4), slot(5));
            Recipe tRecipe = mRecipes.findRecipe(this, mLastRecipe, F, V[1], NI, mTanksInput, tInputItems);
            if (tRecipe != null) {
                if (tRecipe.mCanBeBuffered)
                    mLastRecipe = tRecipe;
                if (canOutput(tRecipe) && tRecipe.isRecipeInputEqual(T, F, mTanksInput, tInputItems)) {
                    ItemStack[] tOutputItems = tRecipe.getOutputs();
                    FluidStack[] tOutputFluids = tRecipe.getFluidOutputs();
                    for (int i = 0; i < mRecipes.mOutputItemsCount && i < tOutputItems.length; i++) addStackToSlot(i + 6, tOutputItems[i]);
                    for (int i = 0; i < mTanksOutput.length && i < tOutputFluids.length; i++) mTanksOutput[i].fill(tOutputFluids[i], T);
                    aPlayer.addExhaustion(tRecipe.getAbsoluteTotalPower() / 250.0F);
                    removeAllDroppableNullStacks();
                    return T;
                }
            }
        }
        if (UT.Inventories.addStackToPlayerInventory(aPlayer, slot(6), T)) {
            slotKill(6);
            return T;
        }
        ItemStack tStack = ST.container(ST.amount(1, aStack), T);
        FluidStack tFluid = FL.getFluid(ST.amount(1, aStack), T);
        if (aStack != null && tFluid != null && FL.fillAll_(this, SIDE_ANY, tFluid, T)) {
            aStack.stackSize--;
            UT.Inventories.addStackToPlayerInventoryOrDrop(aPlayer, tStack, T);
            updateInventory();
            updateAdjacentInventories();
            return T;
        }
        if (SIDES_TOP[aSide] && aHitX > PX_P[2] && aHitX < PX_N[2] && aHitZ > PX_P[2] && aHitZ < PX_N[2]) {
            if (aStack != null)
                for (byte i = 0; i < 6; i++) {
                    if (ST.move(aPlayer.inventory, this, aPlayer.inventory.currentItem, i) > 0)
                        return T;
                }
            if (aStack != null)
                for (FluidTankGT tTank : mTanksOutput) if ((tStack = FL.fill(tTank, ST.amount(1, aStack), T, T, T, T)) != null) {
                    aStack.stackSize--;
                    UT.Inventories.addStackToPlayerInventoryOrDrop(aPlayer, tStack, T);
                    return T;
                }
            if (aStack != null)
                for (FluidTankGT tTank : mTanksInput) if ((tStack = FL.fill(tTank, ST.amount(1, aStack), T, T, T, T)) != null) {
                    aStack.stackSize--;
                    UT.Inventories.addStackToPlayerInventoryOrDrop(aPlayer, tStack, T);
                    return T;
                }
        } else {
            if (aStack != null)
                for (FluidTankGT tTank : mTanksOutput) if ((tStack = FL.fill(tTank, ST.amount(1, aStack), T, T, T, T)) != null) {
                    aStack.stackSize--;
                    UT.Inventories.addStackToPlayerInventoryOrDrop(aPlayer, tStack, T);
                    return T;
                }
            if (aStack != null)
                for (FluidTankGT tTank : mTanksInput) if ((tStack = FL.fill(tTank, ST.amount(1, aStack), T, T, T, T)) != null) {
                    aStack.stackSize--;
                    UT.Inventories.addStackToPlayerInventoryOrDrop(aPlayer, tStack, T);
                    return T;
                }
            if (aStack != null)
                for (byte i = 0; i < 6; i++) {
                    if (ST.move(aPlayer.inventory, this, aPlayer.inventory.currentItem, i) > 0)
                        return T;
                }
        }
        if (!slotHas(6))
            for (int i = 0; i < 6; i++) if (UT.Inventories.addStackToPlayerInventory(aPlayer, slot(i), T)) {
                slotKill(i);
                return T;
            }
    } else {
        if (SIDES_TOP[aSide]) {
            float[] tCoords = UT.Code.getFacingCoordsClicked(aSide, aHitX, aHitY, aHitZ);
            if (tCoords[0] <= PX_P[2] && tCoords[1] <= PX_P[2]) {
                mRecipes.openNEI();
                return T;
            }
            if (mDisplay != 0) {
                if (mDisplay < -1) {
                    UT.Sounds.play(SFX.MC_LIQUID_WATER, 5, 1.0F, 1.0F, getCoords());
                } else {
                    UT.Sounds.play(SFX.MC_DIG_SAND, 5, 1.0F, 1.0F, getCoords());
                }
            }
        }
    }
    return T;
}
Also used : Recipe(gregapi.recipes.Recipe) FluidStack(net.minecraftforge.fluids.FluidStack) FluidTankGT(gregapi.fluid.FluidTankGT) ItemStack(net.minecraft.item.ItemStack)

Example 5 with FluidTankGT

use of gregapi.fluid.FluidTankGT in project gregtech6 by GregTech6.

the class MultiTileEntityBathingPot method onToolClick2.

@Override
public long onToolClick2(String aTool, long aRemainingDurability, long aQuality, Entity aPlayer, List<String> aChatReturn, IInventory aPlayerInventory, boolean aSneaking, ItemStack aStack, byte aSide, float aHitX, float aHitY, float aHitZ) {
    long rReturn = super.onToolClick2(aTool, aRemainingDurability, aQuality, aPlayer, aChatReturn, aPlayerInventory, aSneaking, aStack, aSide, aHitX, aHitY, aHitZ);
    if (rReturn > 0 || isClientSide())
        return rReturn;
    if (aTool.equals(TOOL_plunger)) {
        updateInventory();
        for (FluidTankGT tTank : mTanksOutput) {
            long rAmount = GarbageGT.trash(tTank, 1000);
            if (rAmount > 0)
                return rAmount;
        }
        for (FluidTankGT tTank : mTanksInput) {
            long rAmount = GarbageGT.trash(tTank, 1000);
            if (rAmount > 0)
                return rAmount;
        }
        updateAdjacentInventories();
    }
    if (aTool.equals(TOOL_magnifyingglass)) {
        if (aChatReturn != null) {
            boolean temp = T;
            for (FluidTankGT tTank : mTanksInput) if (!tTank.isEmpty()) {
                temp = F;
                aChatReturn.add("Input: " + tTank.content());
            }
            for (FluidTankGT tTank : mTanksOutput) if (!tTank.isEmpty()) {
                temp = F;
                aChatReturn.add("Output: " + tTank.content());
            }
            if (temp)
                aChatReturn.add("Contains no Fluids");
        }
        return mTanksInput.length + mTanksOutput.length;
    }
    return 0;
}
Also used : FluidTankGT(gregapi.fluid.FluidTankGT)

Aggregations

FluidTankGT (gregapi.fluid.FluidTankGT)23 FluidStack (net.minecraftforge.fluids.FluidStack)8 ItemStack (net.minecraft.item.ItemStack)7 DelegatorTileEntity (gregapi.tileentity.delegate.DelegatorTileEntity)6 Recipe (gregapi.recipes.Recipe)5 Block (net.minecraft.block.Block)4 ArrayListNoNulls (gregapi.code.ArrayListNoNulls)3 OreDictItemData (gregapi.oredict.OreDictItemData)2 BlockLiquid (net.minecraft.block.BlockLiquid)2 Entity (net.minecraft.entity.Entity)2 TileEntity (net.minecraft.tileentity.TileEntity)2 BiomeGenBase (net.minecraft.world.biome.BiomeGenBase)2 IFluidBlock (net.minecraftforge.fluids.IFluidBlock)2 IFluidHandler (net.minecraftforge.fluids.IFluidHandler)2 IFluidTank (net.minecraftforge.fluids.IFluidTank)2 IPrefixBlock (gregapi.block.IPrefixBlock)1 IMTE_OnEntityCollidedWithBlock (gregapi.block.multitileentity.IMultiTileEntity.IMTE_OnEntityCollidedWithBlock)1 MultiTileEntityBlock (gregapi.block.multitileentity.MultiTileEntityBlock)1 HashSetNoNulls (gregapi.code.HashSetNoNulls)1 ITileEntityAdjacentInventoryUpdatable (gregapi.tileentity.ITileEntityAdjacentInventoryUpdatable)1