Search in sources :

Example 66 with FluidStack

use of net.minecraftforge.fluids.FluidStack in project ImmersiveEngineering by BluSunrize.

the class ItemChemthrower method onPlayerStoppedUsing.

@Override
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityLivingBase player, int timeLeft) {
    FluidStack fs = this.getFluid(stack);
    if (fs != null) {
        int duration = getMaxItemUseDuration(stack) - timeLeft;
        fs.amount -= IEConfig.Tools.chemthrower_consumption * duration;
        if (fs.amount <= 0)
            ItemNBTHelper.remove(stack, "Fluid");
        else
            ItemNBTHelper.setFluidStack(stack, "Fluid", fs);
    }
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack)

Example 67 with FluidStack

use of net.minecraftforge.fluids.FluidStack in project ImmersiveEngineering by BluSunrize.

the class ItemDrill method finishUpgradeRecalculation.

@Override
public void finishUpgradeRecalculation(ItemStack stack) {
    FluidStack fs = getFluid(stack);
    if (fs != null && fs.amount > getCapacity(stack, 2000)) {
        fs.amount = getCapacity(stack, 2000);
        ItemNBTHelper.setFluidStack(stack, "Fluid", fs);
    }
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack)

Example 68 with FluidStack

use of net.minecraftforge.fluids.FluidStack in project ImmersiveEngineering by BluSunrize.

the class ItemChemthrower method onUsingTick.

@Override
public void onUsingTick(ItemStack stack, EntityLivingBase player, int count) {
    FluidStack fs = this.getFluid(stack);
    if (fs != null && fs.getFluid() != null) {
        int duration = getMaxItemUseDuration(stack) - count;
        int consumed = IEConfig.Tools.chemthrower_consumption;
        if (consumed * duration <= fs.amount) {
            Vec3d v = player.getLookVec();
            int split = 8;
            boolean isGas = fs.getFluid().isGaseous() || ChemthrowerHandler.isGas(fs.getFluid());
            float scatter = isGas ? .15f : .05f;
            float range = isGas ? .5f : 1f;
            if (getUpgrades(stack).getBoolean("focus")) {
                range += .25f;
                scatter -= .025f;
            }
            boolean ignite = ChemthrowerHandler.isFlammable(fs.getFluid()) && ItemNBTHelper.getBoolean(stack, "ignite");
            for (int i = 0; i < split; i++) {
                Vec3d vecDir = v.addVector(player.getRNG().nextGaussian() * scatter, player.getRNG().nextGaussian() * scatter, player.getRNG().nextGaussian() * scatter);
                EntityChemthrowerShot chem = new EntityChemthrowerShot(player.worldObj, player, vecDir.xCoord * 0.25, vecDir.yCoord * 0.25, vecDir.zCoord * 0.25, fs);
                chem.motionX = vecDir.xCoord * range;
                chem.motionY = vecDir.yCoord * range;
                chem.motionZ = vecDir.zCoord * range;
                if (ignite)
                    chem.setFire(10);
                if (!player.worldObj.isRemote)
                    player.worldObj.spawnEntityInWorld(chem);
            }
            if (count % 4 == 0) {
                if (ignite)
                    player.playSound(IESounds.sprayFire, .5f, 1.5f);
                else
                    player.playSound(IESounds.spray, .5f, .75f);
            }
        } else
            player.stopActiveHand();
    } else
        player.stopActiveHand();
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack) EntityChemthrowerShot(blusunrize.immersiveengineering.common.entities.EntityChemthrowerShot) Vec3d(net.minecraft.util.math.Vec3d)

Example 69 with FluidStack

use of net.minecraftforge.fluids.FluidStack in project Railcraft by Railcraft.

the class TileTankIronValve method update.

