Interface ISpeciesType<S extends ISpecies<I>,I extends IIndividual>

Type Parameters:
S - The interface type of the species this type contains.
I - The interface type of individuals who are members of this species type.
All Superinterfaces:
IBreedingTrackerHandler
All Known Subinterfaces:
IBeeSpeciesType, IButterflySpeciesType, ITreeSpeciesType

public interface ISpeciesType<S extends ISpecies<I>,I extends IIndividual> extends IBreedingTrackerHandler
Represents a type of species/individuals. Replaces the old ISpeciesRoot. Register new species types in IForestryPlugin.registerGenetics(forestry.api.plugin.IGeneticRegistration).
  • Method Details

    • id

      net.minecraft.resources.ResourceLocation id()
      Returns:
      The unique ID of this species type.
    • getKaryotype

      IKaryotype getKaryotype()
      Returns:
      The karyotype for all members of this species type.
    • getLifeStage

      @Nullable ILifeStage getLifeStage(net.minecraft.world.item.ItemStack stack)
      Returns:
      The life stage of the individual contained in the item, or null if the item is not valid.
    • getMutations

      IMutationManager<S> getMutations()
      Returns:
      The mutation manager for this species type.
      Throws:
      IllegalStateException - If not all mutations have been registered.
    • getAllSpecies

      List<S> getAllSpecies()
      Returns:
      The list of all members of this species type.
      Throws:
      IllegalStateException - If not all species have been registered yet.
    • getSpecies

      S getSpecies(net.minecraft.resources.ResourceLocation id)
      Returns:
      The species of this type registered with the given ID.
      Throws:
      RuntimeException - If no species was found with that ID.
      IllegalStateException - If not all species have been registered yet.
    • getSpeciesSafe

      @Nullable S getSpeciesSafe(net.minecraft.resources.ResourceLocation id)
      Returns:
      The species of this type registered with the given ID, or null if no species was found with that ID.
      Throws:
      IllegalStateException - If not all species have been registered yet.
    • getRandomSpecies

      S getRandomSpecies(net.minecraft.util.RandomSource rand)
      Returns:
      A random species from all registered species of this type.
    • getAllSpeciesIds

      com.google.common.collect.ImmutableSet<net.minecraft.resources.ResourceLocation> getAllSpeciesIds()
      Returns:
      A collection of IDs for all species of this type, including secret species. Used for commands.
    • getSpeciesCount

      int getSpeciesCount()
      Returns:
      The number of species of this type, including secret species.
      Throws:
      IllegalStateException - If not all species have been registered yet.
    • getDefaultSpecies

      S getDefaultSpecies()
      Returns:
      The default species for members of this type. For bees, this is the Forest species.
    • getDefaultStage

      ILifeStage getDefaultStage()
      Returns:
      The life stage used to represent this species in icons.
    • getTranslationKey

      String getTranslationKey()
      Returns:
      The translation key for this species type. Ex. "species_type.forestry.bee" -> "Bee"
      Since:
      2.2.0
    • getDisplayName

      default net.minecraft.network.chat.MutableComponent getDisplayName()
      Returns:
      The display name for this species type. Ex. "Bee" or "Butterfly"
      Since:
      2.2.0
    • createDefaultStack

      default net.minecraft.world.item.ItemStack createDefaultStack()
      Returns:
      A new item stack with the default species and life stage of this species type.
    • getLifeStages

      Collection<ILifeStage> getLifeStages()
      Returns:
      All known life stages of this species. Used for commands.
    • getBreedingTracker

      IBreedingTracker getBreedingTracker(net.minecraft.world.level.LevelAccessor level, @Nullable com.mojang.authlib.GameProfile profile)
      Gets the player's breeding tracker for this species type.
      Parameters:
      level - The world instance where the breeding tracker is stored.
      profile - The player whose breeding tracker should be returned.
      Returns:
      The breeding tracker for species of this type.
    • getTypeForMutation

      default ILifeStage getTypeForMutation(int position)
      The type of the species that will be displayed at the given position of the mutation recipe in the gui.
      Parameters:
      position - 0 = first parent, 1 = second parent, 2 = result
    • getAlyzerPlugin

      IAlyzerPlugin getAlyzerPlugin()
      Plugin to add information for the handheld genetic analyzer.
    • createStack

      net.minecraft.world.item.ItemStack createStack(I individual, ILifeStage type)
    • createStack

      net.minecraft.world.item.ItemStack createStack(net.minecraft.resources.ResourceLocation speciesId, ILifeStage stage)
    • getIndividualCodec

      com.mojang.serialization.Codec<? extends I> getIndividualCodec()
      Returns:
      The codec used to serialize/deserialize individuals of this species.
    • isMember

      boolean isMember(IIndividual individual)
      Used to check whether the given IIndividual is member of this class.
      Parameters:
      individual - IIndividual to check.
      Returns:
      true if the individual is member of this class, false otherwise.
    • isMember

      default boolean isMember(net.minecraft.world.item.ItemStack stack)
    • getResearchSuitability

      float getResearchSuitability(S species, net.minecraft.world.item.ItemStack stack)
      Used to determine what items can be used as research materials in the Escritoire and how effective they are for probing. For an item to be accepted in the research material slots in the Escritoire, this method must return a number greater than zero for that item. An item that returns 1 is guaranteed to reveal slots on the board.
      Parameters:
      species - The species being researched.
      stack - The item to be checked for research purposes.
      Returns:
      The chance that a research attempt (clicking the microscope button) will successfully reveal cells on the board.
    • getResearchBounty

      List<net.minecraft.world.item.ItemStack> getResearchBounty(S species, net.minecraft.world.level.Level level, com.mojang.authlib.GameProfile researcher, I individual, int bountyLevel)
      Used to generate rewards for players who win the Escritoire's memory game when researching a specimen.
      Parameters:
      species - The species that was researched.
      level - The world.
      researcher - The profile of the player who completed this research.
      individual - The specimen that was researched.
      bountyLevel - The bounty level starts at 16 and goes down by 1 for every probe (usage of the microscope button). The lowest level is 1. Rewards players for memorizing the tiles and using good research material.
      Returns:
      A list of reward items granted upon researching a specimen in the Escritoire. Might be empty.
    • getBreedingTrackerFile

      String getBreedingTrackerFile(@Nullable com.mojang.authlib.GameProfile profile)
      Returns:
      The name of the breeding tracker save file for the given player.
    • createBreedingTracker

      IBreedingTracker createBreedingTracker()
      Returns:
      A new breeding tracker.
    • createBreedingTracker

      IBreedingTracker createBreedingTracker(net.minecraft.nbt.CompoundTag nbt)
      Returns:
      A breeding tracker with data loaded from a previous save file.
    • createRandomIndividual

      I createRandomIndividual(net.minecraft.util.RandomSource rand)
      Returns:
      A new individual of a random species using the default genome of the chosen species.
    • initializeBreedingTracker

      void initializeBreedingTracker(IBreedingTracker tracker, @Nullable net.minecraft.world.level.Level world, @Nullable com.mojang.authlib.GameProfile profile)
      Used to initialize a breeding tracker with additional information.
      Parameters:
      tracker - The tracker to add information to.
      world - The world this tracker is saved to. Always the overworld dimension.
      profile - The player to whom the breeding tracker belongs to.
    • handleSpeciesRegistration

      com.mojang.datafixers.util.Pair<com.google.common.collect.ImmutableMap<net.minecraft.resources.ResourceLocation,S>,IMutationManager<S>> handleSpeciesRegistration(List<IForestryPlugin> plugins)
      Used to register species and related data for this species type from an IForestryPlugin. Called immediately after item registration, before FMLCommonSetupEvent.

      IForestryPlugin already contains methods for each species type added by Forestry. For a modded species type, it is recommended to offer an additional interface to be implemented by IForestryPlugins in order to handle registration for the custom species type (ex. IBotanyPluginExtension for Binnie's flower species type) and then checking if the plugin implements that interface.

      Parameters:
      plugins - The list of plugins responsible for registering species and data.
      Returns:
      The map of every species registered to this species type, which later gets passed to onSpeciesRegistered(com.google.common.collect.ImmutableMap<net.minecraft.resources.ResourceLocation, S>, forestry.api.genetics.IMutationManager<S>), and the completed mutations manager for this species type.
      See Also:
    • onSpeciesRegistered

      void onSpeciesRegistered(com.google.common.collect.ImmutableMap<net.minecraft.resources.ResourceLocation,S> allSpecies, IMutationManager<S> mutations)
      Called when all species of this type have been registered and modified.
      Parameters:
      allSpecies - The map of every species ID to its species.
      mutations - The mutations for this species type.
    • cast

      default <T extends ISpeciesType<?, ?>> T cast()
      Returns:
      This species type casted to a subclass of ISpeciesType.