diff options
Diffstat (limited to 'src/Java/binnie/core/genetics')
18 files changed, 2392 insertions, 0 deletions
diff --git a/src/Java/binnie/core/genetics/BeeBreedingSystem.java b/src/Java/binnie/core/genetics/BeeBreedingSystem.java new file mode 100644 index 0000000000..2c3947b5a0 --- /dev/null +++ b/src/Java/binnie/core/genetics/BeeBreedingSystem.java @@ -0,0 +1,125 @@ +package binnie.core.genetics; + +import binnie.Binnie; +import binnie.core.BinnieCore; +import binnie.core.language.ManagerLanguage; +import binnie.core.resource.ManagerResource; +import binnie.extrabees.ExtraBees; +import forestry.api.apiculture.EnumBeeChromosome; +import forestry.api.apiculture.EnumBeeType; +import forestry.api.apiculture.IApiaristTracker; +import forestry.api.apiculture.IBeeMutation; +import forestry.api.apiculture.IBeeRoot; +import forestry.api.genetics.IAllele; +import forestry.api.genetics.IBreedingTracker; +import forestry.api.genetics.IChromosomeType; +import forestry.api.genetics.IMutation; +import forestry.api.genetics.ISpeciesRoot; +import java.util.TreeSet; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +class BeeBreedingSystem + extends BreedingSystem +{ + public BeeBreedingSystem() + { + this.iconUndiscovered = Binnie.Resource.getItemIcon(ExtraBees.instance, "icon/undiscoveredBee"); + this.iconDiscovered = Binnie.Resource.getItemIcon(ExtraBees.instance, "icon/discoveredBee"); + } + + public float getChance(IMutation mutation, EntityPlayer player, IAllele species1, IAllele species2) + { + return ((IBeeMutation)mutation).getChance(new VirtualBeeHousing(player), species1, species2, getSpeciesRoot().templateAsGenome(getSpeciesRoot().getTemplate(species1.getUID())), getSpeciesRoot().templateAsGenome(getSpeciesRoot().getTemplate(species2.getUID()))); + } + + public ISpeciesRoot getSpeciesRoot() + { + return Binnie.Genetics.getBeeRoot(); + } + + public int getColour() + { + return 16767232; + } + + public Class<? extends IBreedingTracker> getTrackerClass() + { + return IApiaristTracker.class; + } + + public String getAlleleName(IChromosomeType chromosome, IAllele allele) + { + if (chromosome == EnumBeeChromosome.FERTILITY) + { + if (allele.getUID().contains("Low")) { + return Binnie.Language.localise(BinnieCore.instance, "allele.fertility.low"); + } + if (allele.getUID().contains("Normal")) { + return Binnie.Language.localise(BinnieCore.instance, "allele.fertility.normal"); + } + if (allele.getUID().contains("High")) { + return Binnie.Language.localise(BinnieCore.instance, "allele.fertility.high"); + } + if (allele.getUID().contains("Maximum")) { + return Binnie.Language.localise(BinnieCore.instance, "allele.fertility.maximum"); + } + } + return super.getAlleleName(chromosome, allele); + } + + public boolean isDNAManipulable(ItemStack member) + { + return ((IBeeRoot)getSpeciesRoot()).getType(member) == EnumBeeType.LARVAE; + } + + public int[] getActiveTypes() + { + return new int[] { EnumBeeType.DRONE.ordinal(), EnumBeeType.PRINCESS.ordinal(), EnumBeeType.QUEEN.ordinal(), EnumBeeType.LARVAE.ordinal() }; + } + + public void addExtraAlleles(IChromosomeType chromosome, TreeSet<IAllele> alleles) + { + switch (1.$SwitchMap$forestry$api$apiculture$EnumBeeChromosome[((EnumBeeChromosome)chromosome).ordinal()]) + { + case 1: + for (ForestryAllele.Fertility a : ForestryAllele.Fertility.values()) { + alleles.add(a.getAllele()); + } + break; + case 2: + for (ForestryAllele.Flowering a : ForestryAllele.Flowering.values()) { + alleles.add(a.getAllele()); + } + break; + case 3: + case 4: + for (Tolerance a : Tolerance.values()) { + alleles.add(a.getAllele()); + } + break; + case 5: + for (ForestryAllele.Lifespan a : ForestryAllele.Lifespan.values()) { + alleles.add(a.getAllele()); + } + break; + case 6: + for (ForestryAllele.Speed a : ForestryAllele.Speed.values()) { + alleles.add(a.getAllele()); + } + break; + case 7: + for (ForestryAllele.Territory a : ForestryAllele.Territory.values()) { + alleles.add(a.getAllele()); + } + break; + case 8: + case 9: + case 10: + for (ForestryAllele.Bool a : ForestryAllele.Bool.values()) { + alleles.add(a.getAllele()); + } + break; + } + } +} diff --git a/src/Java/binnie/core/genetics/BeeModifierLogic.java b/src/Java/binnie/core/genetics/BeeModifierLogic.java new file mode 100644 index 0000000000..65a2ab3103 --- /dev/null +++ b/src/Java/binnie/core/genetics/BeeModifierLogic.java @@ -0,0 +1,47 @@ +package binnie.core.genetics; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class BeeModifierLogic +{ + private Map<EnumBeeModifier, Float[]> modifiers = new HashMap(); + private List<EnumBeeBooleanModifier> booleanModifiers = new ArrayList(); + + public float getModifier(EnumBeeModifier modifier, float currentModifier) + { + if (!this.modifiers.containsKey(modifier)) { + return 1.0F; + } + float mult = ((Float[])this.modifiers.get(modifier))[0].floatValue(); + float max = ((Float[])this.modifiers.get(modifier))[1].floatValue(); + if (max >= 1.0F) + { + if (max <= currentModifier) { + return 1.0F; + } + return Math.min(max / currentModifier, mult); + } + if (max >= currentModifier) { + return 1.0F; + } + return Math.max(max / currentModifier, mult); + } + + public boolean getModifier(EnumBeeBooleanModifier modifier) + { + return this.booleanModifiers.contains(modifier); + } + + public void setModifier(EnumBeeBooleanModifier modifier) + { + this.booleanModifiers.add(modifier); + } + + public void setModifier(EnumBeeModifier modifier, float mult, float max) + { + this.modifiers.put(modifier, new Float[] { Float.valueOf(mult), Float.valueOf(max) }); + } +} diff --git a/src/Java/binnie/core/genetics/BreedingSystem.java b/src/Java/binnie/core/genetics/BreedingSystem.java new file mode 100644 index 0000000000..1bdd5d6376 --- /dev/null +++ b/src/Java/binnie/core/genetics/BreedingSystem.java @@ -0,0 +1,558 @@ +package binnie.core.genetics; + +import binnie.Binnie; +import binnie.core.BinnieCore; +import binnie.core.language.ManagerLanguage; +import binnie.core.proxy.BinnieProxy; +import binnie.core.resource.BinnieIcon; +import binnie.extrabees.genetics.ExtraBeeMutation; +import com.mojang.authlib.GameProfile; +import cpw.mods.fml.common.eventhandler.EventBus; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import forestry.api.core.ForestryEvent.SyncedBreedingTracker; +import forestry.api.genetics.AlleleManager; +import forestry.api.genetics.IAllele; +import forestry.api.genetics.IAlleleBoolean; +import forestry.api.genetics.IAlleleRegistry; +import forestry.api.genetics.IAlleleSpecies; +import forestry.api.genetics.IBreedingTracker; +import forestry.api.genetics.IChromosomeType; +import forestry.api.genetics.IClassification; +import forestry.api.genetics.IGenome; +import forestry.api.genetics.IIndividual; +import forestry.api.genetics.IMutation; +import forestry.api.genetics.ISpeciesRoot; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; + +public abstract class BreedingSystem + implements IItemStackRepresentitive +{ + protected BinnieIcon iconUndiscovered; + protected BinnieIcon iconDiscovered; + + public BreedingSystem() + { + Binnie.Genetics.registerBreedingSystem(this); + MinecraftForge.EVENT_BUS.register(this); + } + + public String getChromosomeName(IChromosomeType chromo) + { + return BinnieCore.proxy.localise(getSpeciesRoot().getUID() + ".chromosome." + chromo.getName()); + } + + public String getChromosomeShortName(IChromosomeType chromo) + { + return BinnieCore.proxy.localise(getSpeciesRoot().getUID() + ".chromosome." + chromo.getName() + ".short"); + } + + public final String getEpitome(float discoveredPercentage) + { + int i = 0; + if (discoveredPercentage == 1.0F) { + i = 6; + } else if (discoveredPercentage < 0.1F) { + i = 0; + } else if (discoveredPercentage < 0.3F) { + i = 1; + } else if (discoveredPercentage < 0.5F) { + i = 2; + } else if (discoveredPercentage < 0.7F) { + i = 3; + } else if (discoveredPercentage < 0.9F) { + i = 4; + } else if (discoveredPercentage < 1.0F) { + i = 5; + } + return BinnieCore.proxy.localise(getSpeciesRoot().getUID() + ".epitome." + i); + } + + private List<IClassification> allBranches = new ArrayList(); + List<IAlleleSpecies> allActiveSpecies = new ArrayList(); + private List<IAlleleSpecies> allSpecies = new ArrayList(); + private List<IMutation> allMutations = new ArrayList(); + private Map<IAlleleSpecies, List<IMutation>> resultantMutations = new HashMap(); + private Map<IAlleleSpecies, List<IMutation>> furtherMutations = new HashMap(); + private Map<IAlleleSpecies, List<IMutation>> allResultantMutations = new HashMap(); + private Map<IAlleleSpecies, List<IMutation>> allFurtherMutations = new HashMap(); + public float discoveredSpeciesPercentage; + public int totalSpeciesCount; + public int discoveredSpeciesCount; + public int totalSecretCount; + public int discoveredSecretCount; + public float discoveredBranchPercentage; + public int totalBranchCount; + public int discoveredBranchCount; + private int totalSecretBranchCount; + private int discoveredSecretBranchCount; + String currentEpithet; + + public abstract ISpeciesRoot getSpeciesRoot(); + + public final List<IClassification> getAllBranches() + { + return this.allBranches; + } + + public final Collection<IAlleleSpecies> getAllSpecies() + { + return this.allActiveSpecies; + } + + public final Collection<IMutation> getAllMutations() + { + return this.allMutations; + } + + public void calculateArrays() + { + Collection<IAllele> allAlleles = AlleleManager.alleleRegistry.getRegisteredAlleles().values(); + + + this.resultantMutations = new HashMap(); + this.furtherMutations = new HashMap(); + this.allResultantMutations = new HashMap(); + this.allFurtherMutations = new HashMap(); + + this.allActiveSpecies = new ArrayList(); + this.allSpecies = new ArrayList(); + for (IAllele species : allAlleles) { + if (getSpeciesRoot().getTemplate(species.getUID()) != null) + { + this.resultantMutations.put((IAlleleSpecies)species, new ArrayList()); + + this.furtherMutations.put((IAlleleSpecies)species, new ArrayList()); + + this.allResultantMutations.put((IAlleleSpecies)species, new ArrayList()); + + this.allFurtherMutations.put((IAlleleSpecies)species, new ArrayList()); + + this.allSpecies.add((IAlleleSpecies)species); + if ((!isBlacklisted(species)) && (!species.getUID().contains("speciesBotAlfheim"))) { + this.allActiveSpecies.add((IAlleleSpecies)species); + } + } + } + this.allMutations = new ArrayList(); + + Collection<IClassification> allRegBranches = AlleleManager.alleleRegistry.getRegisteredClassifications().values(); + + + this.allBranches = new ArrayList(); + for (IClassification branch : allRegBranches) { + if ((branch.getMemberSpecies().length > 0) && + (getSpeciesRoot().getTemplate(branch.getMemberSpecies()[0].getUID()) != null)) + { + boolean possible = false; + for (IAlleleSpecies species : branch.getMemberSpecies()) { + if (this.allActiveSpecies.contains(species)) { + possible = true; + } + } + if (possible) { + this.allBranches.add(branch); + } + } + } + if (getSpeciesRoot().getMutations(false) != null) + { + Set<IMutation> mutations = new LinkedHashSet(); + mutations.addAll(getSpeciesRoot().getMutations(false)); + if (this == Binnie.Genetics.beeBreedingSystem) { + mutations.addAll(ExtraBeeMutation.mutations); + } + for (IMutation mutation : mutations) + { + this.allMutations.add(mutation); + + Set<IAlleleSpecies> participatingSpecies = new LinkedHashSet(); + if ((mutation.getAllele0() instanceof IAlleleSpecies)) { + participatingSpecies.add((IAlleleSpecies)mutation.getAllele0()); + } + if ((mutation.getAllele1() instanceof IAlleleSpecies)) { + participatingSpecies.add((IAlleleSpecies)mutation.getAllele1()); + } + for (IAlleleSpecies species : participatingSpecies) + { + ((List)this.allFurtherMutations.get(species)).add(mutation); + if (this.allActiveSpecies.contains(species)) { + ((List)this.furtherMutations.get(species)).add(mutation); + } + } + if (this.resultantMutations.containsKey(mutation.getTemplate()[0])) + { + ((List)this.allResultantMutations.get(mutation.getTemplate()[0])).add(mutation); + ((List)this.resultantMutations.get(mutation.getTemplate()[0])).add(mutation); + } + } + } + } + + public final boolean isBlacklisted(IAllele allele) + { + return AlleleManager.alleleRegistry.isBlacklisted(allele.getUID()); + } + + public final List<IMutation> getResultantMutations(IAlleleSpecies species, boolean includeInactive) + { + if (this.resultantMutations.isEmpty()) { + calculateArrays(); + } + return includeInactive ? (List)this.allResultantMutations.get(species) : (List)this.resultantMutations.get(species); + } + + public final List<IMutation> getResultantMutations(IAlleleSpecies species) + { + if (this.resultantMutations.isEmpty()) { + calculateArrays(); + } + return (List)this.resultantMutations.get(species); + } + + public final List<IMutation> getFurtherMutations(IAlleleSpecies species, boolean includeInactive) + { + if (this.furtherMutations.isEmpty()) { + calculateArrays(); + } + return includeInactive ? (List)this.allFurtherMutations.get(species) : (List)this.furtherMutations.get(species); + } + + public final List<IMutation> getFurtherMutations(IAlleleSpecies species) + { + if (this.furtherMutations.isEmpty()) { + calculateArrays(); + } + return (List)this.furtherMutations.get(species); + } + + public final boolean isMutationDiscovered(IMutation mutation, World world, GameProfile name) + { + return isMutationDiscovered(mutation, getSpeciesRoot().getBreedingTracker(world, name)); + } + + public final boolean isMutationDiscovered(IMutation mutation, IBreedingTracker tracker) + { + if (tracker == null) { + return true; + } + return tracker.isDiscovered(mutation); + } + + public final boolean isSpeciesDiscovered(IAlleleSpecies species, World world, GameProfile name) + { + return isSpeciesDiscovered(species, getSpeciesRoot().getBreedingTracker(world, name)); + } + + public final boolean isSpeciesDiscovered(IAlleleSpecies species, IBreedingTracker tracker) + { + if (tracker == null) { + return true; + } + return tracker.isDiscovered(species); + } + + public final boolean isSecret(IAlleleSpecies species) + { + return !species.isCounted(); + } + + public final boolean isSecret(IClassification branch) + { + for (IAlleleSpecies species : branch.getMemberSpecies()) { + if (!isSecret(species)) { + return false; + } + } + return true; + } + + public final Collection<IClassification> getDiscoveredBranches(World world, GameProfile player) + { + List<IClassification> branches = new ArrayList(); + for (IClassification branch : getAllBranches()) + { + boolean discovered = false; + for (IAlleleSpecies species : branch.getMemberSpecies()) { + if (isSpeciesDiscovered(species, world, player)) { + discovered = true; + } + } + if (discovered) { + branches.add(branch); + } + } + return branches; + } + + public final Collection<IClassification> getDiscoveredBranches(IBreedingTracker tracker) + { + List<IClassification> branches = new ArrayList(); + for (IClassification branch : getAllBranches()) + { + boolean discovered = false; + for (IAlleleSpecies species : branch.getMemberSpecies()) { + if (isSpeciesDiscovered(species, tracker)) { + discovered = true; + } + } + if (discovered) { + branches.add(branch); + } + } + return branches; + } + + public final Collection<IAlleleSpecies> getDiscoveredSpecies(World world, GameProfile player) + { + List<IAlleleSpecies> speciesList = new ArrayList(); + for (IAlleleSpecies species : getAllSpecies()) { + if (isSpeciesDiscovered(species, world, player)) { + speciesList.add(species); + } + } + return speciesList; + } + + public final Collection<IAlleleSpecies> getDiscoveredSpecies(IBreedingTracker tracker) + { + List<IAlleleSpecies> speciesList = new ArrayList(); + for (IAlleleSpecies species : getAllSpecies()) { + if (isSpeciesDiscovered(species, tracker)) { + speciesList.add(species); + } + } + return speciesList; + } + + public final List<IMutation> getDiscoveredMutations(World world, GameProfile player) + { + List<IMutation> speciesList = new ArrayList(); + for (IMutation species : getAllMutations()) { + if (isMutationDiscovered(species, world, player)) { + speciesList.add(species); + } + } + return speciesList; + } + + public final List<IMutation> getDiscoveredMutations(IBreedingTracker tracker) + { + List<IMutation> speciesList = new ArrayList(); + for (IMutation species : getAllMutations()) { + if (isMutationDiscovered(species, tracker)) { + speciesList.add(species); + } + } + return speciesList; + } + + public final int getDiscoveredBranchMembers(IClassification branch, IBreedingTracker tracker) + { + int discoveredSpecies = 0; + for (IAlleleSpecies species : branch.getMemberSpecies()) { + if (isSpeciesDiscovered(species, tracker)) { + discoveredSpecies++; + } + } + return discoveredSpecies; + } + + public IIcon getUndiscoveredIcon() + { + return this.iconUndiscovered.getIcon(); + } + + public IIcon getDiscoveredIcon() + { + return this.iconDiscovered.getIcon(); + } + + public abstract float getChance(IMutation paramIMutation, EntityPlayer paramEntityPlayer, IAllele paramIAllele1, IAllele paramIAllele2); + + public abstract Class<? extends IBreedingTracker> getTrackerClass(); + + @SubscribeEvent + public final void onSyncBreedingTracker(ForestryEvent.SyncedBreedingTracker event) + { + IBreedingTracker tracker = event.tracker; + if (!getTrackerClass().isInstance(tracker)) { + return; + } + syncTracker(tracker); + } + + public final void syncTracker(IBreedingTracker tracker) + { + this.discoveredSpeciesPercentage = 0.0F; + + this.totalSpeciesCount = 0; + this.discoveredSpeciesCount = 0; + + this.totalSecretCount = 0; + this.discoveredSecretCount = 0; + + Collection<IAlleleSpecies> discoveredSpecies = getDiscoveredSpecies(tracker); + Collection<IAlleleSpecies> allSpecies = getAllSpecies(); + for (IAlleleSpecies species : allSpecies) { + if (!isSecret(species)) + { + this.totalSpeciesCount += 1; + if (isSpeciesDiscovered(species, tracker)) { + this.discoveredSpeciesCount += 1; + } + } + else + { + this.totalSecretCount += 1; + if (isSpeciesDiscovered(species, tracker)) { + this.discoveredSecretCount += 1; + } + } + } + this.discoveredBranchPercentage = 0.0F; + + this.totalBranchCount = 0; + this.discoveredBranchCount = 0; + + Collection<IClassification> discoveredBranches = getDiscoveredBranches(tracker); + Collection<IClassification> allBranches = getAllBranches(); + for (IClassification branch : allBranches) { + if (!isSecret(branch)) + { + this.totalBranchCount += 1; + if (discoveredBranches.contains(branch)) { + this.discoveredBranchCount += 1; + } + } + else + { + this.totalSecretBranchCount += 1; + if (discoveredBranches.contains(branch)) { + this.discoveredSecretBranchCount += 1; + } + } + } + this.discoveredSpeciesPercentage = (this.discoveredSpeciesCount / this.totalSpeciesCount); + + this.discoveredBranchPercentage = (this.discoveredBranchCount / this.totalBranchCount); + + + String epithet = getEpitome(); + + onSyncBreedingTracker(tracker); + } + + public void onSyncBreedingTracker(IBreedingTracker tracker) {} + + public String getEpitome() + { + return getEpitome(this.discoveredSpeciesPercentage); + } + + public final String getDescriptor() + { + return BinnieCore.proxy.localise(getSpeciesRoot().getUID() + ".descriptor"); + } + + public final String getIdent() + { + return getSpeciesRoot().getUID(); + } + + public final IChromosomeType getChromosome(int i) + { + for (IChromosomeType chromosome : getSpeciesRoot().getKaryotype()) { + if (i == chromosome.ordinal()) { + return chromosome; + } + } + return null; + } + + public abstract int getColour(); + + public String getAlleleName(IChromosomeType chromosome, IAllele allele) + { + if ((allele instanceof IAlleleBoolean)) { + return ((IAlleleBoolean)allele).getValue() ? Binnie.Language.localise(BinnieCore.instance, "allele.true") : Binnie.Language.localise(BinnieCore.instance, "allele.false"); + } + if (allele.getName() == "for.gui.maximum") { + return Binnie.Language.localise(BinnieCore.instance, "allele.fertility.maximum"); + } + return allele.getName(); + } + + public String getName() + { + return BinnieCore.proxy.localise(getSpeciesRoot().getUID() + ".shortName"); + } + + public ItemStack getItemStackRepresentitive() + { + IIndividual first = (IIndividual)getSpeciesRoot().getIndividualTemplates().get(0); + return getSpeciesRoot().getMemberStack(first, getDefaultType()); + } + + public String toString() + { + return getName(); + } + + public abstract boolean isDNAManipulable(ItemStack paramItemStack); + + public IIndividual getConversion(ItemStack stack) + { + return null; + } + + public final IIndividual getDefaultIndividual() + { + return getSpeciesRoot().templateAsIndividual(getSpeciesRoot().getDefaultTemplate()); + } + + public final int getDefaultType() + { + return getActiveTypes()[0]; + } + + public abstract int[] getActiveTypes(); + + public abstract void addExtraAlleles(IChromosomeType paramIChromosomeType, TreeSet<IAllele> paramTreeSet); + + public ItemStack getConversionStack(ItemStack stack) + { + return getSpeciesRoot().getMemberStack(getConversion(stack), getDefaultType()); + } + + public final Collection<IChromosomeType> getActiveKaryotype() + { + return Binnie.Genetics.getActiveChromosomes(getSpeciesRoot()); + } + + public ItemStack getDefaultMember(String uid) + { + return getSpeciesRoot().getMemberStack(getIndividual(uid), getDefaultType()); + } + + public IIndividual getIndividual(String uid) + { + return getSpeciesRoot().templateAsIndividual(getSpeciesRoot().getTemplate(uid)); + } + + public IGenome getGenome(String uid) + { + return getSpeciesRoot().templateAsGenome(getSpeciesRoot().getTemplate(uid)); + } +} diff --git a/src/Java/binnie/core/genetics/EnumBeeBooleanModifier.java b/src/Java/binnie/core/genetics/EnumBeeBooleanModifier.java new file mode 100644 index 0000000000..58eae12e79 --- /dev/null +++ b/src/Java/binnie/core/genetics/EnumBeeBooleanModifier.java @@ -0,0 +1,8 @@ +package binnie.core.genetics; + +public enum EnumBeeBooleanModifier +{ + Sealed, SelfLighted, SunlightStimulated, Hellish; + + private EnumBeeBooleanModifier() {} +} diff --git a/src/Java/binnie/core/genetics/EnumBeeModifier.java b/src/Java/binnie/core/genetics/EnumBeeModifier.java new file mode 100644 index 0000000000..92fc30bda0 --- /dev/null +++ b/src/Java/binnie/core/genetics/EnumBeeModifier.java @@ -0,0 +1,17 @@ +package binnie.core.genetics; + +import binnie.Binnie; +import binnie.core.BinnieCore; +import binnie.core.language.ManagerLanguage; + +public enum EnumBeeModifier +{ + Territory, Mutation, Lifespan, Production, Flowering, GeneticDecay; + + private EnumBeeModifier() {} + + public String getName() + { + return Binnie.Language.localise(BinnieCore.instance, "beemodifier." + name().toLowerCase()); + } +} diff --git a/src/Java/binnie/core/genetics/FlowerBreedingSystem.java b/src/Java/binnie/core/genetics/FlowerBreedingSystem.java new file mode 100644 index 0000000000..bc706976c8 --- /dev/null +++ b/src/Java/binnie/core/genetics/FlowerBreedingSystem.java @@ -0,0 +1,129 @@ +package binnie.core.genetics; + +import binnie.Binnie; +import binnie.botany.api.EnumFlowerChromosome; +import binnie.botany.api.EnumFlowerStage; +import binnie.botany.api.IBotanistTracker; +import binnie.botany.api.IFlowerMutation; +import binnie.botany.api.IFlowerRoot; +import binnie.botany.core.BotanyCore; +import binnie.botany.genetics.EnumFlowerColor; +import binnie.core.BinnieCore; +import binnie.core.language.ManagerLanguage; +import binnie.core.resource.ManagerResource; +import binnie.extrabees.ExtraBees; +import forestry.api.genetics.IAllele; +import forestry.api.genetics.IBreedingTracker; +import forestry.api.genetics.IChromosomeType; +import forestry.api.genetics.IIndividual; +import forestry.api.genetics.IMutation; +import forestry.api.genetics.ISpeciesRoot; +import java.util.TreeSet; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +class FlowerBreedingSystem + extends BreedingSystem +{ + public FlowerBreedingSystem() + { + this.iconUndiscovered = Binnie.Resource.getItemIcon(ExtraBees.instance, "icon/undiscoveredBee"); + this.iconDiscovered = Binnie.Resource.getItemIcon(ExtraBees.instance, "icon/discoveredBee"); + } + + public float getChance(IMutation mutation, EntityPlayer player, IAllele species1, IAllele species2) + { + return ((IFlowerMutation)mutation).getBaseChance(); + } + + public ISpeciesRoot getSpeciesRoot() + { + return Binnie.Genetics.getFlowerRoot(); + } + + public int getColour() + { + return 14563127; + } + + public Class<? extends IBreedingTracker> getTrackerClass() + { + return IBotanistTracker.class; + } + + public String getAlleleName(IChromosomeType chromosome, IAllele allele) + { + if (chromosome == EnumFlowerChromosome.FERTILITY) + { + if (allele.getUID().contains("Low")) { + return Binnie.Language.localise(BinnieCore.instance, "allele.fertility.low"); + } + if (allele.getUID().contains("Normal")) { + return Binnie.Language.localise(BinnieCore.instance, "allele.fertility.normal"); + } + if (allele.getUID().contains("High")) { + return Binnie.Language.localise(BinnieCore.instance, "allele.fertility.high"); + } + if (allele.getUID().contains("Maximum")) { + return Binnie.Language.localise(BinnieCore.instance, "allele.fertility.maximum"); + } + } + return super.getAlleleName(chromosome, allele); + } + + public boolean isDNAManipulable(ItemStack member) + { + return ((IFlowerRoot)getSpeciesRoot()).getType(member) == EnumFlowerStage.POLLEN; + } + + public IIndividual getConversion(ItemStack stack) + { + return BotanyCore.getFlowerRoot().getConversion(stack); + } + + public int[] getActiveTypes() + { + return new int[] { EnumFlowerStage.FLOWER.ordinal(), EnumFlowerStage.POLLEN.ordinal(), EnumFlowerStage.SEED.ordinal() }; + } + + public void addExtraAlleles(IChromosomeType chromosome, TreeSet<IAllele> alleles) + { + switch (1.$SwitchMap$binnie$botany$api$EnumFlowerChromosome[((EnumFlowerChromosome)chromosome).ordinal()]) + { + case 1: + for (ForestryAllele.Fertility a : ForestryAllele.Fertility.values()) { + alleles.add(a.getAllele()); + } + break; + case 2: + for (ForestryAllele.Lifespan a : ForestryAllele.Lifespan.values()) { + alleles.add(a.getAllele()); + } + break; + case 3: + case 4: + case 5: + for (Tolerance a : Tolerance.values()) { + alleles.add(a.getAllele()); + } + break; + case 6: + case 7: + case 8: + for (EnumFlowerColor a : EnumFlowerColor.values()) { + alleles.add(a.getAllele()); + } + break; + case 9: + for (ForestryAllele.Sappiness a : ForestryAllele.Sappiness.values()) { + alleles.add(a.getAllele()); + } + break; + case 10: + for (ForestryAllele.Territory a : ForestryAllele.Territory.values()) { + alleles.add(a.getAllele()); + } + break; + } + } +} diff --git a/src/Java/binnie/core/genetics/ForestryAllele.java b/src/Java/binnie/core/genetics/ForestryAllele.java new file mode 100644 index 0000000000..19a3ad8b6f --- /dev/null +++ b/src/Java/binnie/core/genetics/ForestryAllele.java @@ -0,0 +1,211 @@ +package binnie.core.genetics; + +import binnie.Binnie; +import forestry.api.apiculture.IAlleleBeeSpecies; +import forestry.api.apiculture.IBeeRoot; +import forestry.api.genetics.AlleleManager; +import forestry.api.genetics.IAllele; +import forestry.api.genetics.IAlleleRegistry; + +public class ForestryAllele +{ + public static enum Lifespan + { + Shortest, Shorter, Short, Shortened, Normal, Elongated, Long, Longer, Longes |
