Record Class FoodIngredient

java.lang.Object
java.lang.Record
com.minecolonies.core.recipes.FoodIngredient
Record Components:
minHealing - minimum healing value
maxHealing - maximum healing value
minSaturation - minimum saturation value
maxSaturation - maximum saturation value
All Implemented Interfaces:
net.neoforged.neoforge.common.crafting.ICustomIngredient

public record FoodIngredient(@NotNull Optional<Integer> minHealing, @NotNull Optional<Integer> maxHealing, @NotNull Optional<Float> minSaturation, @NotNull Optional<Float> maxSaturation) extends Record implements net.neoforged.neoforge.common.crafting.ICustomIngredient
An ingredient that can be used in a vanilla recipe to match food items. Only items with at least *some* healing and saturation are counted, and further restrictions can be imposed if desired. // any food item at all { "type": "minecolonies:food" } // any food with at least 4 healing points (inclusive) { "type": "minecolonies:food", "min-healing": 4 } // any food with less than 1.0 saturation points (not including 1.0 itself) { "type": "minecolonies:food", "max-saturation": 1.0 } Conditions can also be combined. Min bounds are inclusive and max bounds are exclusive.
  • Field Details

    • CODEC

      public static final com.mojang.serialization.MapCodec<FoodIngredient> CODEC
  • Constructor Details

    • FoodIngredient

      public FoodIngredient(@NotNull @NotNull Optional<Integer> minHealing, @NotNull @NotNull Optional<Integer> maxHealing, @NotNull @NotNull Optional<Float> minSaturation, @NotNull @NotNull Optional<Float> maxSaturation)
      Creates an instance of a FoodIngredient record class.
      Parameters:
      minHealing - the value for the minHealing record component
      maxHealing - the value for the maxHealing record component
      minSaturation - the value for the minSaturation record component
      maxSaturation - the value for the maxSaturation record component
  • Method Details

    • builder

      public static FoodIngredient.Builder builder()
    • test

      public boolean test(@Nullable @Nullable net.minecraft.world.item.ItemStack stack)
      Specified by:
      test in interface net.neoforged.neoforge.common.crafting.ICustomIngredient
    • getItems

      @NotNull public @NotNull Stream<net.minecraft.world.item.ItemStack> getItems()
      Specified by:
      getItems in interface net.neoforged.neoforge.common.crafting.ICustomIngredient
    • isSimple

      public boolean isSimple()
      Specified by:
      isSimple in interface net.neoforged.neoforge.common.crafting.ICustomIngredient
    • getType

      @NotNull public @NotNull net.neoforged.neoforge.common.crafting.IngredientType<?> getType()
      Specified by:
      getType in interface net.neoforged.neoforge.common.crafting.ICustomIngredient
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • minHealing

      @NotNull public @NotNull Optional<Integer> minHealing()
      Returns the value of the minHealing record component.
      Returns:
      the value of the minHealing record component
    • maxHealing

      @NotNull public @NotNull Optional<Integer> maxHealing()
      Returns the value of the maxHealing record component.
      Returns:
      the value of the maxHealing record component
    • minSaturation

      @NotNull public @NotNull Optional<Float> minSaturation()
      Returns the value of the minSaturation record component.
      Returns:
      the value of the minSaturation record component
    • maxSaturation

      @NotNull public @NotNull Optional<Float> maxSaturation()
      Returns the value of the maxSaturation record component.
      Returns:
      the value of the maxSaturation record component