Java 类net.minecraftforge.fluids.FluidStack 实例源码

项目:ModularMachinery    文件:ComponentRequirement.java   
@Optional.Method(modid = "mekanism")
private boolean finishWithMekanismHandling(HybridTank handler, ResultChance chance) {
    if(this.required instanceof HybridFluidGas && handler instanceof HybridGasTank) {
        GasStack gasOut = ((HybridFluidGas) this.required).asGasStack();
        HybridGasTank gasTankHandler = (HybridGasTank) handler;
        int fillableGas = gasTankHandler.receiveGas(EnumFacing.UP, gasOut, false);
        if(chance.canProduce(this.chance)) {
            return fillableGas >= gasOut.amount;
        }
        return fillableGas >= gasOut.amount && gasTankHandler.receiveGas(EnumFacing.UP, gasOut, true) >= gasOut.amount;
    } else {
        FluidStack outStack = this.required.asFluidStack();
        if(outStack != null) {
            int fillableAmount = handler.fillInternal(outStack.copy(), false);
            if(chance.canProduce(this.chance)) {
                return fillableAmount >= outStack.amount;
            }
            FluidStack copyOut = outStack.copy();
            if(this.tagDisplay != null ){
                copyOut.tag = this.tagDisplay.copy();
            }
            return fillableAmount >= outStack.amount && handler.fillInternal(copyOut.copy(), true) >= copyOut.amount;
        }
    }
    return false;
}
项目:Soot    文件:CapabilityMixerOutput.java   
@Nullable
@Override
public FluidStack drain(FluidStack resource, boolean doDrain) {
    FluidStack drained = null;

    if(tile != null)
    for (EnumFacing facing : EnumFacing.HORIZONTALS) {
        if(tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY,facing))
        {
            IFluidHandler capability = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY,facing);
            drained = capability.drain(resource,doDrain);
            if(drained != null)
                break;
        }
    }

    return drained;
}
项目:pnc-repressurized    文件:WidgetTank.java   
@Override
public void addTooltip(int mouseX, int mouseY, List<String> curTip, boolean shift) {
    Fluid fluid = null;
    int amt = 0;
    int capacity = 0;

    if (tank.getFluid() != null) {
        fluid = tank.getFluid().getFluid();
        amt = tank.getFluidAmount();
    }
    capacity = tank.getCapacity();

    if (fluid == null || amt == 0 || capacity == 0) {
        curTip.add(amt + "/" + capacity + " mb");
        curTip.add(TextFormatting.GRAY + I18n.format("gui.liquid.empty"));
    } else {
        curTip.add(amt + "/" + capacity + " mb");
        curTip.add(TextFormatting.GRAY + fluid.getLocalizedName(new FluidStack(fluid, amt)));
    }
}
项目:CustomWorldGen    文件:FluidBucketWrapper.java   
@Nullable
@Override
public FluidStack drain(int maxDrain, boolean doDrain)
{
    if (container.stackSize != 1 || maxDrain < Fluid.BUCKET_VOLUME)
    {
        return null;
    }

    FluidStack fluidStack = getFluid();
    if (fluidStack != null)
    {
        if (doDrain)
        {
            setFluid(null);
        }
        return fluidStack;
    }

    return null;
}
项目:Soot    文件:CapabilityMixerOutput.java   
@Nullable
@Override
public FluidStack drain(int maxDrain, boolean doDrain) {
    FluidStack drained = null;

    if(tile != null)
        for (EnumFacing facing : EnumFacing.HORIZONTALS) {
            if(tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY,facing))
            {
                IFluidHandler capability = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY,facing);
                drained = capability.drain(maxDrain,doDrain);
                if(drained != null)
                    break;
            }
        }

    return drained;
}
项目:ModularMachinery    文件:HybridStackHelper.java   
private T matchFluidStack(Iterable<T> ingredients, T ingredientToMatch) {
    if(Iterables.isEmpty(ingredients)) {
        return null;
    }
    FluidStack stack = ingredientToMatch.asFluidStack();
    if(stack == null) {
        return null;
    }
    Fluid fluidMatch = stack.getFluid();
    for (T hybridFluid : ingredients) {
        FluidStack hybridFluidStack = hybridFluid.asFluidStack();
        if(hybridFluidStack == null) {
            continue;
        }
        if(hybridFluidStack.getFluid() == fluidMatch) {
            return hybridFluid;
        }
    }
    return null;
}
项目:CustomWorldGen    文件:FluidBucketWrapper.java   
@Nullable
@Override
public FluidStack drain(FluidStack resource, boolean doDrain)
{
    if (container.stackSize != 1 || resource == null || resource.amount < Fluid.BUCKET_VOLUME)
    {
        return null;
    }

    FluidStack fluidStack = getFluid();
    if (fluidStack != null && fluidStack.isFluidEqual(resource))
    {
        if (doDrain)
        {
            setFluid(null);
        }
        return fluidStack;
    }

    return null;
}
项目:Steam-and-Steel    文件:RenderItemBlockGlassTank.java   
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {

    RenderBlocks renderblocks = (RenderBlocks) data[0];
    Block block = Block.getBlockFromItem(item.getItem());
    if (item.hasTagCompound()) {
        NBTTagCompound tag = item.stackTagCompound;
        if (tag.hasKey("Fluid")) {
            FluidStack liquid = FluidStack.loadFluidStackFromNBT(item.getTagCompound().getCompoundTag("Fluid"));
            if (liquid != null) {
                GL11.glEnable(GL11.GL_BLEND);
                float height = ((float) liquid.amount / (float) 8000 * (float) 0.99);
                renderblocks.setRenderBounds(0.01, 0.01, 0.01, 0.99, height, 0.99);
                Utils.renderInventoryBlock(renderblocks, GrandFluidTank.renderblocks, liquid.getFluid());
                GL11.glDisable(GL11.GL_BLEND);
            }
        }

        GL11.glEnable(GL11.GL_ALPHA_TEST);
        renderblocks.setRenderBounds(0, 0, 0, 1, 1, 1);
        Utils.renderInventoryBlock(renderblocks, block, GrandFluidTank.glassfluidtank.getIcon(0, 0));
        GL11.glDisable(GL11.GL_ALPHA_TEST);

    }
}
项目:HeroUtils    文件:RecipeOutputFluid.java   
@Override
public boolean equals(Object obj) {
    if (obj instanceof RecipeOutputFluid) {
        RecipeOutputFluid ro = (RecipeOutputFluid) obj;

        if (outputs.size() == ro.outputs.size() &&
                (metadata == null && ro.metadata == null || metadata != null && ro.metadata != null && metadata.equals(ro.metadata))) {
            Iterator<FluidStack> itA = outputs.iterator();
            Iterator<FluidStack> itB = ro.outputs.iterator();

            while (itA.hasNext() && itB.hasNext()) {
                FluidStack stackA = itA.next();
                FluidStack stackB = itB.next();

                if (stackA.isFluidStackIdentical(stackB)) return false;
            }

            return true;
        }
    }

    return false;
}
项目:FoodCraft-Reloaded    文件:FluidStackRenderer.java   
private void drawFluid(Minecraft minecraft, final int xPosition, final int yPosition, @Nullable FluidStack fluidStack) {
    if (fluidStack == null) {
        return;
    }
    Fluid fluid = fluidStack.getFluid();
    if (fluid == null) {
        return;
    }

    TextureAtlasSprite fluidStillSprite = getStillFluidSprite(minecraft, fluid);

    int fluidColor = fluid.getColor(fluidStack);

    int scaledAmount = (fluidStack.amount * height) / capacityMb;
    if (fluidStack.amount > 0 && scaledAmount < MIN_FLUID_HEIGHT) {
        scaledAmount = MIN_FLUID_HEIGHT;
    }
    if (scaledAmount > height) {
        scaledAmount = height;
    }

    drawTiledSprite(minecraft, xPosition, yPosition, width, height, fluidColor, scaledAmount, fluidStillSprite);
}
项目:CustomWorldGen    文件:BlockLiquidWrapper.java   
@Nullable
private FluidStack getStack(IBlockState blockState)
{
    Material material = blockState.getMaterial();
    if (material == Material.WATER && blockState.getValue(BlockLiquid.LEVEL) == 0)
    {
        return new FluidStack(FluidRegistry.WATER, Fluid.BUCKET_VOLUME);
    }
    else if (material == Material.LAVA && blockState.getValue(BlockLiquid.LEVEL) == 0)
    {
        return new FluidStack(FluidRegistry.LAVA, Fluid.BUCKET_VOLUME);
    }
    else
    {
        return null;
    }
}
项目:pnc-repressurized    文件:ItemLogisticsFrame.java   
public static void addTooltip(ItemStack stack, World world, List<String> curInfo, boolean sneaking) {
    if (stack.getTagCompound() != null && stack.getItem() instanceof ItemSemiBlockBase) {
        if (stack.getTagCompound().getBoolean("invisible")) curInfo.add(I18n.format("gui.logisticFrame.invisible"));
        if (stack.getTagCompound().hasKey("filters") && stack.getTagCompound().getTagList("filters", 10).tagCount() > 0 || stack.getTagCompound().hasKey("fluidFilters") && stack.getTagCompound().getTagList("fluidFilters", 10).tagCount() > 0) {
            String key = SemiBlockManager.getKeyForSemiBlock(SemiBlockManager.getSemiBlockForItem((ItemSemiBlockBase) stack.getItem()));
            if (sneaking) {
                curInfo.add(I18n.format(String.format("gui.%s.filters", key)));
                SemiBlockRequester requester = new SemiBlockRequester();
                requester.onPlaced(PneumaticCraftRepressurized.proxy.getPlayer(), stack, null);
                ItemStack[] stacks = new ItemStack[requester.getFilters().getSlots()];
                for (int i = 0; i < stacks.length; i++) {
                    stacks[i] = requester.getFilters().getStackInSlot(i);
                }
                PneumaticCraftUtils.sortCombineItemStacksAndToString(curInfo, stacks);
                for (int i = 0; i < 9; i++) {
                    FluidStack fluid = requester.getTankFilter(i).getFluid();
                    if (fluid != null) {
                        curInfo.add("-" + fluid.amount / 1000 + "B " + fluid.getLocalizedName());
                    }
                }
            } else {
                curInfo.add(I18n.format(String.format("gui.%s.hasFilters", key)));
            }
        }
    }
}
项目:pnc-repressurized    文件:SemiBlockRequester.java   
@Override
public int amountRequested(FluidStack stack) {
    int totalRequestingAmount = getTotalRequestedAmount(stack);
    if (totalRequestingAmount > 0) {
        TileEntity te = getTileEntity();
        int count = 0;
        for (EnumFacing facing : EnumFacing.VALUES) {
            if (te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing)) {
                IFluidHandler handler = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing);
                for (IFluidTankProperties properties : handler.getTankProperties()) {
                    FluidStack contents = properties.getContents();
                    if (contents != null && contents.getFluid() == stack.getFluid()) {
                        count += contents.amount;
                    }
                }
                if (count > 0) break;
            }
        }
        if (count == 0) return 0;
        count += getIncomingFluid(stack.getFluid());
        return Math.max(0, Math.min(stack.amount, totalRequestingAmount - count));
    }
    return 0;
}
项目:pnc-repressurized    文件:TileEntityGasLift.java   
private boolean suckLiquid() {
    Block block = world.getBlockState(getPos().offset(EnumFacing.DOWN, currentDepth + 1)).getBlock();
    Fluid fluid = FluidRegistry.lookupFluidForBlock(block);
    if (fluid == null) {
        pumpingLake = null;
        return false;
    }

    FluidStack fluidStack = new FluidStack(fluid, 1000);
    if (tank.fill(fluidStack, false) == 1000) {
        if (pumpingLake == null) {
            findLake(block);
        }
        BlockPos curPos = null;
        boolean foundSource = false;
        while (pumpingLake.size() > 0) {
            curPos = pumpingLake.get(0);
            if (getWorld().getBlockState(curPos).getBlock() == block && FluidUtils.isSourceBlock(getWorld(), curPos)) {
                foundSource = true;
                break;
            }
            pumpingLake.remove(0);
        }
        if (pumpingLake.size() == 0) {
            pumpingLake = null;
        } else if (foundSource) {
            getWorld().setBlockToAir(curPos);
            tank.fill(fluidStack, true);
            addAir(-100);
            status = Status.PUMPING;
        }
    }
    return true;
}
项目:Metalworks    文件:Registry.java   
@SubscribeEvent
public static void registerGeoBurnables(RegistryEvent.Register<IGeoburnable> event){
    IForgeRegistry<IGeoburnable> reg = event.getRegistry();
    reg.register(new BlockGeoburnable(Blocks.MAGMA, 40, 1));
    reg.register(new BlockGeoburnable(Blocks.FIRE, 80, 2){
        @Override
        public ItemStack getJEIIcon() {
            return new ItemStack(Items.FLINT_AND_STEEL);
        }
    });
    reg.register(new BlockGeoburnable(Blocks.LAVA, 160, 3){
        @Override
        public ItemStack getJEIIcon() {
            return FluidUtil.getFilledBucket(new FluidStack(FluidRegistry.LAVA, Fluid.BUCKET_VOLUME));
        }
    });
}
项目:CustomWorldGen    文件:FluidHandlerConcatenate.java   
@Override
public int fill(FluidStack resource, boolean doFill)
{
    if (resource == null || resource.amount <= 0)
        return 0;

    resource = resource.copy();

    int totalFillAmount = 0;
    for (IFluidHandler handler : subHandlers)
    {
        int fillAmount = handler.fill(resource, doFill);
        totalFillAmount += fillAmount;
        resource.amount -= fillAmount;
        if (resource.amount <= 0)
            break;
    }
    return totalFillAmount;
}
项目:pnc-repressurized    文件:GuiAerialInterface.java   
private List<String> getLiquidXPText() {
    List<String> liquidXpText = new ArrayList<String>();
    liquidXpText.add("gui.tab.info.aerialInterface.liquidXp.info");
    for (Fluid fluid : PneumaticCraftAPIHandler.getInstance().liquidXPs.keySet()) {
        liquidXpText.add(TextFormatting.DARK_AQUA + new FluidStack(fluid, 1).getLocalizedName() + " (" + fluid.getName() + ")");
    }
    return liquidXpText;
}
项目:pnc-repressurized    文件:GuiLiquidCompressor.java   
private List<String> getAllFuels() {
    List<String> fuels = new ArrayList<String>();
    fuels.add("L/Bucket | Fluid");
    for (Map.Entry<String, Integer> map : sortByValue(PneumaticCraftAPIHandler.getInstance().liquidFuels).entrySet()) {
        String value = map.getValue() / 1000 + "";
        while (fontRenderer.getStringWidth(value) < 25) {
            value = value + " ";
        }
        Fluid fluid = FluidRegistry.getFluid(map.getKey());
        fuels.add(value + "| " + fluid.getLocalizedName(new FluidStack(fluid, 1)));
    }
    return fuels;
}
项目:Industrial-Foregoing    文件:LavaStrawHandler.java   
@Override
public void onDrink(World world, BlockPos pos, FluidStack stack, EntityPlayer player, boolean fromFluidContainer) {
    player.attackEntityFrom(DamageSource.LAVA, 7);
    player.setFire(30);
    NBTTagCompound tag = player.getEntityData();
    tag.setLong("lavaDrink", world.getTotalWorldTime());
}
项目:CustomWorldGen    文件:FluidContainerRegistryWrapper.java   
@Nullable
@Override
public FluidStack drain(int maxDrain, boolean doDrain)
{
    if (container.stackSize != 1)
    {
        return null;
    }

    FluidStack contained = FluidContainerRegistry.getFluidForFilledItem(container);
    if (contained != null)
    {
        if (contained.amount <= maxDrain)
        {
            ItemStack emptyContainer = FluidContainerRegistry.drainFluidContainer(container);
            if (emptyContainer != null)
            {
                if (doDrain)
                {
                    if (FluidContainerRegistry.hasNullEmptyContainer(container))
                    {
                        emptyContainer.stackSize = 0;
                    }
                    container.deserializeNBT(emptyContainer.serializeNBT());
                }
                return contained;
            }
        }
    }

    return null;
}
项目:harshencastle    文件:HarshenRegistry.java   
public static int getFill(ItemStack stack)
{
    if(stack.getItem() instanceof UniversalBucket)
        return FORGE_INPUT_AMOUNT.get(FluidStack.loadFluidStackFromNBT(stack.getTagCompound()).getFluid());
    for(ItemStack stack1 : ITEMLIQUID_MAP.keySet())
        if(stack1.isItemEqual(stack))
            return 64;
    return HarshenUtils.getObjectFromItemMap(INPUT_FILLBY, stack);
}
项目:customstuff4    文件:MachineRecipeCategory.java   
@Override
public void setRecipe(IRecipeLayout recipeLayout, MachineRecipeWrapper recipeWrapper, IIngredients ingredients)
{
    super.setRecipe(recipeLayout, recipeWrapper, ingredients);

    IGuiItemStackGroup stacks = recipeLayout.getItemStacks();
    IGuiFluidStackGroup fluids = recipeLayout.getFluidStacks();

    List<List<ItemStack>> inputItems = ingredients.getInputs(ItemStack.class);
    List<List<FluidStack>> inputFluids = ingredients.getInputs(FluidStack.class);
    List<List<ItemStack>> outputItems = ingredients.getOutputs(ItemStack.class);
    List<List<FluidStack>> outputFluids = ingredients.getOutputs(FluidStack.class);

    initItems(stacks, true, module.inputSlots, 0);
    initItems(stacks, false, module.outputSlots, module.inputSlots);

    initFluids(fluids, true, module.inputTanks, 0);
    initFluids(fluids, false, module.outputTanks, module.inputTanks.length);

    for (int i = 0; i < inputItems.size(); i++)
    {
        stacks.set(i, inputItems.get(i));
    }

    for (int i = 0; i < outputItems.size(); i++)
    {
        stacks.set(module.inputSlots + i, outputItems.get(i));
    }

    for (int i = 0; i < inputFluids.size(); i++)
    {
        fluids.set(i, inputFluids.get(i));
    }

    for (int i = 0; i < outputFluids.size(); i++)
    {
        fluids.set(module.inputTanks.length + i, outputFluids.get(i));
    }
}
项目:pnc-repressurized    文件:FluidPlastic.java   
public static FluidStack mixFluid(FluidStack plastic, FluidStack otherPlastic) {
    if (plastic == null) return otherPlastic;
    if (otherPlastic == null) return plastic;
    int[] otherColor = getColor3(otherPlastic);
    int[] color = getColor3(plastic);
    double ratio = (double) plastic.amount / (plastic.amount + otherPlastic.amount);
    int[] newColor = new int[3];
    for (int i = 0; i < 3; i++) {
        newColor[i] = (int) (ratio * color[i] + (1 - ratio) * otherColor[i]);
    }
    NBTTagCompound newTag = new NBTTagCompound();
    newTag.setInteger("color", (newColor[0] << 16) + (newColor[1] << 8) + newColor[2]);
    // newTag.setInteger("temperature", (int)(ratio * getTemperatureS(plastic) + (1 - ratio) * getTemperatureS(otherPlastic)));
    return new FluidStack(Fluids.PLASTIC, plastic.amount + otherPlastic.amount, newTag);
}
项目:pnc-repressurized    文件:JEIPlasticMixerCategory.java   
private PlasticMixerRecipeWrapper(FluidStack input, ItemStack output) {
    addInputLiquid(input, 146, 11);
    addIngredient(new PositionedStack(new ItemStack(Items.DYE, 1, 1), 121, 19));
    addIngredient(new PositionedStack(new ItemStack(Items.DYE, 1, 2), 121, 37));
    addIngredient(new PositionedStack(new ItemStack(Items.DYE, 1, 4), 121, 55));
    addOutput(new PositionedStack(output, 92, 55));
    setUsedTemperature(76, 22, PneumaticValues.PLASTIC_MIXER_MELTING_TEMP);
}
项目:Industrial-Foregoing    文件:MobSlaughterFactoryTile.java   
@Override
public float work() {
    if (WorkUtils.isDisabled(this.getBlockType())) return 0;

    AxisAlignedBB area = getWorkingArea();
    List<EntityLiving> mobs = this.getWorld().getEntitiesWithinAABB(EntityLiving.class, area);
    if (mobs.size() == 0) return 0;
    EntityLiving mob = mobs.get(this.getWorld().rand.nextInt(mobs.size()));
    this.outMeat.fill(new FluidStack(FluidsRegistry.MEAT, (int) (mob.getHealth() * BlockRegistry.mobSlaughterFactoryBlock.getMeatValue())), true);
    this.outPink.fill(new FluidStack(FluidsRegistry.PINK_SLIME, (int) mob.getHealth()), true);
    mob.setDropItemsWhenDead(false);
    mob.attackEntityFrom(CommonProxy.custom, mob.getMaxHealth());

    return 1;
}
项目:pnc-repressurized    文件:PneumaticCraftCategory.java   
@Override
public void getIngredients(@Nonnull IIngredients ingredients) {
    ingredients.setInputLists(ItemStack.class, input.stream().map(PositionedStack::getStacks).collect(Collectors.toList()));
    ingredients.setInputs(FluidStack.class, inputLiquids.stream().map(WidgetTank::getFluid).collect(Collectors.toList()));
    ingredients.setOutputLists(ItemStack.class, output.stream().map(PositionedStack::getStacks).collect(Collectors.toList()));
    ingredients.setOutputs(FluidStack.class, outputLiquids.stream().map(WidgetTank::getFluid).collect(Collectors.toList()));
}
项目:Soot    文件:TileEntityMixerBottomImproved.java   
public void consumeFluids(ArrayList<FluidStack> fluids, FluidMixingRecipe recipe) {
    for (FluidTank tank : tanks) {
        FluidStack tankFluid = tank.getFluid();
        boolean doContinue = true;
        for (int j = 0; j < recipe.inputs.size() && doContinue; j++) {
            FluidStack recipeFluid = recipe.inputs.get(j);
            if (recipeFluid != null && tankFluid != null && recipeFluid.getFluid() == tankFluid.getFluid()) {
                doContinue = false;
                tank.drain(recipeFluid.amount,true);
            }
        }
    }
}
项目:pnc-repressurized    文件:IGWHandler.java   
/**
 * TODO: raise a PR to get this into IGW.  This adds support for Forge filled buckets (use "item/bucket/{fluid_name}")
 *
 * @param stack
 * @return
 */
