Class SimpleFluidIngredient

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

public class SimpleFluidIngredient extends FluidIngredient
Fluid ingredient that matches the fluids specified by the given HolderSet. Most commonly, this will either be a list of fluids or a fluid tag.

Unlike with ingredients, this is technically an explicit "type" of fluid ingredient, though in JSON, it is still written without a type field, see FluidIngredientCodecs.codec()

  • Field Details

    • HOLDER_SET_NO_EMPTY_FLUID

      private static final com.mojang.serialization.Codec<net.minecraft.core.HolderSet<net.minecraft.world.level.material.Fluid>> HOLDER_SET_NO_EMPTY_FLUID
    • CODEC

      static final com.mojang.serialization.Codec<SimpleFluidIngredient> CODEC
    • CONTENTS_STREAM_CODEC

      static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,SimpleFluidIngredient> CONTENTS_STREAM_CODEC
    • values

      private final net.minecraft.core.HolderSet<net.minecraft.world.level.material.Fluid> values
  • Constructor Details

    • SimpleFluidIngredient

      public SimpleFluidIngredient(net.minecraft.core.HolderSet<net.minecraft.world.level.material.Fluid> values)
  • Method Details

    • test

      public boolean test(FluidStack fluidStack)
      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:
      fluidStack - the stack to test
      Returns:
      true if the stack matches, false otherwise
    • generateFluids

      protected 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:
    • 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.
    • 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:
    • 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()