Class Chromosome<V>

java.lang.Object
forestry.api.core.genetics.alleles.Chromosome<V>
All Implemented Interfaces:
IChromosome<V>

public final class Chromosome<V> extends Object implements IChromosome<V>
The single, generic chromosome implementation. Replaces the former float/integer/boolean/value/registry subtypes. Data chromosomes have a null resolver; reference chromosomes store a ResourceLocation and resolve it to a behavior object lazily via the resolver.
  • Constructor Details

  • Method Details

    • id

      public net.minecraft.resources.ResourceLocation id()
      Specified by:
      id in interface IChromosome<V>
      Returns:
      Unique ID for this chromosome.
    • valueCodec

      public com.mojang.serialization.Codec<V> valueCodec()
      Specified by:
      valueCodec in interface IChromosome<V>
      Returns:
      Codec for the value stored inline in the genome. Reference chromosomes encode a ResourceLocation.
    • valueStreamCodec

      public net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,V> valueStreamCodec()
      Specified by:
      valueStreamCodec in interface IChromosome<V>
      Returns:
      Stream codec for the value, used to sync genomes over the network.
    • chromosomeTranslationKey

      public String chromosomeTranslationKey()
      Specified by:
      chromosomeTranslationKey in interface IChromosome<V>
      Returns:
      The translation key for the name of this chromosome (e.g. "chromosome.forestry.speed").
    • translationKey

      public String translationKey(V value)
      Description copied from interface: IChromosome
      The naming rule for values of this chromosome. Returns a translation key only; never a Component. Consumers build components at the UI edge, falling back to the raw value when the key has no translation.
      Specified by:
      translationKey in interface IChromosome<V>
      Returns:
      A translation key naming the given value.
    • resolver

      @Nullable public IChromosome.IReferenceResolver<?> resolver()
      Specified by:
      resolver in interface IChromosome<V>
      Returns:
      The id-to-object resolver for reference chromosomes, or null for data chromosomes.
    • toString

      public String toString()
      Overrides:
      toString in class Object