static String getNameFromStack(ItemStack stack) {
    if (stack.getItem().getRegistryName().toString().equals("forge:bucketfilled")) {
        FluidStack fluidStack = FluidUtil.getFluidContained(stack);
        if (fluidStack != null) {
            return "item/bucket/" + fluidStack.getFluid().getName();
        } else {
            return "item/bucket";
        }
    }
    return stack.getUnlocalizedName().replace("tile.", "block/").replace("item.", "item/");
}
项目:pnc-repressurized    文件:Helper.java   
public static String getStackDescription(IIngredient stack) {
    Object internalObject = stack.getInternal();

    if(internalObject instanceof ItemStack) {
        return getStackDescription((ItemStack) internalObject);
    } else if(internalObject instanceof FluidStack) {
        return getStackDescription((FluidStack) internalObject);
    } else if(internalObject instanceof IOreDictEntry) {
        return getStackDescription(((IOreDictEntry) internalObject).getName());
    } else {
        return "null";
    }
}
项目:Industrial-Foregoing    文件:StrawUtils.java   
@Nonnull
public static Optional<StrawHandler> getStrawHandler(@Nonnull FluidStack stack) {

    List<StrawHandler> current = Lists.newArrayList(IFRegistries.STRAW_HANDLER_REGISTRY);
    current.sort(Comparator.comparingInt(StrawHandler::getPriority));
    for (StrawHandler handler : current) {
        if (handler.validFluid(stack))
            return Optional.of(handler);
    }
    return Optional.empty();
}
项目:pnc-repressurized    文件:BasicThermopneumaticProcessingPlantRecipe.java   
public BasicThermopneumaticProcessingPlantRecipe(FluidStack inputLiquid, @Nonnull ItemStack inputItem,
                                                 FluidStack outputLiquid, double requiredTemperature, float requiredPressure) {
    this.inputItem = inputItem;
    this.inputLiquid = inputLiquid;
    this.outputLiquid = outputLiquid;
    this.requiredTemperature = requiredTemperature;
    this.requiredPressure = requiredPressure;
}
项目:Industrial-Foregoing    文件:FluidPumpTile.java   
@Override
public float work() {
    if (WorkUtils.isDisabled(this.getBlockType()) || isWorkFinished) return 0;
    if (tank.getFluidAmount() + 1000 <= tank.getCapacity()) {
        if (blocks == null) {
            blocks = new PriorityQueue<>(Comparator.comparingDouble(value -> (this.pos).distanceSq(((BlockPos) value).getX(), this.pos.getY() - 1, ((BlockPos) value).getZ())));
            BlockUtils.getBlockPosInAABB(getWorkingArea()).stream().filter(pos1 -> !this.world.isOutsideBuildHeight(pos1) && FluidRegistry.lookupFluidForBlock(this.world.getBlockState(pos1).getBlock()) != null && FluidRegistry.lookupFluidForBlock(this.world.getBlockState(pos1).getBlock()).getName().equals(fluid)).forEach(pos1 -> blocks.add(pos1));
        }
        if (blocks.isEmpty()) {
            isWorkFinished = true;
            blocks = null;
            return 0;
        }
        BlockPos peeked = blocks.peek();
        while (!blocks.isEmpty() && (this.world.isOutsideBuildHeight(peeked) || FluidRegistry.lookupFluidForBlock(this.world.getBlockState(peeked).getBlock()) == null || !FluidRegistry.lookupFluidForBlock(this.world.getBlockState(peeked).getBlock()).getName().equals(fluid) || this.world.getBlockState(peeked).getBlock().getMetaFromState(this.world.getBlockState(peeked)) != 0)) {
            blocks.poll();
            if (!blocks.isEmpty()) peeked = blocks.peek();
        }
        if (blocks.isEmpty()) {
            blocks = null;
            return 0;
        }
        while (this.world.getBlockState(peeked).getBlock().equals(this.world.getBlockState(peeked.add(0, -1, 0)).getBlock())) {
            peeked = peeked.add(0, -1, 0);
        }
        FluidStack stack = new FluidStack(FluidRegistry.lookupFluidForBlock(this.world.getBlockState(peeked).getBlock()), 1000);
        tank.fill(stack, true);
        this.world.setBlockState(peeked, Blocks.COBBLESTONE.getDefaultState());
        return 1;
    }
    return 0;
}
项目:Whoosh    文件:ItemTransporter.java   
@Override
public FluidStack drain(ItemStack container, int maxDrain, boolean doDrain) {

    if (container.getTagCompound() == null) {
        container.setTagCompound(new NBTTagCompound());
    }
    if (!container.getTagCompound().hasKey("Fluid") || maxDrain == 0) {
        return null;
    }
    FluidStack stack = FluidStack.loadFluidStackFromNBT(container.getTagCompound().getCompoundTag("Fluid"));

    if (stack == null) {
        return null;
    }
    int drained = Math.min(stack.amount, maxDrain);

    if (doDrain && ItemHelper.getItemDamage(container) != CREATIVE) {
        if (maxDrain >= stack.amount) {
            container.getTagCompound().removeTag("Fluid");
            return stack;
        }
        NBTTagCompound fluidTag = container.getTagCompound().getCompoundTag("Fluid");
        fluidTag.setInteger("Amount", fluidTag.getInteger("Amount") - drained);
        container.getTagCompound().setTag("Fluid", fluidTag);
    }
    stack.amount = drained;
    return stack;
}
项目:customstuff4    文件:TileEntityModuleMachine.java   
private MachineRecipe getActiveRecipe()
{
    NonNullList<ItemStack> input = invHandler.getInputStacks();
    List<FluidStack> inputFluid = Arrays.stream(supplier.inputTanks)
                                        .map(fluidSource::getFluidTank)
                                        .map(IFluidTank::getFluid)
                                        .collect(Collectors.toList());

    return MachineManager.findMatchingRecipe(supplier.recipeList, input, inputFluid, tile.getWorld());
}
项目:Thermionics    文件:PotStillRecipe.java   
private String fluidStackToString(FluidStack stack) {
    if (stack==null) return "null";
    if (stack.getFluid()==null) return "fluid_null";
    String tagString = "null";
    if (stack.tag != null) tagString = "{"+stack.tag.toString()+"}";
    return "{fluid:"+stack.getFluid().getName()+", tag:"+tagString+", amount:"+stack.amount+"}";
}
项目:ModularMachinery    文件:RecipePrimer.java   
private void requireFluid(MachineComponent.IOType ioType, ILiquidStack stack) {
    FluidStack mcFluid = CraftTweakerMC.getLiquidStack(stack);
    if(mcFluid == null) {
        CraftTweakerAPI.logError("Fluidstack not found/unknown fluid: " + stack.toString());
        return;
    }
    if(stack.getTag() != null) {
        mcFluid.tag = CraftTweakerMC.getNBTCompound(stack.getTag());
    }
    ComponentRequirement.RequirementFluid rf = new ComponentRequirement.RequirementFluid(ioType, mcFluid);
    appendComponent(rf);
}
项目:customstuff4    文件:MachineRecipeImpl.java   
@Override
public List<FluidStack> getFluidResult()
{
    return outputFluidStacks.stream()
                            .map(FluidStack::copy)
                            .collect(Collectors.toList());
}
项目:pnc-repressurized    文件:AmadronOfferCustom.java   
void payout() {
    TileEntity returning = getReturningTileEntity();
    TileEntity provider = getProvidingTileEntity();
    if (pendingPayments > 0) {
        int paying = Math.min(pendingPayments, 50);
        paying = ContainerAmadron.capShoppingAmount(this, paying,
                AmadronOfferManager.getItemHandler(provider), AmadronOfferManager.getItemHandler(returning),
                AmadronOfferManager.getFluidHandler(provider), AmadronOfferManager.getFluidHandler(returning),
                null);
        if (paying > 0) {
            pendingPayments -= paying;
            if (getInput() instanceof ItemStack) {
                ItemStack deliveringItems = (ItemStack) getInput();
                int amount = deliveringItems.getCount() * paying;
                List<ItemStack> stacks = new ArrayList<>();
                while (amount > 0) {
                    ItemStack stack = deliveringItems.copy();
                    stack.setCount(Math.min(amount, stack.getMaxStackSize()));
                    stacks.add(stack);
                    amount -= stack.getCount();
                }
                DroneRegistry.getInstance().deliverItemsAmazonStyle(returning.getWorld(), returning.getPos(), stacks.toArray(new ItemStack[stacks.size()]));
            } else {
                FluidStack deliveringFluid = ((FluidStack) getInput()).copy();
                deliveringFluid.amount *= paying;
                DroneRegistry.getInstance().deliverFluidAmazonStyle(returning.getWorld(), returning.getPos(), deliveringFluid);
            }
        }
    }
}
项目:CustomWorldGen    文件:FluidBlockWrapper.java   
@Override
public IFluidTankProperties[] getTankProperties()
{
    float percentFilled = fluidBlock.getFilledPercentage(world, blockPos);
    if (percentFilled < 0)
    {
        percentFilled *= -1;
    }
    int amountFilled = Math.round(Fluid.BUCKET_VOLUME * percentFilled);
    FluidStack fluid = amountFilled > 0 ? new FluidStack(fluidBlock.getFluid(), amountFilled) : null;
    return new FluidTankProperties[]{ new FluidTankProperties(fluid, Fluid.BUCKET_VOLUME, false, true)};
}
项目:customstuff4    文件:MachineManager.java   
public static MachineRecipe findMatchingRecipe(ResourceLocation list, NonNullList<ItemStack> input, List<FluidStack> inputFluid, World worldIn)
{
    if (list.toString().equals("minecraft:vanilla"))
    {
        if (input.size() == 1 && !input.get(0).isEmpty())
        {
            return new VanillaFurnaceRecipe(FurnaceRecipes.instance().getSmeltingResult(input.get(0)));
        } else
        {
            return MachineRecipe.EMPTY;
        }
    }

    return findMatchingRecipe(getRecipes(list), input, inputFluid, worldIn);
}