Revert "Use generics for Chromosome type, begin unifying code"

This reverts commit 43e41034f6.

Conflicts:
	src/main/java/forestry/api/arboriculture/IAlleleTreeSpecies.java
	src/main/java/forestry/api/genetics/IAlleleSpeciesCustom.java
	src/main/java/forestry/core/proxy/ProxyRenderClient.java
This commit is contained in:
mezz committed 2016-03-03 20:50:38 -08:00
1 parent 87f2dc0a0a
commit efcab41e04
217 files changed
+2408 -3136

No files matched your search

@@ -5,7 +5,7 @@
******************************************************************************/
package forestry.api.apiculture;
import forestry.api.arboriculture.ITree;
import forestry.api.genetics.IIndividual;
/**
* Easily extendable default IBeeListener.
@@ -24,7 +24,7 @@ public class DefaultBeeListener implements IBeeListener {
}
@Override
public boolean onPollenRetrieved(ITree pollen) {
public boolean onPollenRetrieved(IIndividual pollen) {
return false;
}
@@ -5,7 +5,6 @@
******************************************************************************/
package forestry.api.apiculture;
import javax.annotation.Nonnull;
import java.util.Locale;
import forestry.api.genetics.IAllele;
@@ -23,7 +22,7 @@ import forestry.api.genetics.ISpeciesRoot;
*
* @author SirSengir
*/
public enum BeeChromosome implements IChromosomeType<BeeChromosome> {
public enum EnumBeeChromosome implements IChromosomeType {
/**
* Species of the bee. Alleles here must implement {@link IAlleleBeeSpecies}.
*/
@@ -76,34 +75,25 @@ public enum BeeChromosome implements IChromosomeType<BeeChromosome> {
* Determines the bee's effect.
*/
EFFECT(IAlleleBeeEffect.class);
@Nonnull
private final Class<? extends IAllele> alleleClass;
BeeChromosome(@Nonnull Class<? extends IAllele> alleleClass) {
EnumBeeChromosome(Class<? extends IAllele> alleleClass) {
this.alleleClass = alleleClass;
}
@Nonnull
@Override
public Class<? extends IAllele> getAlleleClass() {
return alleleClass;
}
@Nonnull
@Override
public String getName() {
return this.toString().toLowerCase(Locale.ENGLISH);
}
@Nonnull
@Override
public ISpeciesRoot<BeeChromosome> getSpeciesRoot() {
public ISpeciesRoot getSpeciesRoot() {
return BeeManager.beeRoot;
}
@Override
public byte getUid() {
return (byte) ordinal();
}
}
@@ -15,7 +15,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.genetics.IAlleleSpecies;
public interface IAlleleBeeSpecies extends IAlleleSpecies<BeeChromosome> {
public interface IAlleleBeeSpecies extends IAlleleSpecies {
/**
* @return the IBeeRoot
@@ -7,40 +7,37 @@ package forestry.api.apiculture;
import net.minecraft.item.ItemStack;
import forestry.api.genetics.IAlleleSpeciesBuilder;
import forestry.api.genetics.IAlleleSpeciesCustom;
public interface IAlleleBeeSpeciesBuilder extends IAlleleSpeciesBuilder<BeeChromosome> {
@Override
IAlleleBeeSpecies build();
public interface IAlleleBeeSpeciesCustom extends IAlleleBeeSpecies, IAlleleSpeciesCustom {
/**
* Add a product for this bee species.
* Chance is between 0 and 1.
*/
IAlleleBeeSpeciesBuilder addProduct(ItemStack product, Float chance);
IAlleleBeeSpeciesCustom addProduct(ItemStack product, Float chance);
/**
* Add a specialty product for this bee species.
* Bees only produce their specialty when they are Jubilant (see IJubilanceProvider)
* Chance is between 0 and 1.
*/
IAlleleBeeSpeciesBuilder addSpecialty(ItemStack specialty, Float chance);
IAlleleBeeSpeciesCustom addSpecialty(ItemStack specialty, Float chance);
/**
* Set the Jubilance Provider for this bee species.
* Bees only produce their specialty when they are Jubilant (see IJubilanceProvider)
*/
IAlleleBeeSpeciesBuilder setJubilanceProvider(IJubilanceProvider provider);
IAlleleBeeSpeciesCustom setJubilanceProvider(IJubilanceProvider provider);
/**
* Make this species only active at night.
*/
IAlleleBeeSpeciesBuilder setNocturnal();
IAlleleBeeSpeciesCustom setNocturnal();
/** Use this if you have custom icons for bees. */
IAlleleBeeSpeciesBuilder setCustomBeeModelProvider(IBeeModelProvider beeIconProvider);
IAlleleBeeSpeciesCustom setCustomBeeModelProvider(IBeeModelProvider beeIconProvider);
/** Use this if you have custom icon colours for bees (other than the default static primary + secondary colours). */
IAlleleBeeSpeciesBuilder setCustomBeeSpriteColourProvider(IBeeSpriteColourProvider beeIconColourProvider);
IAlleleBeeSpeciesCustom setCustomBeeSpriteColourProvider(IBeeSpriteColourProvider beeIconColourProvider);
}
@@ -13,7 +13,7 @@ import forestry.api.genetics.IIndividual;
*
* @author SirSengir
*/
public interface IApiaristTracker extends IBreedingTracker<BeeChromosome> {
public interface IApiaristTracker extends IBreedingTracker {
/**
* Register the birth of a queen. Will mark species as discovered.
@@ -21,7 +21,7 @@ public interface IApiaristTracker extends IBreedingTracker<BeeChromosome> {
* @param queen
* Created queen.
*/
void registerQueen(IIndividual<BeeChromosome> queen);
void registerQueen(IIndividual queen);
/**
* @return Amount of queens bred with this tracker.
@@ -34,7 +34,7 @@ public interface IApiaristTracker extends IBreedingTracker<BeeChromosome> {
* @param princess
* Created princess.
*/
void registerPrincess(IIndividual<BeeChromosome> princess);
void registerPrincess(IIndividual princess);
/**
* @return Amount of princesses bred with this tracker.
@@ -47,7 +47,7 @@ public interface IApiaristTracker extends IBreedingTracker<BeeChromosome> {
* @param drone
* Created drone.
*/
void registerDrone(IIndividual<BeeChromosome> drone);
void registerDrone(IIndividual drone);
/**
* @return Amount of drones bred with this tracker.
@@ -13,9 +13,9 @@ import java.util.Set;
import net.minecraft.item.ItemStack;
import net.minecraft.world.biome.BiomeGenBase;
import forestry.api.arboriculture.ITree;
import forestry.api.core.IErrorState;
import forestry.api.genetics.IEffectData;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IIndividualLiving;
/**
@@ -23,7 +23,7 @@ import forestry.api.genetics.IIndividualLiving;
*
* @author SirSengir
*/
public interface IBee extends IIndividualLiving<BeeChromosome> {
public interface IBee extends IIndividualLiving {
/**
* @return Bee's genetic information.
@@ -79,16 +79,14 @@ public interface IBee extends IIndividualLiving<BeeChromosome> {
ItemStack[] produceStacks(IBeeHousing housing);
@Nullable
IBee spawnPrincess(IBeeHousing housing);
@Nullable
IBee[] spawnDrones(IBeeHousing housing);
void plantFlowerRandom(IBeeHousing housing);
ITree retrievePollen(IBeeHousing housing);
IIndividual retrievePollen(IBeeHousing housing);
boolean pollinateRandom(IBeeHousing housing, ITree pollen);
boolean pollinateRandom(IBeeHousing housing, IIndividual pollen);
}
@@ -12,7 +12,7 @@ public interface IBeeFactory {
/**
* Creates a new bee species.
* Automatically registered with AlleleManager.alleleRegistry.registerAllele()
* See IAlleleBeeSpeciesBuilder and IAlleleSpeciesBuilder for adding additional properties to the returned species.
* See IAlleleBeeSpeciesCustom and IAlleleSpeciesCustom for adding additional properties to the returned species.
*
* @param uid Unique Identifier for this species
* @param dominant Whether this species is genetically dominant (false means it is recessive)
@@ -25,7 +25,7 @@ public interface IBeeFactory {
* @param secondaryColor The body color of this species
* @return a new bee species allele.
*/
IAlleleBeeSpeciesBuilder createSpecies(String uid, boolean dominant, String authority, String unlocalizedName, String unlocalizedDescription, IClassification branch, String binomial, int primaryColor, int secondaryColor);
IAlleleBeeSpeciesCustom createSpecies(String uid, boolean dominant, String authority, String unlocalizedName, String unlocalizedDescription, IClassification branch, String binomial, int primaryColor, int secondaryColor);
/**
* Creates a new bee branch.
@@ -5,8 +5,6 @@
******************************************************************************/
package forestry.api.apiculture;
import javax.annotation.Nonnull;
import forestry.api.genetics.EnumTolerance;
import forestry.api.genetics.IFlowerProvider;
import forestry.api.genetics.IGenome;
@@ -17,13 +15,11 @@ import forestry.api.genetics.IGenome;
* @author SirSengir
*
*/
public interface IBeeGenome extends IGenome<BeeChromosome> {
public interface IBeeGenome extends IGenome {
@Nonnull
@Override
IAlleleBeeSpecies getPrimary();
@Nonnull
@Override
IAlleleBeeSpecies getSecondary();
@@ -33,10 +29,8 @@ public interface IBeeGenome extends IGenome<BeeChromosome> {
int getFertility();
@Nonnull
EnumTolerance getToleranceTemp();
@Nonnull
EnumTolerance getToleranceHumid();
boolean getNocturnal();
@@ -45,17 +39,12 @@ public interface IBeeGenome extends IGenome<BeeChromosome> {
boolean getCaveDwelling();
@Nonnull
IFlowerProvider getFlowerProvider();
int getFlowering();
int[] getTerritory();
@Nonnull
IAlleleBeeEffect getEffect();
@Nonnull
@Override
IBeeRoot getSpeciesRoot();
}
@@ -6,8 +6,11 @@
package forestry.api.apiculture;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import com.mojang.authlib.GameProfile;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.core.IErrorLogicSource;
@@ -41,8 +44,12 @@ public interface IBeeHousing extends IHousing, IErrorLogicSource {
boolean canBlockSeeTheSky();
World getWorld();
BiomeGenBase getBiome();
GameProfile getOwner();
/**
* @since Forestry 4.2
* @return exact coordinates where bee FX should spawn from
@@ -5,7 +5,7 @@
******************************************************************************/
package forestry.api.apiculture;
import forestry.api.arboriculture.ITree;
import forestry.api.genetics.IIndividual;
public interface IBeeListener {
@@ -24,6 +24,6 @@ public interface IBeeListener {
* Called when the bees have retrieved some pollen.
* @return true if this bee listener handled the pollen.
*/
boolean onPollenRetrieved(ITree pollen);
boolean onPollenRetrieved(IIndividual pollen);
}
@@ -5,13 +5,10 @@
******************************************************************************/
package forestry.api.apiculture;
import javax.annotation.Nonnull;
import forestry.api.genetics.IMutation;
public interface IBeeMutation extends IMutation<BeeChromosome> {
@Nonnull
public interface IBeeMutation extends IMutation {
@Override
IBeeRoot getRoot();
@@ -5,12 +5,8 @@
******************************************************************************/
package forestry.api.apiculture;
import javax.annotation.Nonnull;
import forestry.api.genetics.IMutationCustom;
import forestry.api.genetics.IMutationBuilder;
public interface IBeeMutationCustom extends IBeeMutation, IMutationCustom {
public interface IBeeMutationBuilder extends IMutationBuilder<BeeChromosome> {
@Nonnull
@Override
IBeeMutation build();
}
@@ -5,15 +5,13 @@
******************************************************************************/
package forestry.api.apiculture;
import com.google.common.collect.ImmutableMap;
import forestry.api.genetics.IAllele;
public interface IBeeMutationFactory {
/**
* Creates a new bee mutation.
* Automatically registered with BeeManager.beeRoot.registerMutation()
* See IBeeMutationBuilder and IMutationBuilder for adding additional properties to the returned mutation.
* See IBeeMutationCustom and IMutationCustom for adding additional properties to the returned mutation.
*
* @param parentBee0 A parent bee for this mutation
* @param parentBee1 A parent bee for this mutation
@@ -21,5 +19,5 @@ public interface IBeeMutationFactory {
* @param chance The chance that breeding the two parent bees will result in this mutation
* @return a new bee mutation.
*/
IBeeMutationBuilder createMutation(IAlleleBeeSpecies parentBee0, IAlleleBeeSpecies parentBee1, ImmutableMap<BeeChromosome, IAllele> result, int chance);
IBeeMutationCustom createMutation(IAlleleBeeSpecies parentBee0, IAlleleBeeSpecies parentBee1, IAllele[] result, int chance);
}
@@ -5,11 +5,8 @@
******************************************************************************/
package forestry.api.apiculture;
import com.google.common.collect.ImmutableMap;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -18,10 +15,9 @@ import net.minecraft.world.World;
import com.mojang.authlib.GameProfile;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IChromosome;
import forestry.api.genetics.ISpeciesRoot;
public interface IBeeRoot extends ISpeciesRoot<BeeChromosome> {
public interface IBeeRoot extends ISpeciesRoot {
/**
* @return true if passed item is a Forestry bee. Equal to getType(ItemStack stack) != EnumBeeType.NONE
@@ -39,23 +35,17 @@ public interface IBeeRoot extends ISpeciesRoot<BeeChromosome> {
IBee getMember(NBTTagCompound compound);
/* GENOME CONVERSION */
@Nonnull
@Override
IBee templateAsIndividual(ImmutableMap<BeeChromosome, IAllele> template);
@Nonnull
@Override
IBee templateAsIndividual(ImmutableMap<BeeChromosome, IAllele> templateActive, ImmutableMap<BeeChromosome, IAllele> templateInactive);
IBee templateAsIndividual(IAllele[] template);
@Override
IBeeGenome templateAsGenome(ImmutableMap<BeeChromosome, IAllele> template);
IBee templateAsIndividual(IAllele[] templateActive, IAllele[] templateInactive);
@Override
IBeeGenome templateAsGenome(ImmutableMap<BeeChromosome, IAllele> templateActive, ImmutableMap<BeeChromosome, IAllele> templateInactive);
IBeeGenome templateAsGenome(IAllele[] template);
@Nonnull
@Override
IBeeGenome chromosomesAsGenome(ImmutableMap<BeeChromosome, IChromosome> chromosomes);
IBeeGenome templateAsGenome(IAllele[] templateActive, IAllele[] templateInactive);
/* BREEDING TRACKER */
@@ -64,8 +54,7 @@ public interface IBeeRoot extends ISpeciesRoot<BeeChromosome> {
* @return {@link IApiaristTracker} associated with the passed world.
*/
@Override
@Nonnull
IApiaristTracker getBreedingTracker(@Nonnull World world, @Nonnull GameProfile player);
IApiaristTracker getBreedingTracker(World world, GameProfile player);
/* BEE SPECIFIC */
@@ -105,26 +94,24 @@ public interface IBeeRoot extends ISpeciesRoot<BeeChromosome> {
/* TEMPLATES */
@Override
List<IBee> getIndividualTemplates();
ArrayList<IBee> getIndividualTemplates();
/* MUTATIONS */
@Override
Collection<IBeeMutation> getMutations(boolean shuffle);
/* GAME MODE */
void registerMode(@Nonnull IBeekeepingMode mode);
void resetBeekeepingMode();
@Nonnull
@Override
List<IBeekeepingMode> getModes();
ArrayList<IBeekeepingMode> getBeekeepingModes();
@Nonnull
@Override
IBeekeepingMode getMode(@Nonnull World world);
IBeekeepingMode getBeekeepingMode(World world);
@Nonnull
@Override
IBeekeepingMode getMode(@Nonnull String name);
IBeekeepingMode getBeekeepingMode(String name);
void registerBeekeepingMode(IBeekeepingMode mode);
void setBeekeepingMode(World world, String name);
/* MISC */
@@ -5,15 +5,18 @@
******************************************************************************/
package forestry.api.apiculture;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import forestry.api.genetics.ISpeciesMode;
public interface IBeekeepingMode {
/**
* @return Localized name of this beekeeping mode.
*/
String getName();
public interface IBeekeepingMode extends ISpeciesMode<BeeChromosome> {
/**
* @return Localized list of strings outlining the behaviour of this beekeeping mode.
*/
@@ -52,6 +55,12 @@ public interface IBeekeepingMode extends ISpeciesMode<BeeChromosome> {
*/
boolean isDegenerating(IBee queen, IBee offspring, IBeeHousing housing);
/**
* @param queen
* @return true if an offspring of this queen is considered a natural
*/
boolean isNaturalOffspring(IBee queen);
/**
* @param queen
* @return true if this mode allows the passed queen or princess to be multiplied
@@ -61,6 +70,5 @@ public interface IBeekeepingMode extends ISpeciesMode<BeeChromosome> {
/**
* @return the bee modifier for this mode
*/
@Nonnull
IBeeModifier getBeeModifier();
}
@@ -5,7 +5,6 @@
******************************************************************************/
package forestry.api.arboriculture;
import javax.annotation.Nonnull;
import java.util.Locale;
import net.minecraftforge.common.EnumPlantType;
@@ -18,8 +17,9 @@ import forestry.api.genetics.IAlleleInteger;
import forestry.api.genetics.IAllelePlantType;
import forestry.api.genetics.IChromosomeType;
import forestry.api.genetics.IFruitFamily;
import forestry.api.genetics.ISpeciesRoot;
public enum TreeChromosome implements IChromosomeType<TreeChromosome> {
public enum EnumTreeChromosome implements IChromosomeType {
/**
* Determines the following: - WorldGen, including the used wood blocks - {@link IFruitFamily}s supported. Limits which {@link IFruitProvider}
@@ -73,32 +73,25 @@ public enum TreeChromosome implements IChromosomeType<TreeChromosome> {
*/
FIREPROOF(IAlleleBoolean.class),;
Class<? extends IAllele> alleleClass;
Class<? extends IAllele> clss;
TreeChromosome(Class<? extends IAllele> alleleClass) {
this.alleleClass = alleleClass;
EnumTreeChromosome(Class<? extends IAllele> clss) {
this.clss = clss;
}
@Nonnull
@Override
public Class<? extends IAllele> getAlleleClass() {
return alleleClass;
return clss;
}
@Nonnull
@Override
public String getName() {
return this.toString().toLowerCase(Locale.ENGLISH);
}
@Nonnull
@Override
public ITreeRoot getSpeciesRoot() {
public ISpeciesRoot getSpeciesRoot() {
return TreeManager.treeRoot;
}
@Override
public byte getUid() {
return (byte) ordinal();
}
}
@@ -18,7 +18,7 @@ import forestry.api.genetics.IAlleleProperty;
import forestry.api.genetics.IAlleleSpecies;
import forestry.api.genetics.IFruitFamily;
public interface IAlleleTreeSpecies extends IAlleleSpecies<TreeChromosome>, IAlleleProperty<IAlleleTreeSpecies> {
public interface IAlleleTreeSpecies extends IAlleleSpecies, IAlleleProperty<IAlleleTreeSpecies> {
@Override
ITreeRoot getRoot();
@@ -7,17 +7,15 @@ package forestry.api.arboriculture;
import net.minecraftforge.common.EnumPlantType;
import forestry.api.genetics.IAlleleSpeciesBuilder;
import forestry.api.genetics.IAlleleSpeciesCustom;
import forestry.api.genetics.IFruitFamily;
public interface IAlleleTreeSpeciesBuilder extends IAlleleSpeciesBuilder<TreeChromosome> {
@Override
IAlleleTreeSpecies build();
public interface IAlleleTreeSpeciesCustom extends IAlleleSpeciesCustom, IAlleleTreeSpecies {
/** Add a fruit family for this tree. Trees can have multiple fruit families. */
IAlleleTreeSpeciesBuilder addFruitFamily(IFruitFamily family);
IAlleleTreeSpeciesCustom addFruitFamily(IFruitFamily family);
/** Set the minecraft plant type for this tree. Default is Plains. */
IAlleleTreeSpeciesBuilder setPlantType(EnumPlantType type);
IAlleleTreeSpeciesCustom setPlantType(EnumPlantType type);
}
@@ -7,6 +7,6 @@ package forestry.api.arboriculture;
import forestry.api.genetics.IBreedingTracker;
public interface IArboristTracker extends IBreedingTracker<TreeChromosome> {
public interface IArboristTracker extends IBreedingTracker {
}
@@ -6,7 +6,6 @@
package forestry.api.arboriculture;
import javax.annotation.Nonnull;
import java.util.Collection;
import java.util.EnumSet;
import net.minecraft.item.ItemStack;
@@ -23,7 +22,7 @@ import forestry.api.genetics.IEffectData;
import forestry.api.genetics.IIndividual;
import forestry.api.world.ITreeGenData;
public interface ITree extends IIndividual<TreeChromosome>, ITreeGenData {
public interface ITree extends IIndividual, ITreeGenData {
void mate(ITree other);
@@ -39,7 +38,10 @@ public interface ITree extends IIndividual<TreeChromosome>, ITreeGenData {
EnumSet<EnumPlantType> getPlantTypes();
Collection<ITree> getSaplings(World world, GameProfile playerProfile, BlockPos pos, float modifier);
/**
* @since Forestry 4.0
*/
ITree[] getSaplings(World world, GameProfile playerProfile, BlockPos pos, float modifier);
ItemStack[] getProduceList();
@@ -84,8 +86,7 @@ public interface ITree extends IIndividual<TreeChromosome>, ITreeGenData {
@Override
ITree copy();
@Override
boolean isPureBred(TreeChromosome chromosome);
boolean isPureBred(EnumTreeChromosome chromosome);
boolean canBearFruit();
}
@@ -13,7 +13,7 @@ public interface ITreeFactory {
/**
* Creates a new tree species.
* Automatically registered with AlleleManager.alleleRegistry.registerAllele()
* See IAlleleTreeSpeciesBuilder and IAlleleSpeciesBuilder for adding additional properties to the returned species.
* See IAlleleTreeSpeciesCustom and IAlleleSpeciesCustom for adding additional properties to the returned species.
*
* @param uid Unique Identifier for this species
* @param unlocalizedName Unlocalized name for this species
@@ -28,7 +28,7 @@ public interface ITreeFactory {
* @param generator The tree generator
* @return a new tree species allele.
*/
IAlleleTreeSpeciesBuilder createSpecies(String uid, String unlocalizedName, String authority, String unlocalizedDescription, boolean dominant, IClassification branch, String binomial, String mdoelName, ILeafSpriteProvider leafSpriteProvider, IGermlingModelProvider germlingModelProvider, ITreeGenerator generator);
IAlleleTreeSpeciesCustom createSpecies(String uid, String unlocalizedName, String authority, String unlocalizedDescription, boolean dominant, IClassification branch, String binomial, String mdoelName, ILeafSpriteProvider leafSpriteProvider, IGermlingModelProvider germlingModelProvider, ITreeGenerator generator);
/** Get one of the built-in Forestry leaf types. Default type is deciduous. */
ILeafSpriteProvider getLeafIconProvider(EnumLeafType enumLeafType, Color color, Color colorPollinated);
@@ -5,20 +5,17 @@
******************************************************************************/
package forestry.api.arboriculture;
import javax.annotation.Nonnull;
import java.util.EnumSet;
import net.minecraftforge.common.EnumPlantType;
import forestry.api.genetics.IGenome;
public interface ITreeGenome extends IGenome<TreeChromosome> {
public interface ITreeGenome extends IGenome {
@Nonnull
@Override
IAlleleTreeSpecies getPrimary();
@Nonnull
@Override
IAlleleTreeSpecies getSecondary();
@@ -48,8 +45,4 @@ public interface ITreeGenome extends IGenome<TreeChromosome> {
int getGirth();
IAlleleLeafEffect getEffect();
@Nonnull
@Override
ITreeRoot getSpeciesRoot();
}
@@ -34,4 +34,12 @@ public interface ITreeModifier {
* @return Float used to modify the maturation.
*/
float getMaturationModifier(ITreeGenome genome, float currentModifier);
/**
* @param genome0
* @param genome1
* @return Float used to modify the base mutation chance.
*/
float getMutationModifier(ITreeGenome genome0, ITreeGenome genome1, float currentModifier);
}
@@ -5,24 +5,23 @@
******************************************************************************/
package forestry.api.arboriculture;
import javax.annotation.Nonnull;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import forestry.api.genetics.IMutation;
import forestry.api.genetics.ISpeciesRoot;
public interface ITreeMutation extends IMutation<TreeChromosome> {
public interface ITreeMutation extends IMutation {
/**
* @return {@link ISpeciesRoot} this mutation is associated with.
*/
@Nonnull
@Override
ITreeRoot getRoot();
// /**
// * @return float representing the percent chance for mutation to occur, from 0.0 to 100.0.
// * @since Forestry 4.0
// */
// @Override
// float getChance(World world, BlockPos pos, IAlleleTreeSpecies allele0, IAlleleTreeSpecies allele1, ITreeGenome genome0, ITreeGenome genome1);
/**
* @return float representing the percent chance for mutation to occur, from 0.0 to 100.0.
* @since Forestry 4.0
*/
float getChance(World world, BlockPos pos, IAlleleTreeSpecies allele0, IAlleleTreeSpecies allele1, ITreeGenome genome0, ITreeGenome genome1);
}
@@ -5,12 +5,8 @@
******************************************************************************/
package forestry.api.arboriculture;
import javax.annotation.Nonnull;
import forestry.api.genetics.IMutationCustom;
import forestry.api.genetics.IMutationBuilder;
public interface ITreeMutationCustom extends ITreeMutation, IMutationCustom {
public interface ITreeMutationBuilder extends IMutationBuilder<TreeChromosome> {
@Nonnull
@Override
ITreeMutation build();
}
@@ -5,15 +5,13 @@
******************************************************************************/
package forestry.api.arboriculture;
import com.google.common.collect.ImmutableMap;
import forestry.api.genetics.IAllele;
public interface ITreeMutationFactory {
/**
* Creates a new tree mutation.
* Automatically registered with TreeManager.treeRoot.registerMutation()
* See ITreeMutationBuilder and IMutationBuilder for adding additional properties to the returned mutation.
* See ITreeMutationCustom and IMutationCustom for adding additional properties to the returned mutation.
*
* @param parentTree0 A parent tree for this mutation
* @param parentTree1 A parent tree for this mutation
@@ -21,5 +19,5 @@ public interface ITreeMutationFactory {
* @param chance The chance that breeding the two parent trees will result in this mutation
* @return a new tree mutation.
*/
ITreeMutationBuilder createMutation(IAlleleTreeSpecies parentTree0, IAlleleTreeSpecies parentTree1, ImmutableMap<TreeChromosome, IAllele> result, int chance);
ITreeMutationCustom createMutation(IAlleleTreeSpecies parentTree0, IAlleleTreeSpecies parentTree1, IAllele[] result, int chance);
}
@@ -5,12 +5,8 @@
******************************************************************************/
package forestry.api.arboriculture;
import com.google.common.collect.ImmutableMap;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -23,7 +19,7 @@ import forestry.api.genetics.IAllele;
import forestry.api.genetics.IChromosome;
import forestry.api.genetics.ISpeciesRoot;
public interface ITreeRoot extends ISpeciesRoot<TreeChromosome> {
public interface ITreeRoot extends ISpeciesRoot {
@Override
boolean isMember(ItemStack itemstack);
@@ -34,30 +30,24 @@ public interface ITreeRoot extends ISpeciesRoot<TreeChromosome> {
@Override
ITree getMember(NBTTagCompound compound);
@Nonnull
@Override
ITree templateAsIndividual(ImmutableMap<TreeChromosome, IAllele> template);
@Nonnull
@Override
ITree templateAsIndividual(ImmutableMap<TreeChromosome, IAllele> templateActive, ImmutableMap<TreeChromosome, IAllele> templateInactive);
ITree templateAsIndividual(IAllele[] template);
@Override
ITreeGenome templateAsGenome(ImmutableMap<TreeChromosome, IAllele> template);
ITree templateAsIndividual(IAllele[] templateActive, IAllele[] templateInactive);
@Override
ITreeGenome templateAsGenome(ImmutableMap<TreeChromosome, IAllele> templateActive, ImmutableMap<TreeChromosome, IAllele> templateInactive);
ITreeGenome templateAsGenome(IAllele[] template);
@Nonnull
@Override
ITreeGenome chromosomesAsGenome(ImmutableMap<TreeChromosome, IChromosome> chromosomes);
ITreeGenome templateAsGenome(IAllele[] templateActive, IAllele[] templateInactive);
/**
* @param world
* @return {@link IArboristTracker} associated with the passed world.
*/
@Nonnull
@Override
IArboristTracker getBreedingTracker(@Nonnull World world, @Nonnull GameProfile player);
IArboristTracker getBreedingTracker(World world, GameProfile player);
/* TREE SPECIFIC */
@@ -82,27 +72,23 @@ public interface ITreeRoot extends ISpeciesRoot<TreeChromosome> {
boolean plantSapling(World world, ITree tree, GameProfile owner, BlockPos pos);
@Override
ImmutableMap<TreeChromosome, IChromosome> templateAsChromosomes(ImmutableMap<TreeChromosome, IAllele> template);
IChromosome[] templateAsChromosomes(IAllele[] template);
@Override
ImmutableMap<TreeChromosome, IChromosome> templateAsChromosomes(ImmutableMap<TreeChromosome, IAllele> templateActive, ImmutableMap<TreeChromosome, IAllele> templateInactive);
IChromosome[] templateAsChromosomes(IAllele[] templateActive, IAllele[] templateInactive);
boolean setFruitBlock(World world, IAlleleFruit allele, float sappiness, short[] indices, BlockPos pos);
/* GAME MODE */
@Nonnull
@Override
List<ITreekeepingMode> getModes();
ArrayList<ITreekeepingMode> getTreekeepingModes();
@Nonnull
@Override
ITreekeepingMode getMode(@Nonnull World world);
ITreekeepingMode getTreekeepingMode(World world);
@Nonnull
@Override
ITreekeepingMode getMode(@Nonnull String name);
ITreekeepingMode getTreekeepingMode(String name);
void registerMode(@Nonnull ITreekeepingMode mode);
void registerTreekeepingMode(ITreekeepingMode mode);
void setTreekeepingMode(World world, String name);
/* TEMPLATES */
@Override
@@ -5,18 +5,18 @@
******************************************************************************/
package forestry.api.arboriculture;
import javax.annotation.Nonnull;
import java.util.List;
import java.util.ArrayList;
import forestry.api.genetics.ISpeciesMode;
public interface ITreekeepingMode extends ITreeModifier {
public interface ITreekeepingMode extends ISpeciesMode<TreeChromosome> {
/**
* @return Localized name of this treekeeping mode.
*/
String getName();
/**
* @return Localized list of strings outlining the behaviour of this treekeeping mode.
*/
List<String> getDescription();
ArrayList<String> getDescription();
@Nonnull
ITreeModifier getTreeModifier();
}
@@ -5,10 +5,8 @@
******************************************************************************/
package forestry.api.core;
import javax.annotation.Nonnull;
import net.minecraft.nbt.NBTTagCompound;
public interface INbtWritable {
void writeToNBT(@Nonnull NBTTagCompound nbt);
void writeToNBT(NBTTagCompound nbt);
}
@@ -5,8 +5,6 @@
******************************************************************************/
package forestry.api.genetics;
import javax.annotation.Nonnull;
/**
* An {@link IIndividual}'s {@link IGenome} is composed of {@link IChromosome}s consisting each of a primary and secondary {@link IAllele}.
*
@@ -21,7 +19,6 @@ public interface IAllele {
/**
* @return A unique string identifier for this allele.
*/
@Nonnull
String getUID();
/**
@@ -32,13 +29,11 @@ public interface IAllele {
/**
* @return Localized short, human-readable identifier used in tooltips and beealyzer.
*/
@Nonnull
String getName();
/**
* @return The unlocalized identifier
*/
@Nonnull
String getUnlocalizedName();
}
@@ -31,7 +31,7 @@ public interface IAlleleFactory {
* @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. TreeChromosome.HEIGHT)
* @param types allele chromosome type for registration (i.e. EnumTreeChromosome.HEIGHT)
* @return a new IAlleleFloat, registered with the allele registry.
* @since Forestry 4.2
*/
@@ -45,7 +45,7 @@ public interface IAlleleFactory {
* @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. BeeChromosome.TERRITORY)
* @param types allele chromosome type for registration (i.e. EnumBeeChromosome.TERRITORY)
* @return a new IAlleleArea, registered with the allele registry.
* @since Forestry 4.2
*/
@@ -57,7 +57,7 @@ public interface IAlleleFactory {
* @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. BeeChromosome.FERTILITY)
* @param types allele chromosome type for registration (i.e. EnumBeeChromosome.FERTILITY)
* @return a new IAlleleInteger, registered with the allele registry.
* @since Forestry 4.2
*/
@@ -68,7 +68,7 @@ public interface IAlleleFactory {
* @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. TreeChromosome.FIREPROOF)
* @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
@@ -81,7 +81,7 @@ public interface IAlleleFactory {
* @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. BeeChromosome.FLOWER_PROVIDER)
* @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
@@ -5,7 +5,6 @@
******************************************************************************/
package forestry.api.genetics;
import javax.annotation.Nullable;
import java.util.Collection;
import java.util.Map;
@@ -28,7 +27,7 @@ public interface IAlleleRegistry {
* Register a {@link ISpeciesRoot}.
* @param root {@link ISpeciesRoot} to register.
*/
void registerSpeciesRoot(ISpeciesRoot<?> root);
void registerSpeciesRoot(ISpeciesRoot root);
/**
* @return Map of all registered {@link ISpeciesRoot}.
@@ -40,21 +39,21 @@ public interface IAlleleRegistry {
* @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);
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);
ISpeciesRoot getSpeciesRoot(ItemStack stack);
/**
* Retrieve a matching {@link ISpeciesRoot} for the given {@link IIndividual}-class.
* @param individualClass Class extending {@link IIndividual}.
* @param clz Class extending {@link IIndividual}.
* @return {@link ISpeciesRoot} if found, null otherwise.
*/
ISpeciesRoot<?> getSpeciesRoot(Class<? extends IIndividual> individualClass);
ISpeciesRoot getSpeciesRoot(Class<? extends IIndividual> clz);
/* INDIVIDUAL */
@@ -73,8 +72,7 @@ public interface IAlleleRegistry {
* Stack to retrieve genetic information for.
* @return IIndividual containing genetic information, null if none could be extracted.
*/
@Nullable
IIndividual<?> getIndividual(ItemStack stack);
IIndividual getIndividual(ItemStack stack);
/* ALLELES */
@@ -93,7 +91,7 @@ public interface IAlleleRegistry {
* @param chromosomeTypes valid chromosomeTypes for this allele.
* @since Forestry 4.2
*/
void registerAllele(IAllele allele, IChromosomeType<?>... chromosomeTypes);
void registerAllele(IAllele allele, IChromosomeType... chromosomeTypes);
/**
* @return HashMap of all registered deprecated alleles and their corresponding replacements
@@ -123,9 +121,7 @@ public interface IAlleleRegistry {
* @return unmodifiable collection of all the known allele variations for the given chromosome type.
* @since Forestry 4.2
*/
Collection<IAllele> getRegisteredAlleles(IChromosomeType<?> type);
Collection<IChromosomeType<?>> getChromosomeTypes(IAllele allele);
Collection<IAllele> getRegisteredAlleles(IChromosomeType type);
/* CLASSIFICATIONS */
@@ -20,12 +20,12 @@ import forestry.api.core.IModelProvider;
/**
* Basic species allele.
*/
public interface IAlleleSpecies<C extends IChromosomeType> extends IAllele {
public interface IAlleleSpecies extends IAllele {
/**
* @return the {@link ISpeciesRoot} associated with this species.
*/
ISpeciesRoot<C> getRoot();
ISpeciesRoot getRoot();
/**
* @return Localized short description of this species. (May be null.)
@@ -74,7 +74,7 @@ public interface IAlleleSpecies<C extends IChromosomeType> extends IAllele {
* @param bountyLevel
* @return Array of itemstacks representing the bounty for this research success.
*/
ItemStack[] getResearchBounty(World world, GameProfile gameProfile, IIndividual<C> individual, int bountyLevel);
ItemStack[] getResearchBounty(World world, GameProfile gameProfile, IIndividual individual, int bountyLevel);
/* CLIMATE */
@@ -8,19 +8,17 @@ package forestry.api.genetics;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
public interface IAlleleSpeciesBuilder<C extends IChromosomeType> {
public interface IAlleleSpeciesCustom extends IAlleleSpecies {
IAlleleSpecies<C> build();
IAlleleSpeciesCustom setTemperature(EnumTemperature temperature);
IAlleleSpeciesBuilder<C> setTemperature(EnumTemperature temperature);
IAlleleSpeciesCustom setHumidity(EnumHumidity humidity);
IAlleleSpeciesBuilder<C> setHumidity(EnumHumidity humidity);
IAlleleSpeciesBuilder<C> setHasEffect();
IAlleleSpeciesCustom setHasEffect();
/** Secret species are not shown in creative mode. */
IAlleleSpeciesBuilder<C> setIsSecret();
IAlleleSpeciesCustom setIsSecret();
/** Uncounted species do not count toward total species discovered. */
IAlleleSpeciesBuilder<C> setIsNotCounted();
IAlleleSpeciesCustom setIsNotCounted();
}
@@ -15,7 +15,7 @@ import forestry.api.apiculture.IBeekeepingMode;
*
* @author SirSengir
*/
public interface IBreedingTracker<C extends IChromosomeType> {
public interface IBreedingTracker {
/**
* @return Name of the current {@link IBeekeepingMode}.
@@ -37,28 +37,28 @@ public interface IBreedingTracker<C extends IChromosomeType> {
*
* @param individual
*/
void registerBirth(IIndividual<C> individual);
void registerBirth(IIndividual individual);
/**
* Register the pickup of an individual.
*
* @param individual
*/
void registerPickup(IIndividual<C> individual);
void registerPickup(IIndividual individual);
/**
* Marks a species as discovered. Should only be called from registerIndividual normally.
*
* @param species
*/
void registerSpecies(IAlleleSpecies<C> species);
void registerSpecies(IAlleleSpecies species);
/**
* Register a successful mutation. Will mark it as discovered.
*
* @param mutation
*/
void registerMutation(IMutation<C> mutation);
void registerMutation(IMutation mutation);
/**
* Queries the tracker for discovered species.
@@ -67,7 +67,7 @@ public interface IBreedingTracker<C extends IChromosomeType> {
* Mutation to query for.
* @return true if the mutation has been discovered.
*/
boolean isDiscovered(IMutation<C> mutation);
boolean isDiscovered(IMutation mutation);
/**
* Queries the tracker for discovered species.
@@ -76,7 +76,7 @@ public interface IBreedingTracker<C extends IChromosomeType> {
* Species to check.
* @return true if the species has been bred.
*/
boolean isDiscovered(IAlleleSpecies<C> species);
boolean isDiscovered(IAlleleSpecies species);
/**
* Register a successfully researched mutation.
@@ -84,12 +84,12 @@ public interface IBreedingTracker<C extends IChromosomeType> {
* Researched mutations may have bonuses such as occurring at a higher rate.
* Researched mutations count as discovered.
*/
void researchMutation(IMutation<C> mutation);
void researchMutation(IMutation mutation);
/**
* @return true if the mutation has been researched.
*/
boolean isResearched(IMutation<C> mutation);
boolean isResearched(IMutation mutation);
/**
* Synchronizes the tracker to the client side.
@@ -5,8 +5,6 @@
******************************************************************************/
package forestry.api.genetics;
import javax.annotation.Nonnull;
import forestry.api.core.INbtWritable;
/**
@@ -16,16 +14,12 @@ import forestry.api.core.INbtWritable;
*/
public interface IChromosome extends INbtWritable {
@Nonnull
IAllele getPrimaryAllele();
@Nonnull
IAllele getSecondaryAllele();
@Nonnull
IAllele getInactiveAllele();
@Nonnull
IAllele getActiveAllele();
}
@@ -5,25 +5,20 @@
******************************************************************************/
package forestry.api.genetics;
import javax.annotation.Nonnull;
/*
* Interface to be implemented by the enums representing the various chromosomes
*/
public interface IChromosomeType<C extends IChromosomeType<C>> {
public interface IChromosomeType {
/*
* Get class which all alleles on this chromosome must interface
*/
@Nonnull
Class<? extends IAllele> getAlleleClass();
@Nonnull
String getName();
@Nonnull
ISpeciesRoot<C> getSpeciesRoot();
ISpeciesRoot getSpeciesRoot();
byte getUid();
int ordinal();
}
@@ -5,8 +5,6 @@
******************************************************************************/
package forestry.api.genetics;
import java.util.Collection;
/**
* Biological classifications from domain down to genus.
*
@@ -76,7 +74,7 @@ public interface IClassification {
/**
* @return Member groups of this one.
*/
Collection<IClassification> getMemberGroups();
IClassification[] getMemberGroups();
/**
* Adds subgroups to this group.
@@ -86,14 +84,14 @@ public interface IClassification {
/**
* @return Member species of this group.
*/
Collection<IAlleleSpecies<?>> getMemberSpecies();
IAlleleSpecies[] getMemberSpecies();
/**
* Used by the allele registry to populate internal collection of branch members on the fly.
*
* @param species
*/
void addMemberSpecies(IAlleleSpecies<?> species);
void addMemberSpecies(IAlleleSpecies species);
/**
* @return Parent classification, null if this is root.
@@ -5,27 +5,23 @@
******************************************************************************/
package forestry.api.genetics;
import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
public interface IFlowerProvider {
boolean isAcceptedPollinatable(@Nonnull World world, @Nonnull IPollinatable pollinatable);
boolean isAcceptedPollinatable(World world, IPollinatable pollinatable);
/**
* @return The unique type used for the IFlowerRegistry
* @since Forestry 4.0.0
*/
@Nonnull
String getFlowerType();
/**
* @return Short, human-readable identifier used in the beealyzer.
*/
@Nonnull
String getDescription();
/**
@@ -33,6 +29,5 @@ public interface IFlowerProvider {
* If this flowerProvider does not affect the products, it should return the products unchanged.
* @return Array of itemstacks being the (modified or unmodified) produce.
*/
@Nonnull
ItemStack[] affectProducts(World world, IIndividual individual, BlockPos pos, ItemStack[] products);
}
@@ -5,10 +5,6 @@
******************************************************************************/
package forestry.api.genetics;
import com.google.common.collect.ImmutableMap;
import javax.annotation.Nonnull;
import forestry.api.core.INbtWritable;
/**
@@ -16,25 +12,19 @@ import forestry.api.core.INbtWritable;
*
* Only the default implementation is supported.
*/
public interface IGenome<C extends IChromosomeType> extends INbtWritable {
public interface IGenome extends INbtWritable {
@Nonnull
IAlleleSpecies<C> getPrimary();
IAlleleSpecies getPrimary();
@Nonnull
IAlleleSpecies<C> getSecondary();
IAlleleSpecies getSecondary();
@Nonnull
ImmutableMap<C, IChromosome> getChromosomes();
IChromosome[] getChromosomes();
@Nonnull
IAllele getActiveAllele(C chromosomeType);
IAllele getActiveAllele(IChromosomeType chromosomeType);
@Nonnull
IAllele getInactiveAllele(C chromosomeType);
IAllele getInactiveAllele(IChromosomeType chromosomeType);
boolean isGeneticEqual(IGenome<C> other);
@Nonnull
ISpeciesRoot<C> getSpeciesRoot();
boolean isGeneticEqual(IGenome other);
ISpeciesRoot getSpeciesRoot();
}
@@ -6,9 +6,6 @@
package forestry.api.genetics;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import com.mojang.authlib.GameProfile;
/**
* Any housing, hatchery or nest with a location in the world.
@@ -17,8 +14,4 @@ public interface IHousing {
BlockPos getCoordinates();
World getWorld();
GameProfile getOwner();
}
@@ -15,7 +15,7 @@ import forestry.api.core.INbtWritable;
*
* Only the default implementation is supported.
*/
public interface IIndividual<C extends IChromosomeType> extends INbtWritable {
public interface IIndividual extends INbtWritable {
String getIdent();
@@ -36,20 +36,20 @@ public interface IIndividual<C extends IChromosomeType> extends INbtWritable {
boolean isSecret();
@Nonnull
IGenome<C> getGenome();
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<C> other);
boolean isGeneticEqual(IIndividual other);
/**
* @return A deep copy of this individual.
*/
IIndividual<C> copy();
IIndividual copy();
boolean isPureBred(C chromosomeType);
boolean isPureBred(IChromosomeType chromosomeType);
}
@@ -7,7 +7,7 @@ package forestry.api.genetics;
import net.minecraft.world.World;
public interface IIndividualLiving<C extends IChromosomeType> extends IIndividual<C> {
public interface IIndividualLiving extends IIndividual {
/**
* @return Genetic information of the mate, null if unmated.
@@ -5,17 +5,8 @@
******************************************************************************/
package forestry.api.genetics;
import com.google.common.collect.ImmutableMap;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Collection;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import forestry.api.core.INbtWritable;
/**
* Individuals can be seeded either as hive drops or as mutation results.
*
@@ -23,43 +14,38 @@ import forestry.api.core.INbtWritable;
*
* @author SirSengir
*/
public interface IMutation<C extends IChromosomeType> extends INbtWritable {
public interface IMutation {
/**
* @return {@link ISpeciesRoot} this mutation is associated with.
*/
@Nonnull
ISpeciesRoot<C> getRoot();
ISpeciesRoot getRoot();
/**
* @return first of the alleles implementing IAlleleSpecies required for this mutation.
*/
@Nonnull
IAlleleSpecies<C> getSpecies0();
IAlleleSpecies getAllele0();
/**
* @return second of the alleles implementing IAlleleSpecies required for this mutation.
*/
@Nonnull
IAlleleSpecies<C> getSpecies1();
IAlleleSpecies getAllele1();
/**
* @return The full default genome of the mutated side.
* @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.
*/
@Nonnull
ImmutableMap<C, IAllele> getResultTemplate();
IAllele[] getTemplate();
/**
* @return Unmodified base chance for mutation to fire.
*/
float getBaseChance();
float getChance(World world, BlockPos pos, IAlleleSpecies<C> species0, IAlleleSpecies<C> species1, IGenome<C> genome0, IGenome<C> genome1);
/**
* @return Collection of localized, human-readable strings describing special mutation conditions, if any.
*/
@Nonnull
Collection<String> getSpecialConditions();
/**
@@ -72,7 +58,6 @@ public interface IMutation<C extends IChromosomeType> extends INbtWritable {
* @param allele
* @return the other allele which was not passed as argument.
*/
@Nullable
IAllele getPartner(IAllele allele);
/**
@@ -15,7 +15,7 @@ public interface IMutationCondition {
* Most will return 1 if the condition is met and 0 otherwise,
* but the float offers flexibility for more advanced conditions.
*/
<C extends IChromosomeType> float getChance(World world, BlockPos pos, IAlleleSpecies<C> species0, IAlleleSpecies<C> species1, IGenome<C> genome0, IGenome<C> genome1);
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.")
@@ -5,8 +5,6 @@
******************************************************************************/
package forestry.api.genetics;
import javax.annotation.Nonnull;
import net.minecraft.block.Block;
import net.minecraftforge.common.BiomeDictionary;
@@ -15,42 +13,40 @@ import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
/** Set custom mutation requirements */
public interface IMutationBuilder<C extends IChromosomeType<C>> {
@Nonnull
IMutation<C> build();
public interface IMutationCustom extends IMutation {
/** Prevent this mutation from being shown in the analyzers */
IMutationBuilder<C> setIsSecret();
IMutationCustom setIsSecret();
/** Require a specific temperature for this mutation to occur */
IMutationBuilder<C> restrictTemperature(EnumTemperature temperature);
IMutationCustom restrictTemperature(EnumTemperature temperature);
IMutationBuilder<C> restrictTemperature(EnumTemperature minTemperature, EnumTemperature maxTemperature);
IMutationCustom restrictTemperature(EnumTemperature minTemperature, EnumTemperature maxTemperature);
/** Require a specific humidity for this mutation to occur */
IMutationBuilder<C> restrictHumidity(EnumHumidity humidity);
IMutationCustom restrictHumidity(EnumHumidity humidity);
IMutationBuilder<C> restrictHumidity(EnumHumidity minHumidity, EnumHumidity maxHumidity);
IMutationCustom restrictHumidity(EnumHumidity minHumidity, EnumHumidity maxHumidity);
/**
* Restrict this mutation to certain types of biomes.
* @param types The types of biomes this mutation can occur.
*/
IMutationBuilder<C> restrictBiomeType(BiomeDictionary.Type... types);
IMutationCustom restrictBiomeType(BiomeDictionary.Type... types);
/** Restrict the days of the year that this mutation can occur */
IMutationBuilder<C> restrictDateRange(int startMonth, int startDay, int endMonth, int endDay);
IMutationCustom restrictDateRange(int startMonth, int startDay, int endMonth, int endDay);
/** Restrict the time of day that this mutation can occur */
IMutationBuilder<C> requireDay();
IMutationCustom requireDay();
IMutationBuilder<C> requireNight();
IMutationCustom requireNight();
/** Require a specific resource to be under the location of the mutation */
IMutationBuilder<C> requireResource(Block block, int meta);
IMutationCustom requireResource(Block block, int meta);
IMutationBuilder<C> requireResource(String oreDictName);
IMutationCustom requireResource(String oreDictName);
/** Require some other custom mutation condition */
IMutationBuilder<C> addMutationCondition(IMutationCondition mutationCondition);
IMutationCustom addMutationCondition(IMutationCondition mutationCondition);
}
@@ -9,8 +9,6 @@ import java.util.EnumSet;
import net.minecraftforge.common.EnumPlantType;
import forestry.api.arboriculture.ITree;
/**
* Can be implemented by tile entities, if they wish to be pollinatable.
*
@@ -26,7 +24,7 @@ public interface IPollinatable {
/**
* @return IIndividual containing the genetic information of this IPollinatable
*/
ITree getPollen();
IIndividual getPollen();
/**
* Checks whether this {@link IPollinatable} can mate with the given pollen.
@@ -37,7 +35,7 @@ public interface IPollinatable {
* IIndividual representing the pollen.
* @return true if mating is possible, false otherwise.
*/
boolean canMateWith(ITree pollen);
boolean canMateWith(IIndividual pollen);
/**
* Pollinates this entity.
@@ -45,7 +43,7 @@ public interface IPollinatable {
* @param pollen
* IIndividual representing the pollen.
*/
void mateWith(ITree pollen);
void mateWith(IIndividual pollen);
/**
* @return true if this IPollinatable has already been pollinated.
@@ -1,17 +0,0 @@
package forestry.api.genetics;
import javax.annotation.Nonnull;
public interface ISpeciesMode<C extends IChromosomeType> {
/**
* @return Localized name of this mode.
*/
@Nonnull
String getName();
/**
* @return Float used to modify the base mutation chance.
*/
float getMutationModifier(IGenome<C> genome, IGenome<C> mate);
}
@@ -5,10 +5,7 @@
******************************************************************************/
package forestry.api.genetics;
import com.google.common.collect.ImmutableMap;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -23,7 +20,7 @@ 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<C extends IChromosomeType> {
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".
@@ -33,7 +30,7 @@ public interface ISpeciesRoot<C extends IChromosomeType> {
/**
* @return Class of the sub-interface inheriting from {@link IIndividual}.
*/
Class<? extends IIndividual<C>> getMemberClass();
Class<? extends IIndividual> getMemberClass();
/**
* @return Integer denoting the number of (counted) species of this type in the world.
@@ -62,38 +59,29 @@ public interface ISpeciesRoot<C extends IChromosomeType> {
*/
boolean isMember(IIndividual individual);
@Nullable
IIndividual<C> getMember(ItemStack stack);
IIndividual getMember(ItemStack stack);
@Nullable
IIndividual<C> getMember(NBTTagCompound compound);
IIndividual getMember(NBTTagCompound compound);
@Nullable
ISpeciesType getType(ItemStack itemStack);
ItemStack getMemberStack(IIndividual<C> individual, int type);
ItemStack getMemberStack(IIndividual individual, int type);
/* BREEDING TRACKER */
@Nonnull
IBreedingTracker<C> getBreedingTracker(@Nonnull World world, @Nonnull GameProfile player);
IBreedingTracker getBreedingTracker(World world, GameProfile player);
/* GENOME MANIPULATION */
@Nonnull
IIndividual<C> templateAsIndividual(ImmutableMap<C, IAllele> template);
IIndividual templateAsIndividual(IAllele[] template);
@Nonnull
IIndividual<C> templateAsIndividual(ImmutableMap<C, IAllele> templateActive, ImmutableMap<C, IAllele> templateInactive);
IIndividual templateAsIndividual(IAllele[] templateActive, IAllele[] templateInactive);
ImmutableMap<C, IChromosome> templateAsChromosomes(ImmutableMap<C, IAllele> template);
IChromosome[] templateAsChromosomes(IAllele[] template);
ImmutableMap<C, IChromosome> templateAsChromosomes(ImmutableMap<C, IAllele> templateActive, ImmutableMap<C, IAllele> templateInactive);
IChromosome[] templateAsChromosomes(IAllele[] templateActive, IAllele[] templateInactive);
IGenome<C> templateAsGenome(ImmutableMap<C, IAllele> template);
IGenome templateAsGenome(IAllele[] template);
IGenome<C> templateAsGenome(ImmutableMap<C, IAllele> templateActive, ImmutableMap<C, IAllele> templateInactive);
@Nonnull
IGenome<C> chromosomesAsGenome(ImmutableMap<C, IChromosome> chromosomes);
IGenome templateAsGenome(IAllele[] templateActive, IAllele[] templateInactive);
/* TEMPLATES */
@@ -102,38 +90,37 @@ public interface ISpeciesRoot<C extends IChromosomeType> {
*
* @param template
*/
void registerTemplate(ImmutableMap<C, IAllele> template);
void registerTemplate(IAllele[] template);
/**
* Registers a bee template using the passed identifier.
*
* @param template
*/
void registerTemplate(String identifier, ImmutableMap<C, IAllele> template);
void registerTemplate(String identifier, IAllele[] template);
/**
* Retrieves a registered template using the passed identifier.
*
* @param identifier
* @return Map of {@link IAllele} representing a genome.
* @return Array of {@link IAllele} representing a genome.
*/
@Nullable
ImmutableMap<C, IAllele> getTemplate(String identifier);
IAllele[] getTemplate(String identifier);
/**
* @return Default individual template for use when stuff breaks.
*/
ImmutableMap<C, IAllele> getDefaultTemplate();
IAllele[] getDefaultTemplate();
/**
* @param rand Random to use.
* @return A random template from the pool of registered species templates.
*/
ImmutableMap<C, IAllele> getRandomTemplate(Random rand);
IAllele[] getRandomTemplate(Random rand);
Map<String, ImmutableMap<C, IAllele>> getGenomeTemplates();
Map<String, IAllele[]> getGenomeTemplates();
List<? extends IIndividual<C>> getIndividualTemplates();
ArrayList<? extends IIndividual> getIndividualTemplates();
/* MUTATIONS */
@@ -142,26 +129,26 @@ public interface ISpeciesRoot<C extends IChromosomeType> {
*
* @param mutation
*/
void registerMutation(IMutation<C> mutation);
void registerMutation(IMutation mutation);
/**
* @return All registered mutations.
*/
Collection<? extends IMutation<C>> getMutations(boolean shuffle);
Collection<? extends IMutation> getMutations(boolean shuffle);
/**
* @param other Allele to match mutations against.
* @return All registered mutations the given allele is part of.
*/
List<IMutation<C>> getCombinations(IAllele other);
Collection<? extends IMutation> getCombinations(IAllele other);
/**
* @since Forestry 3.7
* @return all possible mutations that result from breeding two species
*/
List<IMutation<C>> getCombinations(IAlleleSpecies<C> parentSpecies0, IAlleleSpecies<C> parentSpecies1, boolean shuffle);
List<IMutation> getCombinations(IAlleleSpecies parentSpecies0, IAlleleSpecies parentSpecies1, boolean shuffle);
Collection<? extends IMutation<C>> getPaths(IAllele result, C chromosomeType);
Collection<? extends IMutation> getPaths(IAllele result, IChromosomeType chromosomeType);
/* RESEARCH */
@@ -180,29 +167,10 @@ public interface ISpeciesRoot<C extends IChromosomeType> {
/**
* @return Array of {@link IChromosomeType} which are in this species genome
*/
@Nonnull
C[] getKaryotype();
IChromosomeType[] getKaryotype();
/**
* @return {@link IChromosomeType} which is the "key" for this species class, usually the species chromosome.
*/
@Nonnull
C getKaryotypeKey();
C getChromosomeTypeForUid(byte uid);
/* GAME MODE */
void resetMode();
@Nonnull
List<? extends ISpeciesMode<C>> getModes();
@Nonnull
ISpeciesMode<C> getMode(@Nonnull World world);
@Nonnull
ISpeciesMode<C> getMode(@Nonnull String name);
void setMode(@Nonnull World world, @Nonnull String name);
IChromosomeType getKaryotypeKey();
}
@@ -5,7 +5,6 @@
******************************************************************************/
package forestry.api.lepidopterology;
import javax.annotation.Nonnull;
import java.util.Locale;
import forestry.api.genetics.IAllele;
@@ -17,7 +16,7 @@ import forestry.api.genetics.IAlleleTolerance;
import forestry.api.genetics.IChromosomeType;
import forestry.api.genetics.ISpeciesRoot;
public enum ButterflyChromosome implements IChromosomeType<ButterflyChromosome> {
public enum EnumButterflyChromosome implements IChromosomeType {
/**
* Species of the bee. Alleles here must implement {@link IAlleleButterflySpecies}.
*/
@@ -70,34 +69,25 @@ public enum ButterflyChromosome implements IChromosomeType<ButterflyChromosome>
* Extra effect to surroundings. (?)
*/
EFFECT(IAlleleButterflyEffect.class);
@Nonnull
private final Class<? extends IAllele> alleleClass;
ButterflyChromosome(@Nonnull Class<? extends IAllele> alleleClass) {
this.alleleClass = alleleClass;
Class<? extends IAllele> clss;
EnumButterflyChromosome(Class<? extends IAllele> clss) {
this.clss = clss;
}
@Nonnull
@Override
public Class<? extends IAllele> getAlleleClass() {
return alleleClass;
return clss;
}
@Nonnull
@Override
public String getName() {
return this.toString().toLowerCase(Locale.ENGLISH);
}
@Nonnull
@Override
public ISpeciesRoot<ButterflyChromosome> getSpeciesRoot() {
public ISpeciesRoot getSpeciesRoot() {
return ButterflyManager.butterflyRoot;
}
@Override
public byte getUid() {
return (byte) ordinal();
}
}
@@ -15,7 +15,7 @@ import net.minecraftforge.common.BiomeDictionary;
import forestry.api.core.ISpriteProvider;
import forestry.api.genetics.IAlleleSpecies;
public interface IAlleleButterflySpecies extends IAlleleSpecies<ButterflyChromosome> {
public interface IAlleleButterflySpecies extends IAlleleSpecies {
/**
* @return the IBeeRoot
@@ -10,16 +10,12 @@
******************************************************************************/
package forestry.api.lepidopterology;
import forestry.api.genetics.IAlleleSpeciesBuilder;
import forestry.api.genetics.IAlleleSpeciesCustom;
public interface IAlleleButterflySpeciesBuilder extends IAlleleSpeciesBuilder<ButterflyChromosome> {
public interface IAlleleButterflySpeciesCustom extends IAlleleButterflySpecies, IAlleleSpeciesCustom {
IAlleleButterflySpeciesCustom setRarity(float rarity);
@Override
IAlleleButterflySpecies build();
IAlleleButterflySpeciesCustom setFlightDistance(float flightDistance);
IAlleleButterflySpeciesBuilder setRarity(float rarity);
IAlleleButterflySpeciesBuilder setFlightDistance(float flightDistance);
IAlleleButterflySpeciesBuilder setNocturnal();
IAlleleButterflySpeciesCustom setNocturnal();
}
@@ -12,7 +12,7 @@ import net.minecraft.world.World;
import forestry.api.genetics.IIndividualLiving;
public interface IButterfly extends IIndividualLiving<ButterflyChromosome> {
public interface IButterfly extends IIndividualLiving {
@Nonnull
@Override
@@ -18,7 +18,7 @@ public interface IButterflyFactory {
/**
* Creates a new butterfly species.
* Automatically registered with AlleleManager.alleleRegistry.registerAllele()
* See IAlleleButterflySpeciesBuilder and IAlleleSpeciesBuilder for adding additional properties to the returned species.
* See IAlleleButterflySpeciesCustom and IAlleleSpeciesCustom for adding additional properties to the returned species.
*
* @param uid Unique Identifier for this species
* @param unlocalizedName Unlocalized name for this species
@@ -31,5 +31,5 @@ public interface IButterflyFactory {
* @param serumColour The color of this butterfly's serum.
* @return a new butterfly species allele.
*/
IAlleleButterflySpeciesBuilder createSpecies(String uid, String unlocalizedName, String authority, String unlocalizedDescription, String texturePath, boolean dominant, IClassification branch, String binomial, Color serumColour);
IAlleleButterflySpeciesCustom createSpecies(String uid, String unlocalizedName, String authority, String unlocalizedDescription, String texturePath, boolean dominant, IClassification branch, String binomial, Color serumColour);
}
@@ -5,19 +5,15 @@
******************************************************************************/
package forestry.api.lepidopterology;
import javax.annotation.Nonnull;
import forestry.api.genetics.EnumTolerance;
import forestry.api.genetics.IFlowerProvider;
import forestry.api.genetics.IGenome;
public interface IButterflyGenome extends IGenome<ButterflyChromosome> {
@Nonnull
public interface IButterflyGenome extends IGenome {
@Override
IAlleleButterflySpecies getPrimary();
@Nonnull
@Override
IAlleleButterflySpecies getSecondary();
@@ -35,7 +31,7 @@ public interface IButterflyGenome extends IGenome<ButterflyChromosome> {
EnumTolerance getToleranceHumid();
boolean getNeverSleeps();
boolean getNocturnal();
boolean getTolerantFlyer();
@@ -45,7 +41,4 @@ public interface IButterflyGenome extends IGenome<ButterflyChromosome> {
IAlleleButterflyEffect getEffect();
@Nonnull
@Override
IButterflyRoot getSpeciesRoot();
}
@@ -1,6 +0,0 @@
package forestry.api.lepidopterology;
import forestry.api.genetics.ISpeciesMode;
public interface IButterflyMode extends ISpeciesMode<ButterflyChromosome> {
}
@@ -9,6 +9,6 @@ import forestry.api.genetics.IAllele;
import forestry.api.genetics.IGenome;
import forestry.api.genetics.IMutation;
public interface IButterflyMutation extends IMutation<ButterflyChromosome> {
public interface IButterflyMutation extends IMutation {
float getChance(IButterflyNursery housing, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1);
}
@@ -5,14 +5,14 @@
******************************************************************************/
package forestry.api.lepidopterology;
import forestry.api.arboriculture.ITree;
import forestry.api.genetics.IHousing;
import forestry.api.genetics.IIndividual;
public interface IButterflyNursery extends IHousing {
IButterfly getCaterpillar();
ITree getNanny();
IIndividual getNanny();
void setCaterpillar(IButterfly butterfly);
@@ -5,11 +5,8 @@
******************************************************************************/
package forestry.api.lepidopterology;
import com.google.common.collect.ImmutableMap;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import net.minecraft.entity.EntityLiving;
import net.minecraft.item.ItemStack;
@@ -19,11 +16,10 @@ import net.minecraft.world.World;
import com.mojang.authlib.GameProfile;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IChromosome;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.ISpeciesRoot;
public interface IButterflyRoot extends ISpeciesRoot<ButterflyChromosome> {
public interface IButterflyRoot extends ISpeciesRoot {
@Override
boolean isMember(ItemStack stack);
@@ -35,31 +31,24 @@ public interface IButterflyRoot extends ISpeciesRoot<ButterflyChromosome> {
IButterfly getMember(NBTTagCompound compound);
@Override
ItemStack getMemberStack(IIndividual<ButterflyChromosome> butterfly, int type);
ItemStack getMemberStack(IIndividual butterfly, int type);
/* GENOME CONVERSION */
@Nonnull
@Override
IButterfly templateAsIndividual(ImmutableMap<ButterflyChromosome, IAllele> template);
@Nonnull
@Override
IButterfly templateAsIndividual(ImmutableMap<ButterflyChromosome, IAllele> templateActive, ImmutableMap<ButterflyChromosome, IAllele> templateInactive);
IButterfly templateAsIndividual(IAllele[] template);
@Override
IButterflyGenome templateAsGenome(ImmutableMap<ButterflyChromosome, IAllele> template);
IButterfly templateAsIndividual(IAllele[] templateActive, IAllele[] templateInactive);
@Override
IButterflyGenome templateAsGenome(ImmutableMap<ButterflyChromosome, IAllele> templateActive, ImmutableMap<ButterflyChromosome, IAllele> templateInactive);
IButterflyGenome templateAsGenome(IAllele[] template);
@Nonnull
@Override
IButterflyGenome chromosomesAsGenome(ImmutableMap<ButterflyChromosome, IChromosome> chromosomes);
IButterflyGenome templateAsGenome(IAllele[] templateActive, IAllele[] templateInactive);
/* BUTTERFLY SPECIFIC */
@Nonnull
@Override
IButterflyTracker getBreedingTracker(@Nonnull World world, @Nonnull GameProfile player);
ILepidopteristTracker getBreedingTracker(World world, GameProfile player);
/**
* Spawns the given butterfly in the world.
@@ -75,7 +64,7 @@ public interface IButterflyRoot extends ISpeciesRoot<ButterflyChromosome> {
/* TEMPLATES */
@Override
List<IButterfly> getIndividualTemplates();
ArrayList<IButterfly> getIndividualTemplates();
/* MUTATIONS */
@Override
@@ -84,14 +73,4 @@ public interface IButterflyRoot extends ISpeciesRoot<ButterflyChromosome> {
@Override
EnumFlutterType getType(ItemStack stack);
/** Modes */
@Nonnull
@Override
IButterflyMode getMode(@Nonnull World world);
@Nonnull
@Override
List<IButterflyMode> getModes();
void registerMode(@Nonnull IButterflyMode mode);
}
@@ -8,7 +8,7 @@ package forestry.api.lepidopterology;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.passive.IAnimals;
import forestry.api.arboriculture.ITree;
import forestry.api.genetics.IIndividual;
public interface IEntityButterfly extends IAnimals {
@@ -23,7 +23,7 @@ public interface IEntityButterfly extends IAnimals {
*/
EntityCreature getEntity();
ITree getPollen();
IIndividual getPollen();
void setPollen(ITree pollen);
void setPollen(IIndividual pollen);
}
@@ -7,7 +7,7 @@ package forestry.api.lepidopterology;
import forestry.api.genetics.IBreedingTracker;
public interface IButterflyTracker extends IBreedingTracker<ButterflyChromosome> {
public interface ILepidopteristTracker extends IBreedingTracker {
void registerCatch(IButterfly butterfly);
@@ -5,8 +5,6 @@
******************************************************************************/
package forestry.api.multiblock;
import javax.annotation.Nonnull;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
@@ -71,5 +69,5 @@ public interface IMultiblockLogic extends INbtWritable {
* Use this in Tile.writeToNBT()
*/
@Override
void writeToNBT(@Nonnull NBTTagCompound nbttagcompound);
void writeToNBT(NBTTagCompound nbttagcompound);
}