Class DataComponentFluidIngredient

java.lang.Object
net.neoforged.neoforge.fluids.crafting.FluidIngredient
net.neoforged.neoforge.fluids.crafting.DataComponentFluidIngredient
All Implemented Interfaces:
Predicate<FluidStack>

public class DataComponentFluidIngredient extends FluidIngredient
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

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.MapCodec<DataComponentFluidIngredient>
     
    private final net.minecraft.core.component.DataComponentExactPredicate
     
    private final net.minecraft.core.HolderSet<net.minecraft.world.level.material.Fluid>
     
    private final FluidStack[]
     
    private final boolean
     

    Fields inherited from class net.neoforged.neoforge.fluids.crafting.FluidIngredient

    OPTIONAL_STREAM_CODEC, STREAM_CODEC
  • Constructor Summary

    Constructors
    Constructor
    Description
    DataComponentFluidIngredient(net.minecraft.core.HolderSet<net.minecraft.world.level.material.Fluid> fluids, net.minecraft.core.component.DataComponentExactPredicate components, boolean strict)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    net.minecraft.core.component.DataComponentExactPredicate
     
    net.minecraft.world.item.crafting.display.SlotDisplay
    Returns a slot display for this ingredient, used for display on the client-side.
    boolean
     
    net.minecraft.core.HolderSet<net.minecraft.world.level.material.Fluid>
     
    Stream<net.minecraft.core.Holder<net.minecraft.world.level.material.Fluid>>
    Returns a stream of fluids accepted by this ingredient.
    Returns The type of this fluid ingredient..
    int
     
    boolean
    Returns whether this fluid ingredient always requires direct stack testing.
    boolean
     
    static <T> FluidIngredient
    of(boolean strict, Supplier<? extends net.minecraft.core.component.DataComponentType<? super T>> type, T value, net.minecraft.world.level.material.Fluid... fluids)
    Creates a new ingredient matching any fluid from the list, containing the given components
    of(boolean strict, net.minecraft.core.component.DataComponentExactPredicate predicate, net.minecraft.core.Holder<net.minecraft.world.level.material.Fluid>... fluids)
    Creates a new ingredient matching any fluid from the list, containing the given components
    of(boolean strict, net.minecraft.core.component.DataComponentExactPredicate predicate, net.minecraft.core.HolderSet<net.minecraft.world.level.material.Fluid> fluids)
    Creates a new ingredient matching any fluid from the list, containing the given components
    of(boolean strict, net.minecraft.core.component.DataComponentExactPredicate predicate, net.minecraft.world.level.material.Fluid... fluids)
    Creates a new ingredient matching any fluid from the list, containing the given components
    of(boolean strict, net.minecraft.core.component.DataComponentMap map, net.minecraft.core.Holder<net.minecraft.world.level.material.Fluid>... fluids)
    Creates a new ingredient matching any fluid from the list, containing the given components
    of(boolean strict, net.minecraft.core.component.DataComponentMap map, net.minecraft.core.HolderSet<net.minecraft.world.level.material.Fluid> fluids)
    Creates a new ingredient matching any fluid from the list, containing the given components
    of(boolean strict, net.minecraft.core.component.DataComponentMap map, net.minecraft.world.level.material.Fluid... fluids)
    Creates a new ingredient matching any fluid from the list, containing the given components
    static <T> FluidIngredient
    of(boolean strict, net.minecraft.core.component.DataComponentType<? super T> type, T value, net.minecraft.world.level.material.Fluid... fluids)
    Creates a new ingredient matching any fluid from the list, containing the given components
    of(boolean strict, FluidStack stack)
    Creates a new ingredient matching the given fluid, containing the given components
    boolean
    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

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.util.function.Predicate

    and, negate, or
  • Field Details

    • CODEC

      public static final com.mojang.serialization.MapCodec<DataComponentFluidIngredient> CODEC
    • fluids

      private final net.minecraft.core.HolderSet<net.minecraft.world.level.material.Fluid> fluids
    • components

      private final net.minecraft.core.component.DataComponentExactPredicate components
    • strict

      private final boolean strict
    • stacks

      private final FluidStack[] stacks
  • Constructor Details

    • DataComponentFluidIngredient

      public DataComponentFluidIngredient(net.minecraft.core.HolderSet<net.minecraft.world.level.material.Fluid> fluids, net.minecraft.core.component.DataComponentExactPredicate components, boolean strict)
  • Method Details

    • test

      public boolean test(FluidStack stack)
      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 interface Predicate<FluidStack>
      Specified by:
      test in class FluidIngredient
      Parameters:
      stack - the stack to test
      Returns:
      true if the stack matches, false otherwise
    • generateFluids

      public Stream<net.minecraft.core.Holder<net.minecraft.world.level.material.Fluid>> generateFluids()
      Description copied from class: FluidIngredient
      Returns 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:
      generateFluids in class FluidIngredient
      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

      public net.minecraft.world.item.crafting.display.SlotDisplay display()
      Description copied from class: FluidIngredient
      Returns a slot display for this ingredient, used for display on the client-side.
      Overrides:
      display in class FluidIngredient
      Returns:
      a slot display for this ingredient, used for display on the client-side
      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 class FluidIngredient
      Returns:
      true if this ingredient ignores NBT data when matching stacks, false otherwise
      See Also:
    • getType

      public FluidIngredientType<?> 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 class FluidIngredient
      Returns:
      The type of this fluid ingredient.
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in class FluidIngredient
    • equals

      public boolean equals(Object obj)
      Specified by:
      equals in class FluidIngredient
    • fluidSet

      public net.minecraft.core.HolderSet<net.minecraft.world.level.material.Fluid> fluidSet()
    • components

      public net.minecraft.core.component.DataComponentExactPredicate components()
    • isStrict

      public boolean isStrict()
    • of

      public static FluidIngredient of(boolean strict, FluidStack stack)
      Creates a new ingredient matching the given fluid, containing the given components
    • of

      public static <T> FluidIngredient of(boolean strict, net.minecraft.core.component.DataComponentType<? super T> type, T value, net.minecraft.world.level.material.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 net.minecraft.core.component.DataComponentType<? super T>> type, T value, net.minecraft.world.level.material.Fluid... fluids)
      Creates a new ingredient matching any fluid from the list, containing the given components
    • of

      public static FluidIngredient of(boolean strict, net.minecraft.core.component.DataComponentMap map, net.minecraft.world.level.material.Fluid... fluids)
      Creates a new ingredient matching any fluid from the list, containing the given components
    • of

      @SafeVarargs public static FluidIngredient of(boolean strict, net.minecraft.core.component.DataComponentMap map, net.minecraft.core.Holder<net.minecraft.world.level.material.Fluid>... fluids)
      Creates a new ingredient matching any fluid from the list, containing the given components
    • of

      public static FluidIngredient of(boolean strict, net.minecraft.core.component.DataComponentMap map, net.minecraft.core.HolderSet<net.minecraft.world.level.material.Fluid> fluids)
      Creates a new ingredient matching any fluid from the list, containing the given components
    • of

      @SafeVarargs public static FluidIngredient of(boolean strict, net.minecraft.core.component.DataComponentExactPredicate predicate, net.minecraft.core.Holder<net.minecraft.world.level.material.Fluid>... fluids)
      Creates a new ingredient matching any fluid from the list, containing the given components
    • of

      public static FluidIngredient of(boolean strict, net.minecraft.core.component.DataComponentExactPredicate predicate, net.minecraft.world.level.material.Fluid... fluids)
      Creates a new ingredient matching any fluid from the list, containing the given components
    • of

      public static FluidIngredient of(boolean strict, net.minecraft.core.component.DataComponentExactPredicate predicate, net.minecraft.core.HolderSet<net.minecraft.world.level.material.Fluid> fluids)
      Creates a new ingredient matching any fluid from the list, containing the given components