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
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec<DataComponentFluidIngredient> private final DataComponentExactPredicateprivate final FluidStack[]private final booleanFields inherited from class net.neoforged.neoforge.fluids.crafting.FluidIngredient
OPTIONAL_STREAM_CODEC, STREAM_CODEC -
Constructor Summary
ConstructorsConstructorDescriptionDataComponentFluidIngredient(HolderSet<Fluid> fluids, DataComponentExactPredicate components, boolean strict) -
Method Summary
Modifier and TypeMethodDescriptiondisplay()Returns a slot display for this ingredient, used for display on the client-side.booleanfluidSet()Returns a stream of fluids accepted by this ingredient.getType()Returns The type of this fluid ingredient..inthashCode()booleanisSimple()Returns whether this fluid ingredient always requires direct stack testing.booleanisStrict()static <T> FluidIngredientof(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 FluidIngredientof(boolean strict, DataComponentExactPredicate predicate, Holder<Fluid>... fluids) Creates a new ingredient matching any fluid from the list, containing the given componentsstatic FluidIngredientof(boolean strict, DataComponentExactPredicate predicate, HolderSet<Fluid> fluids) Creates a new ingredient matching any fluid from the list, containing the given componentsstatic FluidIngredientof(boolean strict, DataComponentExactPredicate predicate, Fluid... fluids) Creates a new ingredient matching any fluid from the list, containing the given componentsstatic FluidIngredientof(boolean strict, DataComponentMap map, Holder<Fluid>... fluids) Creates a new ingredient matching any fluid from the list, containing the given componentsstatic FluidIngredientof(boolean strict, DataComponentMap map, HolderSet<Fluid> fluids) Creates a new ingredient matching any fluid from the list, containing the given componentsstatic FluidIngredientof(boolean strict, DataComponentMap map, Fluid... fluids) Creates a new ingredient matching any fluid from the list, containing the given componentsstatic <T> FluidIngredientof(boolean strict, DataComponentType<? super T> type, T value, Fluid... fluids) Creates a new ingredient matching any fluid from the list, containing the given componentsstatic FluidIngredientof(boolean strict, FluidStack stack) Creates a new ingredient matching the given fluid, containing the given componentsbooleantest(FluidStack stack) Checks if a given fluid stack matches this ingredient.Methods inherited from class net.neoforged.neoforge.fluids.crafting.FluidIngredient
displayForSingleFluid, fluids, of, of, of, of
-
Field Details
-
CODEC
-
fluids
-
components
-
strict
private final boolean strict -
stacks
-
-
Constructor Details
-
DataComponentFluidIngredient
public DataComponentFluidIngredient(HolderSet<Fluid> fluids, DataComponentExactPredicate components, boolean strict)
-
-
Method Details
-
test
Description copied from class:FluidIngredientChecks if a given fluid stack matches this ingredient. The stack must not be modified in any way.- Specified by:
testin interfacePredicate<FluidStack>- Specified by:
testin classFluidIngredient- Parameters:
stack- the stack to test- Returns:
trueif the stack matches,falseotherwise
-
generateFluids
Description copied from class:FluidIngredientReturns a stream of fluids accepted by this ingredient.For compatibility reasons, implementations should follow the same guidelines as for custom item ingredients, i.e.:
- Returned fluids are generally used for display purposes, and need not be exhaustive or perfectly accurate, as ingredients may additionally filter by e.g. data component values.
- An exception is ingredients that are simple,
for which it is important that this stream corresponds exactly all fluids accepted by
FluidIngredient.test(FluidStack)! - At least one stack should always be returned, so that the ingredient is not considered empty. Empty ingredients may invalidate recipes!
Note: no caching needs to be done by the implementation, this is already handled by
FluidIngredient.fluids!- Specified by:
generateFluidsin 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:
-
display
Description copied from class:FluidIngredientReturns a slot display for this ingredient, used for display on the client-side.- Overrides:
displayin classFluidIngredient- Returns:
- a slot display for this ingredient, used for display on the client-side
- See Also:
-
isSimple
public boolean isSimple()Description copied from class:FluidIngredientReturns whether this fluid ingredient always requires direct stack testing.- Specified by:
isSimplein classFluidIngredient- Returns:
trueif this ingredient ignores NBT data when matching stacks,falseotherwise- See Also:
-
getType
Description copied from class:FluidIngredientReturns The type of this fluid ingredient..The type must be registered to
NeoForgeRegistries.FLUID_INGREDIENT_TYPES.- Specified by:
getTypein classFluidIngredient- Returns:
- The type of this fluid ingredient.
-
hashCode
public int hashCode()- Specified by:
hashCodein classFluidIngredient
-
equals
- Specified by:
equalsin classFluidIngredient
-
fluidSet
-
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, DataComponentExactPredicate predicate, Holder<Fluid>... fluids) Creates a new ingredient matching any fluid from the list, containing the given components -
of
public static FluidIngredient of(boolean strict, DataComponentExactPredicate predicate, Fluid... fluids) Creates a new ingredient matching any fluid from the list, containing the given components -
of
public static FluidIngredient of(boolean strict, DataComponentExactPredicate predicate, HolderSet<Fluid> fluids) Creates a new ingredient matching any fluid from the list, containing the given components
-