@Override
public void update() {
    super.update();
    if (Game.isClient(worldObj))
        return;
    decrementFilling();
    if (isMaster) {
        TileEntity tileBelow = tileCache.getTileOnSide(EnumFacing.DOWN);
        TileTankIronValve valveBelow = null;
        if (tileBelow instanceof TileTankIronValve) {
            valveBelow = (TileTankIronValve) tileBelow;
            if (valveBelow.isStructureValid() && valveBelow.getPatternMarker() == 'T') {
                //noinspection ConstantConditions
                StandardTank tankBelow = valveBelow.getTankManager().get(0);
                assert tankBelow != null;
                FluidStack liquid = tankBelow.getFluid();
                if (liquid != null && liquid.amount >= tankBelow.getCapacity() - FluidTools.BUCKET_VOLUME) {
                    valveBelow = null;
                    FluidStack fillStack = liquid.copy();
                    fillStack.amount = FluidTools.BUCKET_VOLUME - (tankBelow.getCapacity() - liquid.amount);
                    if (fillStack.amount > 0) {
                        int used = tank.fill(fillStack, false);
                        if (used > 0) {
                            fillStack = tankBelow.drain(used, true);
                            tank.fill(fillStack, true);
                        }
                    }
                }
            } else
                valveBelow = null;
        }
        if (valveBelow != null) {
            FluidStack available = tankManager.drain(0, FluidTools.BUCKET_VOLUME, false);
            if (available != null && available.amount > 0) {
                int used = valveBelow.fill(available, true);
                tankManager.drain(0, used, true);
            }
        }
    }
    if (getPatternPosition().getY() - getPattern().getMasterOffset().getY() == 0) {
        TankManager tMan = getTankManager();
        if (tMan != null)
            tMan.push(tileCache, Predicates.notInstanceOf(TileTankBase.class), FLUID_OUTPUTS, 0, FLOW_RATE);
    }
    TileMultiBlock masterBlock = getMasterBlock();
    if (masterBlock instanceof TileTankBase) {
        TileTankBase masterTileTankBase = (TileTankBase) masterBlock;
        int compValue = masterTileTankBase.getComparatorValue();
        if (previousComparatorValue != compValue) {
            previousComparatorValue = compValue;
            getWorld().notifyNeighborsOfStateChange(getPos(), null);
        }
    }
    if (previousStructureValidity != isStructureValid())
        getWorld().notifyNeighborsOfStateChange(getPos(), null);
    previousStructureValidity = isStructureValid();
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileMultiBlock(mods.railcraft.common.blocks.machine.TileMultiBlock) FluidStack(net.minecraftforge.fluids.FluidStack) TankManager(mods.railcraft.common.fluids.TankManager) StandardTank(mods.railcraft.common.fluids.tanks.StandardTank)

Example 70 with FluidStack

use of net.minecraftforge.fluids.FluidStack in project Railcraft by Railcraft.

the class TileFluidLoader method processCart.

@Override
protected void processCart(EntityMinecart cart) {
    if (cart instanceof EntityLocomotiveSteam) {
        EntityLocomotiveSteam loco = (EntityLocomotiveSteam) cart;
        if (!loco.isSafeToFill()) {
            retractPipe();
            return;
        }
    }
    AdvancedFluidHandler tankCart = getFluidHandler(cart, EnumFacing.UP);
    if (tankCart == null)
        return;
    boolean cartNeedsFilling = cartNeedsFilling(tankCart);
    if (cartNeedsFilling && needsPipe)
        extendPipe();
    else
        retractPipe();
    setProcessing(false);
    if (cartNeedsFilling && (!needsPipe || pipeIsExtended())) {
        FluidStack moved = FluidUtil.tryFluidTransfer(tankCart, tank, RailcraftConfig.getTankCartFillRate(), true);
        setProcessing(Fluids.isNotEmpty(moved));
    }
    if (isProcessing())
        setPowered(false);
    if (cart instanceof IFluidCart)
        ((IFluidCart) cart).setFilling(isProcessing());
    if (tankCart.isTankFull(tank.getFluidType()))
        setResetTimer(RESET_WAIT);
}
Also used : AdvancedFluidHandler(mods.railcraft.common.fluids.AdvancedFluidHandler) FluidStack(net.minecraftforge.fluids.FluidStack) EntityLocomotiveSteam(mods.railcraft.common.carts.EntityLocomotiveSteam) IFluidCart(mods.railcraft.api.carts.IFluidCart)

Aggregations

FluidStack (net.minecraftforge.fluids.FluidStack)188 ItemStack (net.minecraft.item.ItemStack)63 TileEntity (net.minecraft.tileentity.TileEntity)30 Fluid (net.minecraftforge.fluids.Fluid)28 IFluidHandler (net.minecraftforge.fluids.IFluidHandler)25 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)19 ArrayList (java.util.ArrayList)18 IFluidHandler (net.minecraftforge.fluids.capability.IFluidHandler)16 Block (net.minecraft.block.Block)12 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)12 FluidTankInfo (net.minecraftforge.fluids.FluidTankInfo)10 Item (net.minecraft.item.Item)9 BlockPos (net.minecraft.util.math.BlockPos)9 HashMap (java.util.HashMap)6 FluidIdentifier (logisticspipes.utils.FluidIdentifier)6 StandardTank (mods.railcraft.common.fluids.tanks.StandardTank)6 EntityPlayer (net.minecraft.entity.player.EntityPlayer)6 PipeFluidTransportLogistics (logisticspipes.transport.PipeFluidTransportLogistics)5 IBlockState (net.minecraft.block.state.IBlockState)5 EnumFacing (net.minecraft.util.EnumFacing)5