Class ChromosomeFactory

java.lang.Object
forestry.api.core.genetics.alleles.ChromosomeFactory

public final class ChromosomeFactory extends Object
Factory for the generic Chromosome. Replaces the chromosome-creation methods of the old IAlleleManager. Chromosomes are plain singletons created in the chromosome holder classes (BeeChromosomes, TreeChromosomes, ...).
  • Method Details

    • floatChromosome

      public static IChromosome<Float> floatChromosome(net.minecraft.resources.ResourceLocation id)
    • intChromosome

      public static IChromosome<Integer> intChromosome(net.minecraft.resources.ResourceLocation id)
    • booleanChromosome

      public static IChromosome<Boolean> booleanChromosome(net.minecraft.resources.ResourceLocation id)
    • valueChromosome

      public static <V> IChromosome<V> valueChromosome(net.minecraft.resources.ResourceLocation id, com.mojang.serialization.Codec<V> valueCodec, Function<V,String> valueKeyPart)
      A data chromosome holding an enum, record, or other non-primitive value.
      Parameters:
      valueKeyPart - Maps a value to its translation-key suffix (e.g. enum name, "x_y_z" for Vec3i).
    • referenceChromosome

      public static <R> IChromosome<net.minecraft.resources.ResourceLocation> referenceChromosome(net.minecraft.resources.ResourceLocation id, Function<net.minecraft.resources.ResourceLocation,R> get, Predicate<R> dominant)
      A reference chromosome: the genome stores a ResourceLocation, resolved to a behavior object on demand. The translation key reproduces the existing scheme ("allele.<ns>.<chromosome>.<ref path>").
      Parameters:
      get - Resolves an id to its behavior object (lazily, after registries are populated).
      dominant - Reads the default dominance of a resolved value.