Record Class Compostable
java.lang.Object
java.lang.Record
net.neoforged.neoforge.registries.datamaps.builtin.Compostable
- Record Components:
chance
- the chance that a compost is successfulcanVillagerCompost
- whether farmer villagers can compost the item
Data map value for compostables.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final boolean
The field for thecanVillagerCompost
record component.private final float
The field for thechance
record component.static final com.mojang.serialization.Codec
<Compostable> static final com.mojang.serialization.Codec
<Compostable> -
Constructor Summary
ConstructorsConstructorDescriptionCompostable
(float chance) Constructs aCompostable
that cannot be composted by farmer villagers.Compostable
(float chance, boolean canVillagerCompost) Creates an instance of aCompostable
record class. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns the value of thecanVillagerCompost
record component.float
chance()
Returns the value of thechance
record component.final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.final String
toString()
Returns a string representation of this record class.
-
Field Details
-
chance
private final float chanceThe field for thechance
record component. -
canVillagerCompost
private final boolean canVillagerCompostThe field for thecanVillagerCompost
record component. -
CHANCE_CODEC
-
CODEC
-
-
Constructor Details
-
Compostable
public Compostable(float chance) Constructs aCompostable
that cannot be composted by farmer villagers.- Parameters:
chance
- the chance that a compost is successful
-
Compostable
public Compostable(float chance, boolean canVillagerCompost) Creates an instance of aCompostable
record class.- Parameters:
chance
- the value for thechance
record componentcanVillagerCompost
- the value for thecanVillagerCompost
record component
-
-
Method Details
-
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 with '=='. -
chance
public float chance()Returns the value of thechance
record component.- Returns:
- the value of the
chance
record component
-
canVillagerCompost
public boolean canVillagerCompost()Returns the value of thecanVillagerCompost
record component.- Returns:
- the value of the
canVillagerCompost
record component
-