当前位置: 首页>>代码示例>>Java>>正文


Java FluidStack类代码示例

本文整理汇总了Java中net.minecraftforge.fluids.FluidStack的典型用法代码示例。如果您正苦于以下问题:Java FluidStack类的具体用法?Java FluidStack怎么用?Java FluidStack使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FluidStack类属于net.minecraftforge.fluids包,在下文中一共展示了FluidStack类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: finishWithMekanismHandling

import net.minecraftforge.fluids.FluidStack; //导入依赖的package包/类
@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;
}
 
开发者ID:HellFirePvP,项目名称:ModularMachinery,代码行数:27,代码来源:ComponentRequirement.java

示例2: drain

import net.minecraftforge.fluids.FluidStack; //导入依赖的package包/类
@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;
}
 
开发者ID:DaedalusGame,项目名称:Soot,代码行数:19,代码来源:CapabilityMixerOutput.java

示例3: addTooltip

import net.minecraftforge.fluids.FluidStack; //导入依赖的package包/类
@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)));
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:21,代码来源:WidgetTank.java

示例4: drain

import net.minecraftforge.fluids.FluidStack; //导入依赖的package包/类
@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;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:22,代码来源:FluidBucketWrapper.java

示例5: matchFluidStack

import net.minecraftforge.fluids.FluidStack; //导入依赖的package包/类
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;
}
 
开发者ID:HellFirePvP,项目名称:ModularMachinery,代码行数:21,代码来源:HybridStackHelper.java

示例6: renderItem

import net.minecraftforge.fluids.FluidStack; //导入依赖的package包/类
@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);

	}
}
 
开发者ID:grand-mine-inc,项目名称:Steam-and-Steel,代码行数:26,代码来源:RenderItemBlockGlassTank.java

示例7: equals

import net.minecraftforge.fluids.FluidStack; //导入依赖的package包/类
@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;
}
 
开发者ID:Herobone,项目名称:HeroUtils,代码行数:24,代码来源:RecipeOutputFluid.java

示例8: drawFluid

import net.minecraftforge.fluids.FluidStack; //导入依赖的package包/类
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);
}
 
开发者ID:LasmGratel,项目名称:FoodCraft-Reloaded,代码行数:24,代码来源:FluidStackRenderer.java

示例9: getStack

import net.minecraftforge.fluids.FluidStack; //导入依赖的package包/类
@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;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:18,代码来源:BlockLiquidWrapper.java

示例10: addTooltip

import net.minecraftforge.fluids.FluidStack; //导入依赖的package包/类
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)));
            }
        }
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:27,代码来源:ItemLogisticsFrame.java

示例11: amountRequested

import net.minecraftforge.fluids.FluidStack; //导入依赖的package包/类
@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;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:25,代码来源:SemiBlockRequester.java

示例12: suckLiquid

import net.minecraftforge.fluids.FluidStack; //导入依赖的package包/类
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;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:35,代码来源:TileEntityGasLift.java

示例13: registerGeoBurnables

import net.minecraftforge.fluids.FluidStack; //导入依赖的package包/类
@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));
        }
    });
}
 
开发者ID:canitzp,项目名称:Metalworks,代码行数:18,代码来源:Registry.java

示例14: fill

import net.minecraftforge.fluids.FluidStack; //导入依赖的package包/类
@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;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:20,代码来源:FluidHandlerConcatenate.java

示例15: getLiquidXPText

import net.minecraftforge.fluids.FluidStack; //导入依赖的package包/类
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;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:9,代码来源:GuiAerialInterface.java


注:本文中的net.minecraftforge.fluids.FluidStack类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。