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