Package com.minecolonies.core.recipes
Record Class FoodIngredient
java.lang.Object
java.lang.Record
com.minecolonies.core.recipes.FoodIngredient
- Record Components:
minHealing- minimum healing valuemaxHealing- maximum healing valueminSaturation- minimum saturation valuemaxSaturation- 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.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic FoodIngredient.Builderbuilder()final booleanIndicates whether some other object is "equal to" this one.@NotNull Stream<net.minecraft.world.item.ItemStack> getItems()@NotNull net.neoforged.neoforge.common.crafting.IngredientType<?> getType()final inthashCode()Returns a hash code value for this object.booleanisSimple()Returns the value of themaxHealingrecord component.Returns the value of themaxSaturationrecord component.Returns the value of theminHealingrecord component.Returns the value of theminSaturationrecord component.booleantest(@Nullable net.minecraft.world.item.ItemStack stack) final StringtoString()Returns a string representation of this record class.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.neoforged.neoforge.common.crafting.ICustomIngredient
toVanilla
-
Field Details
-
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 aFoodIngredientrecord class.- Parameters:
minHealing- the value for theminHealingrecord componentmaxHealing- the value for themaxHealingrecord componentminSaturation- the value for theminSaturationrecord componentmaxSaturation- the value for themaxSaturationrecord component
-
-
Method Details
-
builder
-
test
public boolean test(@Nullable @Nullable net.minecraft.world.item.ItemStack stack) - Specified by:
testin interfacenet.neoforged.neoforge.common.crafting.ICustomIngredient
-
getItems
- Specified by:
getItemsin interfacenet.neoforged.neoforge.common.crafting.ICustomIngredient
-
isSimple
public boolean isSimple()- Specified by:
isSimplein interfacenet.neoforged.neoforge.common.crafting.ICustomIngredient
-
getType
@NotNull public @NotNull net.neoforged.neoforge.common.crafting.IngredientType<?> getType()- Specified by:
getTypein interfacenet.neoforged.neoforge.common.crafting.ICustomIngredient
-
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
minHealing
Returns the value of theminHealingrecord component.- Returns:
- the value of the
minHealingrecord component
-
maxHealing
Returns the value of themaxHealingrecord component.- Returns:
- the value of the
maxHealingrecord component
-
minSaturation
Returns the value of theminSaturationrecord component.- Returns:
- the value of the
minSaturationrecord component
-
maxSaturation
Returns the value of themaxSaturationrecord component.- Returns:
- the value of the
maxSaturationrecord component
-