Record Class Allele<V>
java.lang.Object
java.lang.Record
forestry.api.core.genetics.alleles.Allele<V>
- Type Parameters:
V- The type of value held by this allele.- Record Components:
value- The value held by this allele.dominant- Whether this allele is dominant.
An allele is a single inline value of a chromosome, together with its dominance.
Alleles are plain data: they are not interned, have no ID, and are not stored in any registry. A genome stores
AllelePair of these directly, serialized inline via each chromosome's value codec. For "reference"
chromosomes (species, flower type, bee effect, activity, fruit, tree effect, cocoon, butterfly effect) the value
is the referenced object's ResourceLocation; the behavior object is resolved on
demand through IChromosome.resolver().
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <V> com.mojang.serialization.Codec<Allele<V>> codec(com.mojang.serialization.Codec<V> valueCodec) booleandominant()Returns the value of thedominantrecord component.static <V> Allele<V> dominant(V value) final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.static <V> Allele<V> of(V value, boolean dominant) static <V> Allele<V> recessive(V value) static Allele<net.minecraft.resources.ResourceLocation> reference(net.minecraft.resources.ResourceLocation id) Creates an allele for a reference chromosome from the referenced value's ID.static <V> net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf, Allele<V>> streamCodec(net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf, V> valueStreamCodec) final StringtoString()Returns a string representation of this record class.value()Returns the value of thevaluerecord component.
-
Constructor Details
-
Method Details
-
dominant
-
recessive
-
of
-
reference
public static Allele<net.minecraft.resources.ResourceLocation> reference(net.minecraft.resources.ResourceLocation id) Creates an allele for a reference chromosome from the referenced value's ID. The dominance is a placeholder: a reference value's dominance is intrinsic to the value, so it is resolved from the chromosome's resolver when the genome is materialized (e.g. in). Use this for genome overrides built before registries are populated, such as hive drops or village bees.invalid reference
IGenome#copyWith -
codec
public static <V> com.mojang.serialization.Codec<Allele<V>> codec(com.mojang.serialization.Codec<V> valueCodec) - Returns:
- A codec for a single allele, serializing its value inline via the given value codec as
{ "value": ..., "dominant": false }(dominance defaults to false when omitted).
-
streamCodec
public static <V> net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,Allele<V>> streamCodec(net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf, V> valueStreamCodec) - Returns:
- A stream codec for a single allele: its value (via the given value stream codec) followed by a boolean dominance flag.
-
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
value
Returns the value of thevaluerecord component.- Returns:
- the value of the
valuerecord component
-
dominant
public boolean dominant()Returns the value of thedominantrecord component.- Returns:
- the value of the
dominantrecord component
-