Test with stuff + Forestry potential support

This commit is contained in:
WayofTime 2014-01-25 20:36:28 -05:00
parent 5b05cf651b
commit bd26e441cb
174 changed files with 5602 additions and 0 deletions

View file

@ -0,0 +1,24 @@
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>();
}

View file

@ -0,0 +1,11 @@
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
}

View file

@ -0,0 +1,29 @@
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();
}

View file

@ -0,0 +1,10 @@
package forestry.api.genetics;
/**
* Simple interface to allow adding additional alleles containing float values.
*/
public interface IAlleleArea extends IAllele {
int[] getValue();
}

View file

@ -0,0 +1,11 @@
package forestry.api.genetics;
/**
* Simple interface to allow adding additional alleles containing float values.
*/
public interface IAlleleBoolean extends IAllele {
boolean getValue();
}

View file

@ -0,0 +1,21 @@
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);
}

View file

@ -0,0 +1,10 @@
package forestry.api.genetics;
/**
* Simple interface to allow adding additional alleles containing float values.
*/
public interface IAlleleFloat extends IAllele {
float getValue();
}

View file

@ -0,0 +1,11 @@
package forestry.api.genetics;
public interface IAlleleFlowers extends IAllele {
/**
* @return FlowerProvider
*/
IFlowerProvider getProvider();
}

View file

@ -0,0 +1,36 @@
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);
}

View file

@ -0,0 +1,10 @@
package forestry.api.genetics;
/**
* Simple interface to allow adding additional alleles containing integer values.
*/
public interface IAlleleInteger extends IAllele {
int getValue();
}

View file

@ -0,0 +1,11 @@
package forestry.api.genetics;
import java.util.EnumSet;
import net.minecraftforge.common.EnumPlantType;
public interface IAllelePlantType extends IAllele {
public EnumSet<EnumPlantType> getPlantTypes();
}

View file

@ -0,0 +1,221 @@
package forestry.api.genetics;
import java.util.Collection;
import java.util.Map;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
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.
*/
void registerAllele(IAllele allele);
/**
* @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);
/* THIS SHOULD BE PHASED OUT */
@Deprecated
void reloadMetaMap(World world);
@Deprecated
IAllele getFromMetaMap(int meta);
@Deprecated
int getFromUIDMap(String uid);
/* 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);
/**
* 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(String 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(String researcher, IMutation mutation);
}

View file

@ -0,0 +1,106 @@
package forestry.api.genetics;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.core.IIconProvider;
/**
* 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 researcher
* @param individual
* @param bountyLevel
* @return Array of itemstacks representing the bounty for this research success.
*/
ItemStack[] getResearchBounty(World world, String researcher, 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 getIconColour(int renderPass);
@SideOnly(Side.CLIENT)
IIconProvider getIconProvider();
}

View file

@ -0,0 +1,10 @@
package forestry.api.genetics;
/**
* Simple interface to allow adding additional alleles containing float values.
*/
public interface IAlleleTolerance extends IAllele {
EnumTolerance getValue();
}

View file

@ -0,0 +1,93 @@
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 and/or discovered 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.
*/
@Deprecated
void registerMutation(IAllele allele0, IAllele allele1);
/**
* 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);
/**
* Synchronizes the tracker to the client side. Should be called before opening any gui needing that information.
*
* @param player
*/
void synchToPlayer(EntityPlayer player);
/* LOADING & SAVING */
void decodeFromNBT(NBTTagCompound nbttagcompound);
void encodeToNBT(NBTTagCompound nbttagcompound);
}

View file

@ -0,0 +1,20 @@
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();
}

View file

@ -0,0 +1,19 @@
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();
}

View file

@ -0,0 +1,102 @@
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);
}

View file

@ -0,0 +1,22 @@
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);
}

View file

@ -0,0 +1,51 @@
package forestry.api.genetics;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public interface IFlowerProvider {
/**
* @param world
* @param individual
* @param x
* @param y
* @param z
* @return True if the block at the passed coordinates is a valid flower for the species.
*/
boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z);
boolean isAcceptedPollinatable(World world, IPollinatable pollinatable);
/**
* @param world
* @param individual
* @param x
* @param y
* @param z
* @return True if a flower was planted.
*/
boolean growFlower(World world, IIndividual individual, int x, int y, int z);
/**
* @return Short, human-readable identifier used in the beealyzer.
*/
String getDescription();
/**
* Allows the flower provider to affect the produce at the given location.
* @param world
* @param individual
* @param x
* @param y
* @param z
* @param products
* @return Array of itemstacks being the (modified or unmodified) produce.
*/
ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products);
/**
* @return Array of itemstacks representing valid flowers for the flower provider. The first in the array is for use as an icon Return null or an empty
* array if the flower does not have an itemstack
*/
ItemStack[] getItemStacks();
}

View file

@ -0,0 +1,45 @@
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);
}

View file

@ -0,0 +1,27 @@
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();
}

View file

@ -0,0 +1,25 @@
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(int chromosome);
IAllele getInactiveAllele(int chromosome);
boolean isGeneticEqual(IGenome other);
ISpeciesRoot getSpeciesRoot();
}

View file

@ -0,0 +1,46 @@
package forestry.api.genetics;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
/**
* Any housing, hatchery or nest which is a fixed location in the world.
*/
public interface IHousing {
/**
* @return String containing the login of this housing's owner.
*/
String getOwnerName();
World getWorld();
int getXCoord();
int getYCoord();
int getZCoord();
int getBiomeId();
EnumTemperature getTemperature();
EnumHumidity getHumidity();
void setErrorState(int state);
int getErrorOrdinal();
/**
* Adds products to the housing's inventory.
*
* @param product
* ItemStack with the product to add.
* @param all
* @return Boolean indicating success or failure.
*/
boolean addProduct(ItemStack product, boolean all);
}

View file

@ -0,0 +1,52 @@
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();
/**
* @param chromosomeOrdinal Ordinal of the chromosome to check.
* @return true if both primary and secondary allele on the given chromosome match.
*/
boolean isPureBred(int chromosomeOrdinal);
}

View file

@ -0,0 +1,40 @@
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();
}

View file

@ -0,0 +1,10 @@
package forestry.api.genetics;
/**
* AlleleManager.alleleRegistry can be cast to this type.
*/
public interface ILegacyHandler {
void registerLegacyMapping(int id, String uid);
IAllele getFromLegacyMap(int id);
}

View file

@ -0,0 +1,63 @@
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.
*/
IAllele getAllele0();
/**
* @return second of the alleles implementing IAlleleSpecies required for this mutation.
*/
IAllele 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();
}

View file

@ -0,0 +1,43 @@
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);
}

View file

@ -0,0 +1,160 @@
package forestry.api.genetics;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
import java.util.Random;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
/**
* 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 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);
ItemStack getMemberStack(IIndividual individual, int type);
/* BREEDING TRACKER */
IBreedingTracker getBreedingTracker(World world, String 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);
/**
* @param result {@link IAllele} to search for.
* @return All registered mutations the given {@link IAllele} is the result of.
*/
Collection<? extends IMutation> getPaths(IAllele result, int chromosomeOrdinal);
/* 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();
}

View file

@ -0,0 +1,3 @@
@API(apiVersion="1.0", owner="ForestryAPI|core", provides="ForestryAPI|genetics")
package forestry.api.genetics;
import cpw.mods.fml.common.API;