Class Chromosome<V>
java.lang.Object
forestry.api.core.genetics.alleles.Chromosome<V>
- All Implemented Interfaces:
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.-
Nested Class Summary
Nested classes/interfaces inherited from interface forestry.api.core.genetics.alleles.IChromosome
IChromosome.IReferenceResolver<R> -
Constructor Summary
ConstructorsConstructorDescriptionChromosome(net.minecraft.resources.ResourceLocation id, com.mojang.serialization.Codec<V> valueCodec, Function<V, String> naming, IChromosome.IReferenceResolver<?> resolver) -
Method Summary
-
Constructor Details
-
Chromosome
public Chromosome(net.minecraft.resources.ResourceLocation id, com.mojang.serialization.Codec<V> valueCodec, Function<V, String> naming, @Nullable IChromosome.IReferenceResolver<?> resolver)
-
-
Method Details
-
id
public net.minecraft.resources.ResourceLocation id()- Specified by:
idin interfaceIChromosome<V>- Returns:
- Unique ID for this chromosome.
-
valueCodec
- Specified by:
valueCodecin interfaceIChromosome<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:
valueStreamCodecin interfaceIChromosome<V>- Returns:
- Stream codec for the value, used to sync genomes over the network.
-
chromosomeTranslationKey
- Specified by:
chromosomeTranslationKeyin interfaceIChromosome<V>- Returns:
- The translation key for the name of this chromosome (e.g. "chromosome.forestry.speed").
-
translationKey
Description copied from interface:IChromosomeThe naming rule for values of this chromosome. Returns a translation key only; never aComponent. Consumers build components at the UI edge, falling back to the raw value when the key has no translation.- Specified by:
translationKeyin interfaceIChromosome<V>- Returns:
- A translation key naming the given value.
-
resolver
- Specified by:
resolverin interfaceIChromosome<V>- Returns:
- The id-to-object resolver for reference chromosomes, or
nullfor data chromosomes.
-
toString
-