Class DataComponentFluidIngredient
java.lang.Object
net.neoforged.neoforge.fluids.crafting.FluidIngredient
net.neoforged.neoforge.fluids.crafting.DataComponentFluidIngredient
- All Implemented Interfaces:
Predicate<FluidStack>
Fluid ingredient that matches the given set of fluids, additionally performing either a
strict
or partial test on the FluidStack's components.
Strict ingredients will only match fluid stacks that have exactly the provided components, while partial ones will match if the stack's components contain all required components for the input predicate.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec
<DataComponentFluidIngredient> private final DataComponentPredicate
private final FluidStack[]
private final boolean
Fields inherited from class net.neoforged.neoforge.fluids.crafting.FluidIngredient
CODEC_NON_EMPTY, LIST_CODEC, LIST_CODEC_NON_EMPTY, MAP_CODEC_NONEMPTY, STREAM_CODEC
-
Constructor Summary
ConstructorDescriptionDataComponentFluidIngredient
(HolderSet<Fluid> fluids, DataComponentPredicate components, boolean strict) -
Method Summary
Modifier and TypeMethodDescriptionboolean
fluids()
Generates a stream of all fluid stacks this ingredient matches against.getType()
Returns The type of this fluid ingredient..int
hashCode()
boolean
isSimple()
Returns whether this fluid ingredient always requires direct stack testing.boolean
isStrict()
static <T> FluidIngredient
of
(boolean strict, Supplier<? extends DataComponentType<? super T>> type, T value, Fluid... fluids) Creates a new ingredient matching any fluid from the list, containing the given componentsstatic FluidIngredient
of
(boolean strict, DataComponentMap map, Holder<Fluid>... fluids) Creates a new ingredient matching any fluid from the list, containing the given componentsstatic FluidIngredient
of
(boolean strict, DataComponentMap map, HolderSet<Fluid> fluids) Creates a new ingredient matching any fluid from the list, containing the given componentsstatic FluidIngredient
of
(boolean strict, DataComponentMap map, Fluid... fluids) Creates a new ingredient matching any fluid from the list, containing the given componentsstatic FluidIngredient
of
(boolean strict, DataComponentPredicate predicate, Holder<Fluid>... fluids) Creates a new ingredient matching any fluid from the list, containing the given componentsstatic FluidIngredient
of
(boolean strict, DataComponentPredicate predicate, HolderSet<Fluid> fluids) Creates a new ingredient matching any fluid from the list, containing the given componentsstatic FluidIngredient
of
(boolean strict, DataComponentPredicate predicate, Fluid... fluids) Creates a new ingredient matching any fluid from the list, containing the given componentsstatic <T> FluidIngredient
of
(boolean strict, DataComponentType<? super T> type, T value, Fluid... fluids) Creates a new ingredient matching any fluid from the list, containing the given componentsstatic FluidIngredient
of
(boolean strict, FluidStack stack) Creates a new ingredient matching the given fluid, containing the given componentsboolean
test
(FluidStack stack) Checks if a given fluid stack matches this ingredient.Methods inherited from class net.neoforged.neoforge.fluids.crafting.FluidIngredient
empty, getStacks, hasNoFluids, isEmpty, of, of, of, single, single, single, tag
-
Field Details
-
CODEC
-
fluids
-
components
-
strict
private final boolean strict -
stacks
-
-
Constructor Details
-
DataComponentFluidIngredient
public DataComponentFluidIngredient(HolderSet<Fluid> fluids, DataComponentPredicate components, boolean strict)
-
-
Method Details
-
test
Description copied from class:FluidIngredient
Checks if a given fluid stack matches this ingredient. The stack must not be modified in any way.- Specified by:
test
in interfacePredicate<FluidStack>
- Specified by:
test
in classFluidIngredient
- Parameters:
stack
- the stack to test- Returns:
true
if the stack matches,false
otherwise
-
generateStacks
Description copied from class:FluidIngredient
Generates a stream of all fluid stacks this ingredient matches against.For compatibility reasons, implementations should follow the same guidelines as for custom item ingredients, i.e.:
- These stacks are generally used for display purposes, and need not be exhaustive or perfectly accurate.
- An exception is ingredients that are simple,
for which it is important that the returned stacks correspond exactly to all the accepted
Fluid
s. - At least one stack should always be returned, otherwise the ingredient may be considered accidentally empty.
- The ingredient should try to return at least one stack with each accepted
Fluid
. This allows mods that inspect the ingredient to figure out which stacks it might accept.
- Specified by:
generateStacks
in classFluidIngredient
- Returns:
- a stream of all fluid stacks this ingredient accepts.
Note: No guarantees are made as to the amount of the fluid, as FluidIngredients are generally not meant to match by amount and these stacks are mostly used for display.
- See Also:
-
isSimple
public boolean isSimple()Description copied from class:FluidIngredient
Returns whether this fluid ingredient always requires direct stack testing.- Specified by:
isSimple
in classFluidIngredient
- Returns:
true
if this ingredient ignores NBT data when matching stacks,false
otherwise- See Also:
-
getType
Description copied from class:FluidIngredient
Returns The type of this fluid ingredient..The type must be registered to
NeoForgeRegistries.FLUID_INGREDIENT_TYPES
.- Specified by:
getType
in classFluidIngredient
- Returns:
- The type of this fluid ingredient.
-
hashCode
public int hashCode()- Specified by:
hashCode
in classFluidIngredient
-
equals
- Specified by:
equals
in classFluidIngredient
-
fluids
-
components
-
isStrict
public boolean isStrict() -
of
Creates a new ingredient matching the given fluid, containing the given components -
of
public static <T> FluidIngredient of(boolean strict, DataComponentType<? super T> type, T value, Fluid... fluids) Creates a new ingredient matching any fluid from the list, containing the given components -
of
public static <T> FluidIngredient of(boolean strict, Supplier<? extends DataComponentType<? super T>> type, T value, Fluid... fluids) Creates a new ingredient matching any fluid from the list, containing the given components -
of
Creates a new ingredient matching any fluid from the list, containing the given components -
of
@SafeVarargs public static FluidIngredient of(boolean strict, DataComponentMap map, Holder<Fluid>... fluids) Creates a new ingredient matching any fluid from the list, containing the given components -
of
Creates a new ingredient matching any fluid from the list, containing the given components -
of
@SafeVarargs public static FluidIngredient of(boolean strict, DataComponentPredicate predicate, Holder<Fluid>... fluids) Creates a new ingredient matching any fluid from the list, containing the given components -
of
Creates a new ingredient matching any fluid from the list, containing the given components -
of
public static FluidIngredient of(boolean strict, DataComponentPredicate predicate, HolderSet<Fluid> fluids) Creates a new ingredient matching any fluid from the list, containing the given components
-