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.

public record Allele<V>(V value, boolean dominant) extends Record
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
    Constructor
    Description
    Allele(V value, boolean dominant)
    Creates an instance of a Allele record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <V> com.mojang.serialization.Codec<Allele<V>>
    codec(com.mojang.serialization.Codec<V> valueCodec)
     
    boolean
    Returns the value of the dominant record component.
    static <V> Allele<V>
    dominant(V value)
     
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    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 String
    Returns a string representation of this record class.
    Returns the value of the value record component.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Allele

      public Allele(V value, boolean dominant)
      Creates an instance of a Allele record class.
      Parameters:
      value - the value for the value record component
      dominant - the value for the dominant record component
  • Method Details

    • dominant

      public static <V> Allele<V> dominant(V value)
    • recessive

      public static <V> Allele<V> recessive(V value)
    • of

      public static <V> Allele<V> of(V value, boolean dominant)
    • 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
      invalid reference
      IGenome#copyWith
      ). Use this for genome overrides built before registries are populated, such as hive drops or village bees.
    • 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

      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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      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.
    • value

      public V value()
      Returns the value of the value record component.
      Returns:
      the value of the value record component
    • dominant

      public boolean dominant()
      Returns the value of the dominant record component.
      Returns:
      the value of the dominant record component