Example usage for net.minecraftforge.fluids FluidStack FluidStack

List of usage examples for net.minecraftforge.fluids FluidStack FluidStack

Introduction

In this page you can find the example usage for net.minecraftforge.fluids FluidStack FluidStack.

Prototype

public FluidStack(FluidStack stack, int amount) 

Source Link

Usage

From source file:abo.pipes.fluids.PipeFluidsPump.java

License:Open Source License

@Override
public void updateEntity() {
    super.updateEntity();
    if (container.worldObj.getBlockId(container.xCoord, container.yCoord - 1,
            container.zCoord) == liquid.blockID) {
        transport.fill(ForgeDirection.DOWN,
                new FluidStack(BlockUtil.getFluid(liquid.blockID), FluidContainerRegistry.BUCKET_VOLUME / 10),
                true);//w ww.jav  a 2  s .  com
    }
}

From source file:advancedbrewing.gui.ContainerMachine.java

License:Minecraft Mod Public

@Override
@SideOnly(Side.CLIENT)//from   w  ww.  j  a  v a2  s.c o m
public void updateProgressBar(int id, int value) {
    // set properties
    switch (id) {
    case 0:
        this.tileEntity.getPowerHandler().setEnergy(value / 100);
        return;
    case 1:
        this.tileEntity.setRecentEnergyAverage(value / 100);
        return;
    case 2:
        this.tileEntity.setCurrentInput(value / 100);
        return;
    case 3:
        this.tileEntity.setRedstoneActivated(value == 1 ? true : false);
        return;
    case 4:
        this.tileEntity.setWorkTime(value);
        return;
    }

    FluidTank[] fluidTanks = this.tileEntity.getFluidTanks();

    // set fluid ids
    if (id >= 100 && id < 200) {
        if (fluidTanks[id - 100].getFluid() == null) {
            if (value >= 0) {
                fluidTanks[id - 100].setFluid(new FluidStack(value, 0));
            }
        } else {
            fluidTanks[id - 100].getFluid().fluidID = value;
        }
        return;
    }

    // set fluid amounts
    if (id >= 200 && id < 300) {
        if (fluidTanks[id - 200].getFluid() != null) {
            fluidTanks[id - 200].getFluid().amount = value;
        }
        return;
    }
}

From source file:advancedbrewing.tileentity.TileEntityBrewery.java

License:Minecraft Mod Public

@Override
protected boolean work() {
    if (this.canWork()) {
        // get ingredients
        List<ItemStack> validIngredients = new ArrayList<ItemStack>();
        for (int i = 2; i < (this.type > 0 ? 5 : 3); i++) {
            ItemStack itemStack = this.itemStacks[i];
            if (itemStack != null && this.hasItemInBuffer(itemStack.itemID)
                    && Item.itemsList[itemStack.itemID].isPotionIngredient()) {
                validIngredients.add(itemStack);
                // remove item from buffer
                this.removeItemFromBuffer(itemStack.itemID, 1);
            }//from w w  w  .  j  a va 2s . com
        }

        // do brewing
        Fluid fluidResult = this.fluidTanks[0].getFluid().getFluid();
        for (ItemStack validIngredient : validIngredients) {
            int potionResult = Utils.getPotionIDResult(fluidResult, validIngredient, false);
            PotionDefinition potionDefinitionResult = Utils.getPotionDefinitionByPotionID(potionResult);
            fluidResult = Utils.getFluidByPotionDefintion(potionDefinitionResult);
        }

        int fluidAmount = this.type > 0 ? TileEntityBrewery.RESULT_FLUIDAMOUNT_MULTI
                : TileEntityBrewery.RESULT_FLUIDAMOUNT;
        this.fluidTanks[0].drain(fluidAmount, true);
        this.fluidTanks[1].fill(new FluidStack(fluidResult, fluidAmount), true);

        return true;
    }

    return false;
}

From source file:appeng.tile.storage.TileChest.java

License:Open Source License

@Override
public boolean canFill(ForgeDirection from, Fluid fluid) {
    try {/*from  ww w. j  av  a 2s  . co  m*/
        IMEInventoryHandler h = this.getHandler(StorageChannel.FLUIDS);
        return h.canAccept(AEFluidStack.create(new FluidStack(fluid, 1)));
    } catch (ChestNoHandler ignored) {
    }
    return false;
}

From source file:appeng.util.item.AEFluidStack.java

License:Open Source License

@Override
public FluidStack getFluidStack() {
    FluidStack is = new FluidStack(this.fluid, (int) Math.min(Integer.MAX_VALUE, this.stackSize));
    if (this.tagCompound != null) {
        is.tag = this.tagCompound.getNBTTagCompoundCopy();
    }//w ww. ja v a 2  s.  co  m

    return is;
}

From source file:blusunrize.immersiveengineering.api.crafting.IngredientStack.java

public static IngredientStack readFromNBT(NBTTagCompound nbt) {
    if (nbt.hasKey("nbtType"))
        switch (nbt.getInteger("nbtType")) {
        case 0://from  www  .j a va 2  s .  c om
            ItemStack stack = new ItemStack(nbt.getCompoundTag("stack"));
            stack.setCount(nbt.getInteger("inputSize"));
            IngredientStack ingr = new IngredientStack(stack);
            ingr.useNBT = nbt.getBoolean("useNBT");
            return ingr;
        case 1:
            NBTTagList list = nbt.getTagList("stackList", 10);
            List<ItemStack> stackList = new ArrayList();
            for (int i = 0; i < list.tagCount(); i++)
                stackList.add(new ItemStack(list.getCompoundTagAt(i)));
            return new IngredientStack(stackList, nbt.getInteger("inputSize"));
        case 2:
            return new IngredientStack(nbt.getString("oreName"), nbt.getInteger("inputSize"));
        case 3:
            FluidStack fs = new FluidStack(FluidRegistry.getFluid(nbt.getString("fluid")),
                    nbt.getInteger("fluidAmount"));
            return new IngredientStack(fs);
        }
    return null;
}

