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


Java FluidStack.getFluid方法代码示例

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


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

示例1: fill

import net.minecraftforge.fluids.FluidStack; //导入方法依赖的package包/类
@Override
public int fill(FluidStack resource, boolean doFill) {
    if (resource != null && canFill(resource.getFluid())) {
        EntityPlayer player = getPlayer();
        if (player != null) {
            int liquidToXP = PneumaticCraftAPIHandler.getInstance().liquidXPs.get(resource.getFluid());
            int xpPoints = resource.amount / liquidToXP;
            if (doFill) {
                player.addExperience(xpPoints);
                curXpFluid = resource.getFluid();
            }
            return xpPoints * liquidToXP;
        }
    }
    return 0;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:17,代码来源:TileEntityAerialInterface.java

示例2: 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

示例3: 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

示例4: 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

示例5: getValidRecipe

import net.minecraftforge.fluids.FluidStack; //导入方法依赖的package包/类
private IThermopneumaticProcessingPlantRecipe getValidRecipe() {
    for (IThermopneumaticProcessingPlantRecipe recipe : BasicThermopneumaticProcessingPlantRecipe.recipes) {
        if (recipe.isValidRecipe(inputTank.getFluid(), handler.getStackInSlot(0))) {
            if (outputTank.getFluid() == null) {
                return recipe;
            } else {
                FluidStack output = recipe.getRecipeOutput(inputTank.getFluid(), handler.getStackInSlot(0));
                if (output.getFluid() == outputTank.getFluid().getFluid() && output.amount <= outputTank.getCapacity() - outputTank.getFluidAmount()) {
                    return recipe;
                }
            }
        }
    }
    return null;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:16,代码来源:TileEntityThermopneumaticProcessingPlant.java

示例6: drain

import net.minecraftforge.fluids.FluidStack; //导入方法依赖的package包/类
@Nullable
@Override
public FluidStack drain(FluidStack resource, boolean doDrain) {
    if (resource != null && canDrain(resource.getFluid())) {
        EntityPlayer player = getPlayer();
        if (player != null) {
            int liquidToXP = PneumaticCraftAPIHandler.getInstance().liquidXPs.get(resource.getFluid());
            int pointsDrained = Math.min(getPlayerXP(player), resource.amount / liquidToXP);
            if (doDrain) addPlayerXP(player, -pointsDrained);
            return new FluidStack(resource.getFluid(), pointsDrained * liquidToXP);
        }
    }
    return null;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:15,代码来源:TileEntityAerialInterface.java

示例7: getTotalRequestedAmount

import net.minecraftforge.fluids.FluidStack; //导入方法依赖的package包/类
private int getTotalRequestedAmount(FluidStack stack) {
    int requesting = 0;
    for (int i = 0; i < 9; i++) {
        FluidStack requestingStack = getTankFilter(i).getFluid();
        if (requestingStack != null && requestingStack.getFluid() == stack.getFluid()) {
            requesting += requestingStack.amount;
        }
    }
    return requesting;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:11,代码来源:SemiBlockRequester.java

示例8: matches

import net.minecraftforge.fluids.FluidStack; //导入方法依赖的package包/类
@Override
public boolean matches(ItemStack subject) {
	FluidStack fs = FluidContainerRegistry.getFluidForFilledItem(subject);

	if (fs == null && subject.getItem() instanceof IFluidContainerItem) {
		IFluidContainerItem item = (IFluidContainerItem)subject.getItem();
		fs = item.getFluid(subject);
	}

	// match amount precisely to avoid having to deal with leftover
	return fs == null && fluid == null ||
			fs != null && fs.getFluid() == fluid && fs.amount >= amount;
}
 
开发者ID:Herobone,项目名称:HeroUtils,代码行数:14,代码来源:RecipeInputFluidContainer.java

示例9: consumeFluids

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

示例10: onBlockActivated

import net.minecraftforge.fluids.FluidStack; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
	if (world.isRemote) return true;
	TileEntityBarrel barrel = (TileEntityBarrel) world.getTileEntity(pos);
	world.notifyBlockUpdate(pos, state, state, 3);
	ItemStack stack = player.getHeldItem(hand);
	if (stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null)) {
		IFluidHandlerItem itemHandler = stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null);
		IFluidHandler barrelHandler = barrel.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null);
		FluidStack fluidInItem = itemHandler.drain(Fluid.BUCKET_VOLUME, false);
		FluidStack fluidInBarrel = barrelHandler.drain(Fluid.BUCKET_VOLUME, false);
		if ((fluidInBarrel != null && fluidInBarrel.amount > 0) && (fluidInItem == null || fluidInItem.amount == 0 || (fluidInItem.isFluidEqual(fluidInBarrel) && fluidInItem.amount < Fluid.BUCKET_VOLUME))) {
			itemHandler.fill(barrelHandler.drain(Fluid.BUCKET_VOLUME, true), true);
			player.setHeldItem(hand, itemHandler.getContainer());
		} else if (fluidInItem != null && fluidInItem.amount > 0 && fluidInItem.getFluid() != null && (fluidInBarrel == null || fluidInBarrel.amount == 0 || (fluidInBarrel.amount < Fluid.BUCKET_VOLUME && fluidInBarrel.isFluidEqual(fluidInItem)))) {
			FluidStack fsin = itemHandler.drain(Fluid.BUCKET_VOLUME, true);
			if (fsin != null && fsin.amount > 0 && fsin.getFluid() != null) {
				barrelHandler.fill(fsin, true);
				player.setHeldItem(hand, itemHandler.getContainer());
				player.inventory.markDirty();
			}
		}
		return true;
	}

	player.openGui(Bewitchment.instance, LibGui.BARREL.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
	return true;
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:29,代码来源:BlockBarrel.java

示例11: fluidStackToString

import net.minecraftforge.fluids.FluidStack; //导入方法依赖的package包/类
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+"}";
}
 
开发者ID:elytra,项目名称:Thermionics,代码行数:8,代码来源:PotStillRecipe.java

示例12: canFillFluidType

import net.minecraftforge.fluids.FluidStack; //导入方法依赖的package包/类
public boolean canFillFluidType(FluidStack fluid)
{
    if (fluid.getFluid() == FluidRegistry.WATER || fluid.getFluid() == FluidRegistry.LAVA || fluid.getFluid().getName().equals("milk"))
    {
        return true;
    }
    return FluidRegistry.isUniversalBucketEnabled() && FluidRegistry.getBucketFluids().contains(fluid.getFluid());
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:9,代码来源:FluidBucketWrapper.java

示例13: handleItemState

import net.minecraftforge.fluids.FluidStack; //导入方法依赖的package包/类
@Override
public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity)
{
    FluidStack fluidStack = FluidUtil.getFluidContained(stack);

    // not a fluid item apparently
    if (fluidStack == null)
    {
        // empty bucket
        return originalModel;
    }

    BakedDynBucket model = (BakedDynBucket)originalModel;

    Fluid fluid = fluidStack.getFluid();
    String name = fluid.getName();

    if (!model.cache.containsKey(name))
    {
        IModel parent = model.parent.process(ImmutableMap.of("fluid", name));
        Function<ResourceLocation, TextureAtlasSprite> textureGetter;
        textureGetter = new Function<ResourceLocation, TextureAtlasSprite>()
        {
            public TextureAtlasSprite apply(ResourceLocation location)
            {
                return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString());
            }
        };

        IBakedModel bakedModel = parent.bake(new SimpleModelState(model.transforms), model.format, textureGetter);
        model.cache.put(name, bakedModel);
        return bakedModel;
    }

    return model.cache.get(name);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:37,代码来源:ModelDynBucket.java

示例14: render

import net.minecraftforge.fluids.FluidStack; //导入方法依赖的package包/类
@SuppressWarnings("ConstantConditions")
@Override
public void render(TileCauldron te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
	Optional<FluidStack> optional = te.getFluid();
	if (optional.isPresent() && optional.get().amount > 0) {
		FluidStack fluidStack = optional.get();
		Fluid fluid = fluidStack.getFluid();
		ResourceLocation location = fluid.getStill();
		double level = (double) fluidStack.amount / (Fluid.BUCKET_VOLUME * 2D);

		GlStateManager.pushMatrix();
		GlStateManager.disableLighting();
		GlStateManager.translate(x, y + 0.1 + level, z);
		if (fluid == FluidRegistry.WATER || te.hasIngredients()) {
			float r = (te.getColorRGB() >>> 16 & 0xFF) / 256.0F;
			float g = (te.getColorRGB() >>> 8 & 0xFF) / 256.0F;
			float b = (te.getColorRGB() & 0xFF) / 256.0F;
			GlStateManager.color(r, g, b);
			if (fluid == FluidRegistry.WATER)
				location = ResourceLocations.GRAY_WATER;
		}

		Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);

		GlStateManager.enableBlend();
		GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
		GlStateManager.disableAlpha();

		final float w = 0.125F;
		GlStateManager.translate(w, 0, w);
		GlStateManager.rotate(90F, 1F, 0F, 0F);
		final float s = 0.0460425F;
		GlStateManager.scale(s, s, s);

		OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240F, 240F);
		renderWater(location);

		GlStateManager.enableAlpha();
		GlStateManager.disableBlend();

		GlStateManager.enableLighting();
		GlStateManager.popMatrix();
	}
	GlStateManager.pushMatrix();
	GlStateManager.translate(x + 0.5, y + 0.2D, z + 0.35);
	GlStateManager.rotate(90F, 1F, 0, 0);

	ItemStack stack = te.getContainer();
	if (!stack.isEmpty()) {
		Minecraft mc = Minecraft.getMinecraft();
		mc.getRenderItem().renderItem(stack, ItemCameraTransforms.TransformType.GROUND);
	}
	GlStateManager.popMatrix();
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:55,代码来源:TileRenderCauldron.java

示例15: hasFluid

import net.minecraftforge.fluids.FluidStack; //导入方法依赖的package包/类
public boolean hasFluid() {
	FluidStack fluid = getFluid();
	return fluid != null && fluid.amount > 0 && fluid.getFluid() != null;
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:5,代码来源:TileFluidInventory.java


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