Class SizedFluidIngredient

java.lang.Object
net.neoforged.neoforge.fluids.crafting.SizedFluidIngredient

public final class SizedFluidIngredient extends Object
Standard implementation for a FluidIngredient with an amount.

FluidIngredient, like its item counterpart, explicitly does not perform count checks, so this class is used to (a) wrap a standard FluidIngredient with an amount and (b) provide a standard serialization format for mods to use.

See Also:
  • Field Details

    • CODEC

      public static final com.mojang.serialization.Codec<SizedFluidIngredient> CODEC
      The codec for SizedFluidIngredient.

      With this codec, the amount is serialized separately from the ingredient itself, for example:

      {
          "ingredient": "minecraft:lava",
          "amount": 1000
      }
      

      or for custom ingredients:

      {
          "ingredient": {
              "neoforge:type": "neoforge:intersection",
              "children": [
                   "#example:tag1",
                   "#example:tag2"
              ],
          },
          "amount": 4711
      }
      
    • STREAM_CODEC

      public static final StreamCodec<RegistryFriendlyByteBuf, SizedFluidIngredient> STREAM_CODEC
    • ingredient

      private final FluidIngredient ingredient
    • amount

      private final int amount
  • Constructor Details

    • SizedFluidIngredient

      public SizedFluidIngredient(FluidIngredient ingredient, int amount)
  • Method Details

    • of

      public static SizedFluidIngredient of(Fluid fluid, int amount)
    • ingredient

      public FluidIngredient ingredient()
    • amount

      public int amount()
    • test

      public boolean test(FluidStack stack)
      Performs a size-sensitive test on the given stack.
      Returns:
      true if the stack matches the ingredient and has at least the required amount.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object