Get things compiling.

Move ForestryAPI into the Forestry project instead of as a submodule
Include the new RF API
Remove code for mods that have not yet ported to 1.8.9 (add it back later)
Bump version to 5.0.0
This commit is contained in:
mezz committed 2016-02-20 19:51:49 -08:00
1 parent 73812d8765
commit 8da0c0dc95
325 files changed
+9600 -4026

No files matched your search

@@ -0,0 +1,36 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
import java.util.HashMap;
import net.minecraft.item.ItemStack;
/**
* Holds a static reference to the {@link IAlleleRegistry}.
*/
public class AlleleManager {
/**
* Main access point for all things related to genetics. See {@link IAlleleRegistry} for details.
*/
public static IAlleleRegistry alleleRegistry;
/**
* Translates plain leaf blocks into genetic data. Used by bees and butterflies to convert and pollinate foreign leaf blocks.
*/
public static HashMap<ItemStack, IIndividual> ersatzSpecimen = new HashMap<ItemStack, IIndividual>();
/**
* Translates plain saplings into genetic data. Used by the treealyzer and the farm to convert foreign saplings.
*/
public static HashMap<ItemStack, IIndividual> ersatzSaplings = new HashMap<ItemStack, IIndividual>();
/**
* Queryable instance of an {@link IClimateHelper} for easier implementation.
*/
public static IClimateHelper climateHelper;
/**
* Creates Forestry alleles.
*/
public static IAlleleFactory alleleFactory;
}
@@ -0,0 +1,16 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
public enum EnumTolerance {
NONE,
BOTH_1, BOTH_2, BOTH_3, BOTH_4, BOTH_5,
UP_1, UP_2, UP_3, UP_4, UP_5,
DOWN_1, DOWN_2, DOWN_3, DOWN_4, DOWN_5
}
@@ -0,0 +1,39 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
/**
* An {@link IIndividual}'s {@link IGenome} is composed of {@link IChromosome}s consisting each of a primary and secondary {@link IAllele}.
*
* {@link IAllele}s hold all information regarding an {@link IIndividual}'s traits, from species to size, temperature tolerances, etc.
*
* Should be extended for different types of alleles. ISpeciesAllele, IBiomeAllele, etc.
*
* @author SirSengir
*/
public interface IAllele {
/**
* @return A unique string identifier for this allele.
*/
String getUID();
/**
* @return true if the allele is dominant, false otherwise.
*/
boolean isDominant();
/**
* @return Localized short, human-readable identifier used in tooltips and beealyzer.
*/
String getName();
/**
* @return The unlocalized identifier
*/
String getUnlocalizedName();
}
@@ -0,0 +1,15 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
/**
* Simple interface to allow adding additional alleles containing float values.
*/
public interface IAlleleArea extends IAllele {
int[] getValue();
}
@@ -0,0 +1,16 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
/**
* Simple interface to allow adding additional alleles containing float values.
*/
public interface IAlleleBoolean extends IAllele {
boolean getValue();
}
@@ -0,0 +1,26 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
/**
* Basic effect allele.
*/
public interface IAlleleEffect extends IAllele {
/**
* @return true if this effect can combine with the effect on other allele (i.e. run before or after). combination can only occur if both effects are
* combinable.
*/
boolean isCombinable();
/**
* Returns the passed data storage if it is valid for this effect or a new one if the passed storage object was invalid for this effect.
*
* @param storedData
* @return {@link IEffectData} for the next cycle.
*/
IEffectData validateStorage(IEffectData storedData);
}
@@ -0,0 +1,153 @@
package forestry.api.genetics;
/**
* Creates new alleles with smart localization.
*
*
* UID is created like this:
* modId + '.' + category + WordUtils.capitalize(valueName);
* For Example:
* modId:forestry, category:height, valueName:smallest => forestry.heightSmallest
* This is mainly for legacy compatibility and may change in future major versions.
*
*
* The default localization uses:
* [modId].allele.[valueName]
*
* Languages that need category-specific names can override it by defining:
* [modId].allele.[category].[valueName]
*
* For example:
* en_US
* forestry.allele.smallest=Smallest
* ru_RU
* forestry.allele.smallest=????? ?????????
* forestry.allele.height.smallest=????? ??????
*/
public interface IAlleleFactory {
/**
* @param modId mod prefix for uid and localization (i.e. "forestry")
* @param category allele category for uid and localization (i.e. "height")
* @param valueName allele value name for uid and localization (i.e. "smallest")
* @param value allele float value
* @param isDominant allele dominance
* @param types allele chromosome type for registration (i.e. EnumTreeChromosome.HEIGHT)
* @return a new IAlleleFloat, registered with the allele registry.
* @since Forestry 4.2
*/
IAlleleFloat createFloat(String modId, String category, String valueName, float value, boolean isDominant, IChromosomeType... types);
/**
* @param modId mod prefix for uid and localization (i.e. "forestry")
* @param category allele category for uid and localization (i.e. "territory")
* @param valueName allele value name for uid and localization (i.e. "large")
* @param xDimValue allele area X Size
* @param yDimValue allele area Y Size
* @param zDimValue allele area Z Size
* @param isDominant allele dominance
* @param types allele chromosome type for registration (i.e. EnumBeeChromosome.TERRITORY)
* @return a new IAlleleArea, registered with the allele registry.
* @since Forestry 4.2
*/
IAlleleArea createArea(String modId, String category, String valueName, int xDimValue, int yDimValue, int zDimValue, boolean isDominant, IChromosomeType... types);
/**
* @param modId mod prefix for uid and localization (i.e. "forestry")
* @param category allele category for uid and localization (i.e. "fertility")
* @param valueName allele value name for uid and localization (i.e. "low")
* @param value allele int value
* @param isDominant allele dominance
* @param types allele chromosome type for registration (i.e. EnumBeeChromosome.FERTILITY)
* @return a new IAlleleInteger, registered with the allele registry.
* @since Forestry 4.2
*/
IAlleleInteger createInteger(String modId, String category, String valueName, int value, boolean isDominant, IChromosomeType... types);
/**
* @param modId mod prefix for uid and localization (i.e. "forestry")
* @param category allele category for uid and localization (i.e. "fireproof")
* @param value allele boolean value
* @param isDominant allele dominance
* @param types allele chromosome type for registration (i.e. EnumTreeChromosome.FIREPROOF)
* @return a new IAlleleBoolean, registered with the allele registry.
* Note that valueName will always be "true" or "false"
* @since Forestry 4.2
*/
IAlleleBoolean createBoolean(String modId, String category, boolean value, boolean isDominant, IChromosomeType... types);
/**
* @param modId mod prefix for uid (i.e. "forestry")
* @param category allele category for uid (i.e. "flowers")
* @param valueName allele value name for uid (i.e. "vanilla")
* @param value allele IFlowerProvider value
* @param isDominant allele dominance
* @param types allele chromosome type for registration (i.e. EnumBeeChromosome.FLOWER_PROVIDER)
* @return a new IAlleleFlowers, registered with the allele registry.
* IAlleleFlowers localization is handled by the IFlowerProvider.getDescription(), unlike the other alleles.
* @since Forestry 4.2
*/
IAlleleFlowers createFlowers(String modId, String category, String valueName, IFlowerProvider value, boolean isDominant, IChromosomeType... types);
/**
* @param modId mod prefix for uid and localization (i.e. "forestry")
* @param category allele category for uid and localization (i.e. "height")
* @param valueName allele value name for uid and localization (i.e. "smallest")
* @param value allele float value
* @param isDominant allele dominance
* @return a new IAlleleFloat, registered with the allele registry.
* @deprecated since Forestry 4.2. Use the IChromosomeType version.
*/
@Deprecated
IAlleleFloat createFloat(String modId, String category, String valueName, float value, boolean isDominant);
/**
* @param modId mod prefix for uid and localization (i.e. "forestry")
* @param category allele category for uid and localization (i.e. "territory")
* @param valueName allele value name for uid and localization (i.e. "large")
* @param xDimValue allele area X Size
* @param yDimValue allele area Y Size
* @param zDimValue allele area Z Size
* @param isDominant allele dominance
* @return a new IAlleleArea, registered with the allele registry.
* @deprecated since Forestry 4.2. Use the IChromosomeType version.
*/
@Deprecated
IAlleleArea createArea(String modId, String category, String valueName, int xDimValue, int yDimValue, int zDimValue, boolean isDominant);
/**
* @param modId mod prefix for uid and localization (i.e. "forestry")
* @param category allele category for uid and localization (i.e. "fertility")
* @param valueName allele value name for uid and localization (i.e. "low")
* @param value allele int value
* @param isDominant allele dominance
* @return a new IAlleleInteger, registered with the allele registry.
* @deprecated since Forestry 4.2. Use the IChromosomeType version.
*/
@Deprecated
IAlleleInteger createInteger(String modId, String category, String valueName, int value, boolean isDominant);
/**
* @param modId mod prefix for uid and localization (i.e. "forestry")
* @param category allele category for uid and localization (i.e. "fireproof")
* @param value allele boolean value
* @param isDominant allele dominance
* @return a new IAlleleBoolean, registered with the allele registry.
* Note that valueName will always be "true" or "false"
* @deprecated since Forestry 4.2. Use the IChromosomeType version.
*/
@Deprecated
IAlleleBoolean createBoolean(String modId, String category, boolean value, boolean isDominant);
/**
* @param modId mod prefix for uid (i.e. "forestry")
* @param category allele category for uid (i.e. "flowers")
* @param valueName allele value name for uid (i.e. "vanilla")
* @param value allele IFlowerProvider value
* @param isDominant allele dominance
* @return a new IAlleleFlowers, registered with the allele registry.
* IAlleleFlowers localization is handled by the IFlowerProvider.getDescription(), unlike the other alleles.
* @deprecated since Forestry 4.2. Use the IChromosomeType version.
*/
@Deprecated
IAlleleFlowers createFlowers(String modId, String category, String valueName, IFlowerProvider value, boolean isDominant);
}
@@ -0,0 +1,15 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
/**
* Simple interface to allow adding additional alleles containing float values.
*/
public interface IAlleleFloat extends IAllele {
float getValue();
}
@@ -0,0 +1,16 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
public interface IAlleleFlowers extends IAllele {
/**
* @return FlowerProvider
*/
IFlowerProvider getProvider();
}
@@ -0,0 +1,41 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
/**
* @author Alex Binnie
*
* Handler for events that occur in IAlleleRegistry, such as registering alleles, branches etc. Useful for handling plugin specific behavior (i.e.
* creating a list of all bee species etc.)
*
*/
public interface IAlleleHandler {
/**
* Called when an allele is registered with {@link IAlleleRegistry}.
*
* @param allele
* Allele which was registered.
*/
public void onRegisterAllele(IAllele allele);
/**
* Called when a classification is registered with {@link IAlleleRegistry}.
*
* @param classification
* Classification which was registered.
*/
public void onRegisterClassification(IClassification classification);
/**
* Called when a fruit family is registered with {@link IAlleleRegistry}.
*
* @param family
* Fruit family which was registered.
*/
public void onRegisterFruitFamily(IFruitFamily family);
}
@@ -0,0 +1,15 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
/**
* Simple interface to allow adding additional alleles containing integer values.
*/
public interface IAlleleInteger extends IAllele {
int getValue();
}
@@ -0,0 +1,16 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
import java.util.EnumSet;
import net.minecraftforge.common.EnumPlantType;
public interface IAllelePlantType extends IAllele {
public EnumSet<EnumPlantType> getPlantTypes();
}
@@ -0,0 +1,238 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
import java.util.Collection;
import java.util.Map;
import net.minecraft.item.ItemStack;
import com.mojang.authlib.GameProfile;
import forestry.api.genetics.IClassification.EnumClassLevel;
/**
* Manages {@link ISpeciesRoot}, {@link IAllele}s, {@link IFruitFamily}s, {@link IClassification}, the blacklist and allows creation of research notes.
*
* @author SirSengir
*/
public interface IAlleleRegistry {
/* SPECIES ROOT CLASSES */
/**
* Register a {@link ISpeciesRoot}.
* @param root {@link ISpeciesRoot} to register.
*/
void registerSpeciesRoot(ISpeciesRoot root);
/**
* @return Map of all registered {@link ISpeciesRoot}.
*/
Map<String, ISpeciesRoot> getSpeciesRoot();
/**
* Retrieve the {@link ISpeciesRoot} with the given uid.
* @param uid Unique id for the species class, i.e. "rootBees", "rootTrees", "rootButterflies".
* @return {@link ISpeciesRoot} if it exists, null otherwise.
*/
ISpeciesRoot getSpeciesRoot(String uid);
/**
* Retrieve a matching {@link ISpeciesRoot} for the given itemstack.
* @param stack An itemstack possibly containing NBT data which can be converted by a species root.
* @return {@link ISpeciesRoot} if found, null otherwise.
*/
ISpeciesRoot getSpeciesRoot(ItemStack stack);
/**
* Retrieve a matching {@link ISpeciesRoot} for the given {@link IIndividual}-class.
* @param clz Class extending {@link IIndividual}.
* @return {@link ISpeciesRoot} if found, null otherwise.
*/
ISpeciesRoot getSpeciesRoot(Class<? extends IIndividual> clz);
/* INDIVIDUAL */
/**
* Tests the itemstack for genetic information.
*
* @param stack
* @return true if the itemstack is an individual.
*/
boolean isIndividual(ItemStack stack);
/**
* Retrieve genetic information from an itemstack.
*
* @param stack
* Stack to retrieve genetic information for.
* @return IIndividual containing genetic information, null if none could be extracted.
*/
IIndividual getIndividual(ItemStack stack);
/* ALLELES */
/**
* @return HashMap of all currently registered alleles.
*/
Map<String, IAllele> getRegisteredAlleles();
/**
* Registers an allele.
*
* @param allele IAllele to register.
* @deprecated since Forestry 4.2. Use the IChromosomeType-specific version.
*/
@Deprecated
void registerAllele(IAllele allele);
/**
* Registers an allele.
*
* NOTE: Where possible, it is recommended to use IAlleleFactory instead
* because it has built-in advanced localization support.
*
* @param allele IAllele to register.
* @param chromosomeTypes valid chromosomeTypes for this allele.
* @since Forestry 4.2
*/
void registerAllele(IAllele allele, IChromosomeType... chromosomeTypes);
/**
* @return HashMap of all registered deprecated alleles and their corresponding replacements
*/
Map<String, IAllele> getDeprecatedAlleleReplacements();
/**
* Registers an old allele UID and the new IAllele to replace instances of it with.
*
* @param deprecatedAlleleUID
* the old allele's UID
* @param replacement
* the IAllele that the deprecated Allele will be replaced with.
*/
void registerDeprecatedAlleleReplacement(String deprecatedAlleleUID, IAllele replacement);
/**
* Gets an allele
*
* @param uid
* String based unique identifier of the allele to retrieve.
* @return IAllele if found or a replacement is found in the Deprecated Allele map, null otherwise.
*/
IAllele getAllele(String uid);
/**
* @return unmodifiable collection of all the known allele variations for the given chromosome type.
* @since Forestry 4.2
*/
Collection<IAllele> getRegisteredAlleles(IChromosomeType type);
/* CLASSIFICATIONS */
/**
* @return HashMap of all currently registered classifications.
*/
Map<String, IClassification> getRegisteredClassifications();
/**
* Registers a classification.
*
* @param classification
* IClassification to register.
*/
void registerClassification(IClassification classification);
/**
* Creates and returns a classification.
*
* @param level
* EnumClassLevel of the classification to create.
* @param uid
* String based unique identifier. Implementation will throw an exception if the key is already taken.
* @param scientific
* Binomial for the given classification.
* @return Created {@link IClassification} for easier chaining.
*/
IClassification createAndRegisterClassification(EnumClassLevel level, String uid, String scientific);
IClassification createAndRegisterClassification(EnumClassLevel level, String uid, String scientific, IClassification... members);
/**
* Gets a classification.
*
* @param uid
* String based unique identifier of the classification to retrieve.
* @return {@link IClassification} if found, null otherwise.
*/
IClassification getClassification(String uid);
/* FRUIT FAMILIES */
/**
* Get all registered fruit families.
*
* @return A map of registered fruit families and their UIDs.
*/
Map<String, IFruitFamily> getRegisteredFruitFamilies();
/**
* Registers a new fruit family.
*
* @param family
*/
void registerFruitFamily(IFruitFamily family);
/**
* Retrieves a fruit family identified by uid.
*
* @param uid
* @return {IFruitFamily} if found, false otherwise.
*/
IFruitFamily getFruitFamily(String uid);
/* ALLELE HANDLERS */
/**
* Registers a new IAlleleHandler
*
* @param handler
* IAlleleHandler to register.
*/
void registerAlleleHandler(IAlleleHandler handler);
/* BLACKLIST */
/**
* Blacklist an allele identified by its UID from mutation.
*
* @param uid
* UID of the allele to blacklist.
*/
void blacklistAllele(String uid);
/**
* @return Current blacklisted alleles.
*/
Collection<String> getAlleleBlacklist();
/**
* @param uid
* UID of the species to vet.
* @return true if the allele is blacklisted.
*/
boolean isBlacklisted(String uid);
/* RESEARCH */
/**
* @param researcher Username of the player who researched this note.
* @param species {@link IAlleleSpecies} to encode on the research note.
* @return An itemstack containing a research note with the given species encoded onto it.
*/
ItemStack getSpeciesNoteStack(GameProfile researcher, IAlleleSpecies species);
/**
* @param researcher Username of the player who researched this note.
* @param mutation {@link IMutation} to encode on the research note.
* @return An itemstack containing a research note with the given mutation encoded onto it.
*/
ItemStack getMutationNoteStack(GameProfile researcher, IMutation mutation);
}
@@ -0,0 +1,114 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import com.mojang.authlib.GameProfile;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.core.IModelProvider;
/**
* Basic species allele.
*/
public interface IAlleleSpecies extends IAllele {
/**
* @return the {@link ISpeciesRoot} associated with this species.
*/
ISpeciesRoot getRoot();
/**
* @return Localized short description of this species. (May be null.)
*/
String getDescription();
/**
* Binomial name of the species sans genus ("Apis"). Returning "humboldti" will have the bee species flavour name be "Apis humboldti". Feel free to use fun
* names or return null.
*
* @return flavour text (may be null)
*/
String getBinomial();
/**
* Authority for the binomial name, e.g. "Sengir" on species of base Forestry.
*
* @return flavour text (may be null)
*/
String getAuthority();
/**
* @return Branch this species is associated with.
*/
IClassification getBranch();
/* RESEARCH */
/**
* Complexity determines the difficulty researching a species. The values of primary and secondary are
* added together (and rounded) to determine the amount of pairs needed for successful research.
* @return Values between 3 - 11 are useful.
*/
int getComplexity();
/**
* @param itemstack
* @return A float signifying the chance for the passed itemstack to yield a research success.
*/
float getResearchSuitability(ItemStack itemstack);
/**
* @param world
* @param gameProfile
* @param individual
* @param bountyLevel
* @return Array of itemstacks representing the bounty for this research success.
*/
ItemStack[] getResearchBounty(World world, GameProfile gameProfile, IIndividual individual, int bountyLevel);
/* CLIMATE */
/**
* @return Preferred temperature
*/
EnumTemperature getTemperature();
/**
* @return Preferred humidity
*/
EnumHumidity getHumidity();
/* MISC */
/**
* @return true if the species icon should have a glowing effect.
*/
boolean hasEffect();
/**
* @return true if the species should not be displayed in NEI or creative inventory.
*/
boolean isSecret();
/**
* @return true to have the species count against the species total.
*/
boolean isCounted();
/* APPEARANCE */
/**
* @param renderPass Render pass to get the colour for.
* @return Colour to use for the render pass.
*/
int getSpriteColour(int renderPass);
@SideOnly(Side.CLIENT)
IModelProvider getModelProvider();
}
@@ -0,0 +1,23 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
public interface IAlleleSpeciesCustom extends IAlleleSpecies {
IAlleleSpeciesCustom setTemperature(EnumTemperature temperature);
IAlleleSpeciesCustom setHumidity(EnumHumidity humidity);
IAlleleSpeciesCustom setHasEffect();
/** Secret species are not shown in creative mode. */
IAlleleSpeciesCustom setIsSecret();
/** Uncounted species do not count toward total species discovered. */
IAlleleSpeciesCustom setIsNotCounted();
}
@@ -0,0 +1,15 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
/**
* Simple interface to allow adding additional alleles containing float values.
*/
public interface IAlleleTolerance extends IAllele {
EnumTolerance getValue();
}
@@ -0,0 +1,106 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import forestry.api.apiculture.IBeekeepingMode;
/**
* Keeps track of who bred, discovered, and researched which species in a world.
*
* @author SirSengir
*/
public interface IBreedingTracker {
/**
* @return Name of the current {@link IBeekeepingMode}.
*/
String getModeName();
/**
* Set the current {@link IBeekeepingMode}.
*/
void setModeName(String name);
/**
* @return Amount of species discovered.
*/
int getSpeciesBred();
/**
* Register the birth of an individual. Will mark it as discovered.
*
* @param individual
*/
void registerBirth(IIndividual individual);
/**
* Register the pickup of an individual.
*
* @param individual
*/
void registerPickup(IIndividual individual);
/**
* Marks a species as discovered. Should only be called from registerIndividual normally.
*
* @param species
*/
void registerSpecies(IAlleleSpecies species);
/**
* Register a successful mutation. Will mark it as discovered.
*
* @param mutation
*/
void registerMutation(IMutation mutation);
/**
* Queries the tracker for discovered species.
*
* @param mutation
* Mutation to query for.
* @return true if the mutation has been discovered.
*/
boolean isDiscovered(IMutation mutation);
/**
* Queries the tracker for discovered species.
*
* @param species
* Species to check.
* @return true if the species has been bred.
*/
boolean isDiscovered(IAlleleSpecies species);
/**
* Register a successfully researched mutation.
* Mutations are normally researched in the Escritoire.
* Researched mutations may have bonuses such as occurring at a higher rate.
* Researched mutations count as discovered.
*/
void researchMutation(IMutation mutation);
/**
* @return true if the mutation has been researched.
*/
boolean isResearched(IMutation mutation);
/**
* Synchronizes the tracker to the client side.
* Before Forestry 4.2.1: Should be called before opening any gui needing that information.
* Since Forestry 4.2.1: Breeding tracker should be automatically synced, only Forestry should need to call this.
*/
void synchToPlayer(EntityPlayer player);
/* LOADING & SAVING */
void decodeFromNBT(NBTTagCompound nbttagcompound);
void encodeToNBT(NBTTagCompound nbttagcompound);
}
@@ -0,0 +1,25 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
import forestry.api.core.INBTTagable;
/**
* Implementations other than Forestry's default one are not supported!
*
* @author SirSengir
*/
public interface IChromosome extends INBTTagable {
IAllele getPrimaryAllele();
IAllele getSecondaryAllele();
IAllele getInactiveAllele();
IAllele getActiveAllele();
}
@@ -0,0 +1,24 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
/*
* Interface to be implemented by the enums representing the various chromosomes
*/
public interface IChromosomeType {
/*
* Get class which all alleles on this chromosome must interface
*/
Class<? extends IAllele> getAlleleClass();
String getName();
ISpeciesRoot getSpeciesRoot();
int ordinal();
}
@@ -0,0 +1,107 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
/**
* Biological classifications from domain down to genus.
*
* Used by the *alyzers to display hierarchies.
*/
public interface IClassification {
public enum EnumClassLevel {
DOMAIN(0x777fff, true), KINGDOM(0x77c3ff), PHYLUM(0x77ffb6, true), DIVISION(0x77ffb6, true), CLASS(0x7bff77), ORDER(0xbeff77), FAMILY(0xfffd77),
SUBFAMILY(0xfffd77), TRIBE(0xfffd77), GENUS(0xffba77);
private int colour;
private boolean isDroppable;
private EnumClassLevel(int colour) {
this(colour, false);
}
private EnumClassLevel(int colour, boolean isDroppable) {
this.colour = colour;
this.isDroppable = isDroppable;
}
/**
* @return Colour to use for displaying this classification.
*/
public int getColour() {
return colour;
}
/**
* @return Indicates whether display of this classification level can be ommitted in case of space constraints.
*/
public boolean isDroppable() {
return isDroppable;
}
}
/**
* @return Level inside the full hierarchy this particular classification is located at.
*/
EnumClassLevel getLevel();
/**
* @return Unique String identifier.
*/
String getUID();
/**
* @return Localized branch name for user display.
*/
String getName();
/**
* A branch approximates a "genus" in real life. Real life examples: "Micrapis", "Megapis"
*
* @return flavour text (may be null)
*/
String getScientific();
/**
* @return Localized description of this branch. (May be null.)
*/
String getDescription();
/**
* @return Member groups of this one.
*/
IClassification[] getMemberGroups();
/**
* Adds subgroups to this group.
*/
void addMemberGroup(IClassification group);
/**
* @return Member species of this group.
*/
IAlleleSpecies[] getMemberSpecies();
/**
* Used by the allele registry to populate internal collection of branch members on the fly.
*
* @param species
*/
void addMemberSpecies(IAlleleSpecies species);
/**
* @return Parent classification, null if this is root.
*/
IClassification getParent();
/**
* Only used internally by the AlleleRegistry if this classification has been added to another one.
*
* @param parent
*/
void setParent(IClassification parent);
}
@@ -0,0 +1,53 @@
package forestry.api.genetics;
import java.util.Collection;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
public interface IClimateHelper {
/**
* Determines whether the given temperature and humidity are within the given constraints.
* @param temperature The temperature to test.
* @param humidity The humidity to test.
* @param baseTemp Base temperature for the test.
* @param tolTemp Temperature tolerance to apply.
* @param baseHumid Base humidity for the test.
* @param tolHumid Humidity tolerance to apply.
* @return true if both temperature and humidity fit the given constraints.
*/
boolean isWithinLimits(EnumTemperature temperature, EnumHumidity humidity,
EnumTemperature baseTemp, EnumTolerance tolTemp,
EnumHumidity baseHumid, EnumTolerance tolHumid);
boolean isWithinLimits(EnumTemperature temperature, EnumTemperature baseTemp, EnumTolerance tolTemp);
boolean isWithinLimits(EnumHumidity humidity, EnumHumidity baseHumid, EnumTolerance tolHumid);
/**
* Gets a collection of humidities which fit the given parameters.
* @param prefered Base humidity from which to measure.
* @param tolerance Tolerance to apply to the base humidity.
* @return A collection of humidities which fall within the given parameters.
*/
Collection<EnumHumidity> getToleratedHumidity(EnumHumidity prefered, EnumTolerance tolerance);
/**
* Gets a collection of temperatures which fit the given parameters.
* @param prefered Base temperature from which to measure.
* @param tolerance Tolerance to apply to the base temperatures.
* @return A collection of temperatures which fall within the given parameters.
*/
Collection<EnumTemperature> getToleratedTemperature(EnumTemperature prefered, EnumTolerance tolerance);
/**
* Gets a localized, human readable string for the given temperature.
* @param temperature Temperature to generate the string for.
* @return A localized, human readable string for the given temperature.
*/
String toDisplay(EnumTemperature temperature);
/**
* Gets a localized, human readable string for the given humidity.
* @param humidity Humidity to generate the string for.
* @return A localized, human readable string for the given humidity.
*/
String toDisplay(EnumHumidity humidity);
}
@@ -0,0 +1,27 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
import forestry.api.core.INBTTagable;
/**
* Container to hold some temporary data for bee, tree and butterfly effects.
*
* @author SirSengir
*/
public interface IEffectData extends INBTTagable {
void setInteger(int index, int val);
void setFloat(int index, float val);
void setBoolean(int index, boolean val);
int getInteger(int index);
float getFloat(int index);
boolean getBoolean(int index);
}
@@ -0,0 +1,24 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
import net.minecraft.block.Block;
/**
* @deprecated since Forestry 4.0. Use alternative methods in IFlowerRegistry.
*/
@Deprecated
public interface IFlower extends Comparable<IFlower> {
Block getBlock();
int getMeta();
double getWeight();
void setWeight(double weight);
boolean isPlantable();
}
@@ -0,0 +1,17 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
public interface IFlowerAcceptableRule {
/**
* Checks if the flower at this position is accepted by this rule.
* flowerType is passed in case this rule is registered for multiple flower types.
*/
boolean isAcceptableFlower(String flowerType, World world, BlockPos pos);
}
@@ -0,0 +1,17 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
public interface IFlowerGrowthHelper {
/**
* Plants a random flower from flowerType at the specified position.
* @return true if successful, false if it could not be planted.
*/
boolean plantRandomFlower(String flowerType, World world, BlockPos pos);
}
@@ -0,0 +1,22 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
/**
* Basic condition for flower growing, such as checking that the soil is the correct type.
*/
public interface IFlowerGrowthRule {
/**
* Checks a position for suitability, and then plants a flower there.
* Returns true on success.
* For implementers, you can plant a random flower using IFlowerGrowthHelper.plantRandomFlower
* @since Forestry 4.0.8
*/
boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, BlockPos pos);
}
@@ -0,0 +1,35 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
import java.util.Set;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
public interface IFlowerProvider {
boolean isAcceptedPollinatable(World world, IPollinatable pollinatable);
/**
* @return The unique type used for the IFlowerRegistry
* @since Forestry 4.0.0
*/
String getFlowerType();
/**
* @return Short, human-readable identifier used in the beealyzer.
*/
String getDescription();
/**
* Allows the flower provider to affect the produce at the given location.
* If this flowerProvider does not affect the products, it should return the products unchanged.
* @return Array of itemstacks being the (modified or unmodified) produce.
*/
ItemStack[] affectProducts(World world, IIndividual individual, BlockPos pos, ItemStack[] products);
}
@@ -0,0 +1,92 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
import java.util.Collection;
import java.util.Random;
import java.util.Set;
import net.minecraft.block.Block;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeHousing;
// See {@link forestry.api.apiculture.FlowerManager}.FlowerType___ for basic Forestry flower types.
// Each IFlowerProvider has one flower type, and multiple IFlowerProviders may share one type.
// "Acceptable flowers" allow nearby bees to do work.
// "Plantable flowers" are "Acceptable flowers" and are also planted randomly by bees.
public interface IFlowerRegistry {
/**
* Register a new flower growth rule.
* This defines the flower planting logic for the specified flower types.
* Without a flower growth rule, no flowers of that type can be planted.
*/
void registerGrowthRule(IFlowerGrowthRule rule, String... flowerTypes);
/**
* Registers an accepted flower with any meta value.
*/
void registerAcceptableFlower(Block flowerBlock, String... flowerTypes);
/**
* Registers an accepted flower with a specific meta value.
*/
void registerAcceptableFlower(Block flowerBlock, int flowerMeta, String... flowerTypes);
/**
* Registers custom logic for accepted flowers.
* These rules are inefficient compared to ones made with registerAcceptableFlower, but may be necessary for tile entity flowers.
* The flower types built into Forestry can not be used here.
* @since Forestry 4.0.8
*/
void registerAcceptableFlowerRule(IFlowerAcceptableRule flowerAcceptableRule, String... flowerTypes);
/**
* Registers a plantable flower.
* The distribution is based on its own weight and the total number of plants for this flowerType.
*
* @param weight Weight for the Flower (Vanilla = 1.0, Modded flowers < 1.0)
* @param flowerTypes See {@link forestry.api.apiculture.FlowerManager}.FlowerTypeXXX
*/
void registerPlantableFlower(Block flowerBlock, int flowerMeta, double weight, String... flowerTypes);
/**
* Calls the appropriate IFlowerGrowthRule to grow a flower at a specified position.
*/
boolean growFlower(String flowerType, World world, IIndividual individual, BlockPos pos);
/**
* @return the coordinates of a nearby accepted flower or null if there is none.
*/
BlockPos getAcceptedFlowerCoordinates(IBeeHousing beeHousing, IBee bee, String flowerType);
/**
* Checks a single coordinate to see if it is an accepted flower.
*/
boolean isAcceptedFlower(String flowerType, World world, BlockPos pos);
/**
* For use by IFlowerGrowthRule implementations
* @deprecated since Forestry 4.0.8 This will be accessible to IFlowerGrowthRule via IFlowerGrowthHelper
*/
@Deprecated
IFlower getRandomPlantableFlower(String flowerType, Random rand);
/**
* Returns all known flower types.
* @deprecated since Forestry 4.0.8 This should only be used internally.
*/
@Deprecated
Collection<String> getFlowerTypes();
/**
* @deprecated since Forestry 4.0.8 This should only be used internally.
*/
@Deprecated
Set<IFlower> getAcceptableFlowers(String flowerType);
}
@@ -0,0 +1,50 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
import java.util.Collection;
import net.minecraft.item.ItemStack;
/**
* Can be implemented by tile entities which can bear fruit.
*
* @author SirSengir
*/
public interface IFruitBearer {
/**
* @return true if the actual tile can bear fruits.
*/
boolean hasFruit();
/**
* @return Family of the potential fruits on this tile.
*/
IFruitFamily getFruitFamily();
/**
* Picks the fruits of this tile, resetting it to unripe fruits.
*
* @param tool
* Tool used in picking the fruits. May be null.
* @return Picked fruits.
*/
Collection<ItemStack> pickFruit(ItemStack tool);
/**
* @return float indicating the ripeness of the fruit with >= 1.0f indicating full ripeness.
*/
float getRipeness();
/**
* Increases the ripeness of the fruit.
*
* @param add
* Float to add to the ripeness. Will truncate to valid values.
*/
void addRipeness(float add);
}
@@ -0,0 +1,32 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
public interface IFruitFamily {
/**
* @return Unique String identifier.
*/
String getUID();
/**
* @return Localized family name for user display.
*/
String getName();
/**
* A scientific-y name for this fruit family
*
* @return flavour text (may be null)
*/
String getScientific();
/**
* @return Localized description of this fruit family. (May be null.)
*/
String getDescription();
}
@@ -0,0 +1,30 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
import forestry.api.core.INBTTagable;
/**
* Holds the {@link IChromosome}s which comprise the traits of a given individual.
*
* Only the default implementation is supported.
*/
public interface IGenome extends INBTTagable {
IAlleleSpecies getPrimary();
IAlleleSpecies getSecondary();
IChromosome[] getChromosomes();
IAllele getActiveAllele(IChromosomeType chromosomeType);
IAllele getInactiveAllele(IChromosomeType chromosomeType);
boolean isGeneticEqual(IGenome other);
ISpeciesRoot getSpeciesRoot();
}
@@ -0,0 +1,17 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
import net.minecraft.util.BlockPos;
/**
* Any housing, hatchery or nest with a location in the world.
*/
public interface IHousing {
BlockPos getCoordinates();
}
@@ -0,0 +1,53 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
import java.util.List;
import forestry.api.core.INBTTagable;
/**
* An actual individual with genetic information.
*
* Only the default implementation is supported.
*/
public interface IIndividual extends INBTTagable {
String getIdent();
String getDisplayName();
void addTooltip(List<String> list);
/**
* Call to mark the IIndividual as analyzed.
* @return true if the IIndividual has not been analyzed previously.
*/
boolean analyze();
boolean isAnalyzed();
boolean hasEffect();
boolean isSecret();
IGenome getGenome();
/**
* Check whether the genetic makeup of two IIndividuals is identical. Ignores additional data like generations, irregular mating, etc..
* @param other
* @return true if the given other IIndividual has the amount of chromosomes and their alleles are identical.
*/
boolean isGeneticEqual(IIndividual other);
/**
* @return A deep copy of this individual.
*/
IIndividual copy();
boolean isPureBred(IChromosomeType chromosomeType);
}
@@ -0,0 +1,45 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
import net.minecraft.world.World;
public interface IIndividualLiving extends IIndividual {
/**
* @return Genetic information of the mate, null if unmated.
*/
IGenome getMate();
/**
* @return Current health of the individual.
*/
int getHealth();
/**
* @return Maximum health of the individual.
*/
int getMaxHealth();
/**
* Age the individual.
* @param world
* @param ageModifier
*/
void age(World world, float ageModifier);
/**
* Mate with the given individual.
* @param individual the {@link IIndividual} to mate this one with.
*/
void mate(IIndividual individual);
/**
* @return true if the individual is among the living.
*/
boolean isAlive();
}
@@ -0,0 +1,68 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
import java.util.Collection;
/**
* Individuals can be seeded either as hive drops or as mutation results.
*
* {@link IAlleleRegistry} manages these.
*
* @author SirSengir
*/
public interface IMutation {
/**
* @return {@link ISpeciesRoot} this mutation is associated with.
*/
ISpeciesRoot getRoot();
/**
* @return first of the alleles implementing IAlleleSpecies required for this mutation.
*/
IAlleleSpecies getAllele0();
/**
* @return second of the alleles implementing IAlleleSpecies required for this mutation.
*/
IAlleleSpecies getAllele1();
/**
* @return Array of {@link IAllele} representing the full default genome of the mutated side.
*
* Make sure to return a proper array for the species class. Returning an allele of the wrong type will cause cast errors on runtime.
*/
IAllele[] getTemplate();
/**
* @return Unmodified base chance for mutation to fire.
*/
float getBaseChance();
/**
* @return Collection of localized, human-readable strings describing special mutation conditions, if any.
*/
Collection<String> getSpecialConditions();
/**
* @param allele
* @return true if the passed allele is one of the alleles participating in this mutation.
*/
boolean isPartner(IAllele allele);
/**
* @param allele
* @return the other allele which was not passed as argument.
*/
IAllele getPartner(IAllele allele);
/**
* @return true if the mutation should not be displayed in the beealyzer.
*/
boolean isSecret();
}
@@ -0,0 +1,24 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
public interface IMutationCondition {
/**
* Returns a float from 0 to 1 representing the chance for mutation to occur.
* Most will return 1 if the condition is met and 0 otherwise,
* but the float offers flexibility for more advanced conditions.
*/
float getChance(World world, BlockPos pos, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1);
/**
* A localized description of the mutation condition. (i.e. "A temperature of HOT is required.")
*/
String getDescription();
}
@@ -0,0 +1,48 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
import net.minecraft.block.Block;
import net.minecraftforge.common.BiomeDictionary;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
/** Set custom mutation requirements */
public interface IMutationCustom extends IMutation {
/** Prevent this mutation from being shown in the analyzers */
IMutationCustom setIsSecret();
/** Require a specific temperature for this mutation to occur */
IMutationCustom restrictTemperature(EnumTemperature temperature);
IMutationCustom restrictTemperature(EnumTemperature minTemperature, EnumTemperature maxTemperature);
/** Require a specific humidity for this mutation to occur */
IMutationCustom restrictHumidity(EnumHumidity humidity);
IMutationCustom restrictHumidity(EnumHumidity minHumidity, EnumHumidity maxHumidity);
/**
* Restrict this mutation to certain types of biomes.
* @param types The types of biomes this mutation can occur.
*/
IMutationCustom restrictBiomeType(BiomeDictionary.Type... types);
/** Restrict the days of the year that this mutation can occur */
IMutationCustom restrictDateRange(int startMonth, int startDay, int endMonth, int endDay);
/** Restrict the time of day that this mutation can occur */
IMutationCustom requireDay();
IMutationCustom requireNight();
/** Require a specific resource to be under the location of the mutation */
IMutationCustom requireResource(Block block, int meta);
IMutationCustom requireResource(String oreDictName);
/** Require some other custom mutation condition */
IMutationCustom addMutationCondition(IMutationCondition mutationCondition);
}
@@ -0,0 +1,53 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
import java.util.EnumSet;
import net.minecraftforge.common.EnumPlantType;
/**
* Can be implemented by tile entities, if they wish to be pollinatable.
*
* @author SirSengir
*/
public interface IPollinatable {
/**
* @return plant types this pollinatable is classified as. (Can be used by bees to determine whether to interact or not.
*/
EnumSet<EnumPlantType> getPlantType();
/**
* @return IIndividual containing the genetic information of this IPollinatable
*/
IIndividual getPollen();
/**
* Checks whether this {@link IPollinatable} can mate with the given pollen.
*
* Must be the one to check genetic equivalency.
*
* @param pollen
* IIndividual representing the pollen.
* @return true if mating is possible, false otherwise.
*/
boolean canMateWith(IIndividual pollen);
/**
* Pollinates this entity.
*
* @param pollen
* IIndividual representing the pollen.
*/
void mateWith(IIndividual pollen);
/**
* @return true if this IPollinatable has already been pollinated.
* @since Forestry 4.1.0
*/
boolean isPollinated();
}
@@ -0,0 +1,179 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Random;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import com.mojang.authlib.GameProfile;
/**
* Describes a class of species (i.e. bees, trees, butterflies), provides helper functions and access to common functionality.
*/
public interface ISpeciesRoot {
/**
* @return A unique identifier for the species class. Should consist of "root" + a common name for the species class in camel-case, i.e. "rootBees", "rootTrees", "rootButterflies".
*/
String getUID();
/**
* @return Class of the sub-interface inheriting from {@link IIndividual}.
*/
Class<? extends IIndividual> getMemberClass();
/**
* @return Integer denoting the number of (counted) species of this type in the world.
*/
int getSpeciesCount();
/**
* Used to check whether a given itemstack contains genetic data corresponding to an {@link IIndividual} of this class.
* @param stack itemstack to check.
* @return true if the itemstack contains an {@link IIndividual} of this class, false otherwise.
*/
boolean isMember(ItemStack stack);
/**
* Used to check whether a given itemstack contains genetic data corresponding to an {@link IIndividual} of this class and matches the given type.
* @param stack itemstack to check.
* @param type Integer denoting the type needed to match. (i.e. butterfly vs. butterfly serum; bee queens, princesses, drones; etc.)
* @return true if the itemstack contains an {@link IIndividual} of this class, false otherwise.
*/
boolean isMember(ItemStack stack, int type);
/**
* Used to check whether the given {@link IIndividual} is member of this class.
* @param individual {@link IIndividual} to check.
* @return true if the individual is member of this class, false otherwise.
*/
boolean isMember(IIndividual individual);
IIndividual getMember(ItemStack stack);
IIndividual getMember(NBTTagCompound compound);
ISpeciesType getType(ItemStack itemStack);
ItemStack getMemberStack(IIndividual individual, int type);
/* BREEDING TRACKER */
IBreedingTracker getBreedingTracker(World world, GameProfile player);
/**
* @deprecated since Forestry 4.2.1. Breeding tracker should be automatically synced.
*/
@Deprecated
void syncBreedingTrackerToPlayer(EntityPlayer player);
/* GENOME MANIPULATION */
IIndividual templateAsIndividual(IAllele[] template);
IIndividual templateAsIndividual(IAllele[] templateActive, IAllele[] templateInactive);
IChromosome[] templateAsChromosomes(IAllele[] template);
IChromosome[] templateAsChromosomes(IAllele[] templateActive, IAllele[] templateInactive);
IGenome templateAsGenome(IAllele[] template);
IGenome templateAsGenome(IAllele[] templateActive, IAllele[] templateInactive);
/* TEMPLATES */
/**
* Registers a bee template using the UID of the first allele as identifier.
*
* @param template
*/
void registerTemplate(IAllele[] template);
/**
* Registers a bee template using the passed identifier.
*
* @param template
*/
void registerTemplate(String identifier, IAllele[] template);
/**
* Retrieves a registered template using the passed identifier.
*
* @param identifier
* @return Array of {@link IAllele} representing a genome.
*/
IAllele[] getTemplate(String identifier);
/**
* @return Default individual template for use when stuff breaks.
*/
IAllele[] getDefaultTemplate();
/**
* @param rand Random to use.
* @return A random template from the pool of registered species templates.
*/
IAllele[] getRandomTemplate(Random rand);
Map<String, IAllele[]> getGenomeTemplates();
ArrayList<? extends IIndividual> getIndividualTemplates();
/* MUTATIONS */
/**
* Use to register mutations.
*
* @param mutation
*/
void registerMutation(IMutation mutation);
/**
* @return All registered mutations.
*/
Collection<? extends IMutation> getMutations(boolean shuffle);
/**
* @param other Allele to match mutations against.
* @return All registered mutations the given allele is part of.
*/
Collection<? extends IMutation> getCombinations(IAllele other);
/**
* @since Forestry 3.7
* @return all possible mutations that result from breeding two species
*/
List<IMutation> getCombinations(IAlleleSpecies parentSpecies0, IAlleleSpecies parentSpecies1, boolean shuffle);
Collection<? extends IMutation> getPaths(IAllele result, IChromosomeType chromosomeType);
/* RESEARCH */
/**
* @return List of generic catalysts which should be accepted for research by species of this class.
*/
Map<ItemStack, Float> getResearchCatalysts();
/**
* Sets an item stack as a valid (generic) research catalyst for this class.
* @param itemstack ItemStack to set as suitable.
* @param suitability Float between 0 and 1 to indicate suitability.
*/
void setResearchSuitability(ItemStack itemstack, float suitability);
/**
* @return Array of {@link IChromosomeType} which are in this species genome
*/
IChromosomeType[] getKaryotype();
/**
* @return {@link IChromosomeType} which is the "key" for this species class, usually the species chromosome.
*/
IChromosomeType getKaryotypeKey();
}
@@ -0,0 +1,10 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
/** Species types, implemented by enums and compared with == */
public interface ISpeciesType {
}
@@ -0,0 +1,9 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
@API(apiVersion = "4.7.1", owner = "ForestryAPI|core", provides = "ForestryAPI|genetics")
package forestry.api.genetics;
import net.minecraftforge.fml.common.API;