From source file:blusunrize.immersiveengineering.common.blocks.metal.TileEntityFluidPump.java

@Override
public void update() {
    ApiUtils.checkForNeedlessTicking(this);
    if (dummy || world.isRemote)
        return;//from  w w w . j a  v  a2s .c om
    if (tank.getFluidAmount() > 0) {
        int i = outputFluid(tank.getFluid(), false);
        tank.drain(i, true);
    }

    if (world.getRedstonePowerFromNeighbors(getPos()) > 0
            || world.getRedstonePowerFromNeighbors(getPos().add(0, 1, 0)) > 0) {
        for (EnumFacing f : EnumFacing.values())
            if (sideConfig[f.ordinal()] == 0) {
                BlockPos output = getPos().offset(f);
                TileEntity tile = Utils.getExistingTileEntity(world, output);
                if (tile != null && tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY,
                        f.getOpposite())) {
                    IFluidHandler handler = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY,
                            f.getOpposite());
                    FluidStack drain = handler.drain(500, false);
                    if (drain == null || drain.amount <= 0)
                        continue;
                    int out = this.outputFluid(drain, false);
                    handler.drain(out, true);
                } else if (world.getTotalWorldTime() % 20 == ((getPos().getX() ^ getPos().getZ()) & 19)
                        && world.getBlockState(getPos().offset(f)).getBlock() == Blocks.WATER
                        && IEConfig.Machines.pump_infiniteWater
                        && tank.fill(new FluidStack(FluidRegistry.WATER, 1000), false) == 1000
                        && this.energyStorage.extractEnergy(IEConfig.Machines.pump_consumption,
                                true) >= IEConfig.Machines.pump_consumption) {
                    int connectedSources = 0;
                    for (EnumFacing f2 : EnumFacing.HORIZONTALS) {
                        IBlockState waterState = world.getBlockState(getPos().offset(f).offset(f2));
                        if (waterState.getBlock() == Blocks.WATER
                                && Blocks.WATER.getMetaFromState(waterState) == 0)
                            connectedSources++;
                    }
                    if (connectedSources > 1) {
                        this.energyStorage.extractEnergy(IEConfig.Machines.pump_consumption, false);
                        this.tank.fill(new FluidStack(FluidRegistry.WATER, 1000), true);
                    }
                }
            }
        if (world.getTotalWorldTime() % 40 == (((getPos().getX() ^ getPos().getZ())) % 40 + 40) % 40) {
            if (closedList.isEmpty())
                prepareAreaCheck();
            else {
                int target = closedList.size() - 1;
                BlockPos pos = closedList.get(target);
                FluidStack fs = Utils.drainFluidBlock(world, pos, false);
                if (fs == null)
                    closedList.remove(target);
                else if (tank.fill(fs, false) == fs.amount
                        && this.energyStorage.extractEnergy(IEConfig.Machines.pump_consumption,
                                true) >= IEConfig.Machines.pump_consumption) {
                    this.energyStorage.extractEnergy(IEConfig.Machines.pump_consumption, false);
                    fs = Utils.drainFluidBlock(world, pos, true);
                    //                  int rainbow = (closedList.size()%11)+1;
                    //                  if(rainbow>6)
                    //                     rainbow+=2;
                    //                  if(rainbow>9)
                    //                     rainbow++;
                    //                  world.setBlock( cc.posX,cc.posY,cc.posZ, Blocks.stained_glass,rainbow, 0x3);
                    if (IEConfig.Machines.pump_placeCobble && placeCobble)
                        world.setBlockState(pos, Blocks.COBBLESTONE.getDefaultState());
                    this.tank.fill(fs, true);
                    closedList.remove(target);
                }
            }
        }
    }

    if (checkingArea)
        checkAreaTick();
}

From source file:blusunrize.immersiveengineering.common.crafting.IngredientFluidStack.java

public IngredientFluidStack(Fluid fluid, int amount) {
    this(new FluidStack(fluid, amount));
}

From source file:blusunrize.immersiveengineering.common.crafting.MixerPotionHelper.java

public static FluidStack getFluidStackForType(PotionType type, int amount) {
    if (type == PotionTypes.WATER || type == null)
        return new FluidStack(FluidRegistry.WATER, amount);
    FluidStack stack = new FluidStack(IEContent.fluidPotion, amount);
    stack.tag = new NBTTagCompound();
    stack.tag.setString("Potion", PotionType.REGISTRY.getNameForObject(type).toString());
    return stack;
}

From source file:blusunrize.immersiveengineering.common.util.compat.ActuallyAdditionsHelper.java

@Override
public void registerRecipes() {
    Fluid canolaOil = FluidRegistry.getFluid("canolaoil");
    if (canolaOil != null)
        SqueezerRecipe.addRecipe(new FluidStack(canolaOil, 80), ItemStack.EMPTY, "cropCanola", 6400);
}