Class FluidIngredient
java.lang.Object
net.minecraft.world.item.crafting.Ingredient
me.desht.pneumaticcraft.api.crafting.ingredient.FluidIngredient
- All Implemented Interfaces:
Predicate<net.minecraft.world.item.ItemStack>
- Direct Known Subclasses:
CompoundFluidIngredient
public class FluidIngredient
extends net.minecraft.world.item.crafting.Ingredient
A fluid ingredient matcher, with fluid tag support. Can also match items; it checks if the item contains the
desired fluid.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class net.minecraft.world.item.crafting.Ingredient
net.minecraft.world.item.crafting.Ingredient.ItemValue, net.minecraft.world.item.crafting.Ingredient.TagValue, net.minecraft.world.item.crafting.Ingredient.Value -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFluidIngredient(List<net.minecraft.world.level.material.Fluid> fluids, int amount, net.minecraft.resources.ResourceLocation fluidId, net.minecraft.tags.TagKey<net.minecraft.world.level.material.Fluid> fluidTagKey, net.minecraft.nbt.CompoundTag nbt, boolean fuzzyNBT) -
Method Summary
Modifier and TypeMethodDescriptionintprotected Collection<net.minecraft.world.level.material.Fluid>List<net.minecraftforge.fluids.FluidStack>net.minecraft.world.item.ItemStack[]getItems()net.minecraftforge.common.crafting.IIngredientSerializer<? extends net.minecraft.world.item.crafting.Ingredient>booleanisEmpty()static FluidIngredientof(int amount, net.minecraft.nbt.CompoundTag nbt, boolean fuzzyNBT, net.minecraft.resources.ResourceLocation fluidId) Create a fluid ingredient from the given fluid registry ID.static FluidIngredientof(int amount, net.minecraft.nbt.CompoundTag nbt, boolean fuzzyNBT, net.minecraft.tags.TagKey<net.minecraft.world.level.material.Fluid> fluidTag) Create a fluid ingredient from the given fluid tagstatic FluidIngredientof(int amount, net.minecraft.nbt.CompoundTag nbt, boolean fuzzyNBT, net.minecraft.world.level.material.Fluid... fluids) Create a fluid ingredient from the given list of fluidsstatic FluidIngredientof(int amount, net.minecraft.resources.ResourceLocation fluidId) Create a fluid ingredient from the given fluid registry ID.static FluidIngredientof(int amount, net.minecraft.tags.TagKey<net.minecraft.world.level.material.Fluid> fluidTag) Create a fluid ingredient from the given fluid tagstatic FluidIngredientof(int amount, net.minecraft.world.level.material.Fluid... fluids) Create a fluid ingredient from the given list of fluidsstatic FluidIngredientof(net.minecraftforge.fluids.FluidStack fluidStack) Create a fluid ingredient from the given FluidStack.static FluidIngredientofFluidStream(Stream<FluidIngredient> stream) Create a fluid ingredient from the given stream of other fluid ingredients.booleantest(net.minecraft.world.item.ItemStack stack) Test the given item against this ingredient.booleantestFluid(net.minecraft.world.level.material.Fluid fluid) Test the given fluid against this ingredient.booleantestFluid(net.minecraftforge.fluids.FluidStack fluidStack) Test the given fluid stack against this ingredient.com.google.gson.JsonElementtoJson()Methods inherited from class net.minecraft.world.item.crafting.Ingredient
checkInvalidation, fromJson, fromNetwork, fromValues, getStackingIds, invalidate, invalidateAll, isSimple, isVanilla, markValid, merge, of, of, of, of, of, toNetwork, valueFromJson
-
Field Details
-
EMPTY
-
-
Constructor Details
-
FluidIngredient
protected FluidIngredient(List<net.minecraft.world.level.material.Fluid> fluids, int amount, net.minecraft.resources.ResourceLocation fluidId, net.minecraft.tags.TagKey<net.minecraft.world.level.material.Fluid> fluidTagKey, net.minecraft.nbt.CompoundTag nbt, boolean fuzzyNBT)
-
-
Method Details
-
of
Create a fluid ingredient from the given FluidStack. If the FluidStack has any NBT, this will also be required as an ingredient match, in a non-fuzzy way (exact match of all fields required).- Parameters:
fluidStack- the fluidstack to match against- Returns:
- the fluid ingredient
-
of
public static FluidIngredient of(int amount, @Nullable net.minecraft.nbt.CompoundTag nbt, boolean fuzzyNBT, net.minecraft.world.level.material.Fluid... fluids) Create a fluid ingredient from the given list of fluids- Parameters:
amount- the amount, in mBnbt- the NBT, or null for no NBT matchingfuzzyNBT- true for a fuzzy match (only fields in the ingredient will be matched), false for an exact match. Ignored if the nbt parameter is null.fluids- the list of fluids- Returns:
- the fluid ingredient
-
of
Create a fluid ingredient from the given list of fluids- Parameters:
amount- the amount, in mBfluids- the list of fluids- Returns:
- the fluid ingredient
-
of
public static FluidIngredient of(int amount, @Nullable net.minecraft.nbt.CompoundTag nbt, boolean fuzzyNBT, net.minecraft.tags.TagKey<net.minecraft.world.level.material.Fluid> fluidTag) Create a fluid ingredient from the given fluid tag- Parameters:
amount- the amount, in mBnbt- the NBT, or null for no NBT matchingfuzzyNBT- true for a fuzzy match (only fields in the ingredient will be matched), false for an exact match. Ignored if the nbt parameter is null.fluidTag- the fluid tag- Returns:
- the fluid ingredient
-
of
public static FluidIngredient of(int amount, net.minecraft.tags.TagKey<net.minecraft.world.level.material.Fluid> fluidTag) Create a fluid ingredient from the given fluid tag- Parameters:
amount- the amount, in mBfluidTag- the fluid tag- Returns:
- the fluid ingredient
-
of
public static FluidIngredient of(int amount, @Nullable net.minecraft.nbt.CompoundTag nbt, boolean fuzzyNBT, net.minecraft.resources.ResourceLocation fluidId) Create a fluid ingredient from the given fluid registry ID. Use this if the fluid might not exist at runtime (e.g. it's from another mod which may or may not be loaded). If the fluid does not exist at runtime, this ingredient will never match anything.- Parameters:
amount- the amount, in mBnbt- the NBT, or null for no NBT matchingfuzzyNBT- true for a fuzzy match (only fields in the ingredient will be matched), false for an exact match. Ignored if the nbt parameter is null.fluidId- the fluid's registry ID- Returns:
- the fluid ingredient
-
of
Create a fluid ingredient from the given fluid registry ID. Use this if the fluid might not exist at runtime (e.g. it's from another mod which may or may not be loaded). If the fluid does not exist at runtime, this ingredient will never match anything.- Parameters:
amount- the amount, in mBfluidId- the fluid's registry ID- Returns:
- the fluid ingredient
-
ofFluidStream
Create a fluid ingredient from the given stream of other fluid ingredients. This new compound ingredient is effectively a logical OR of all the constituent ingredients.- Parameters:
stream- a stream of ingredients- Returns:
- the fluid ingredient
- API Note:
- this method is called "ofFluidStream" rather than "of" to avoid confusion with
Ingredient.of(Stream)
-
getFluidList
-
isEmpty
public boolean isEmpty()- Overrides:
isEmptyin classnet.minecraft.world.item.crafting.Ingredient
-
test
public boolean test(@Nullable net.minecraft.world.item.ItemStack stack) Test the given item against this ingredient. The item must be a fluid container item (providing theCapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITYcapability) containing fluid which matches this ingredient, AND it must be a container item (IForgeItem.hasCraftingRemainingItem(ItemStack)must return true). -
getItems
public net.minecraft.world.item.ItemStack[] getItems()- Overrides:
getItemsin classnet.minecraft.world.item.crafting.Ingredient
-
testFluid
public boolean testFluid(net.minecraftforge.fluids.FluidStack fluidStack) Test the given fluid stack against this ingredient. The fluid must match, and the fluid stack amount must be at least as large. In addition, if the ingredient specifies any NBT, that must also match.- Parameters:
fluidStack- the fluid stack to test- Returns:
- true if the fluid stack matches, false otherwise
-
testFluid
public boolean testFluid(net.minecraft.world.level.material.Fluid fluid) Test the given fluid against this ingredient. Just a fluid match; no amount or NBT matching is done.- Parameters:
fluid- the fluid to test- Returns:
- true if the fluid matches, false otherwise
-
toJson
public com.google.gson.JsonElement toJson()- Overrides:
toJsonin classnet.minecraft.world.item.crafting.Ingredient
-
getSerializer
public net.minecraftforge.common.crafting.IIngredientSerializer<? extends net.minecraft.world.item.crafting.Ingredient> getSerializer()- Overrides:
getSerializerin classnet.minecraft.world.item.crafting.Ingredient
-
getAmount
public int getAmount() -
getFluidStacks
-