當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。