Search in sources :

Example 1 with SpeciesNotFoundException

use of forestry.core.commands.SpeciesNotFoundException in project ForestryMC by ForestryMC.

the class CommandBeeGive method getBeeGenome.

private static IBeeGenome getBeeGenome(String speciesName) throws SpeciesNotFoundException, TemplateNotFoundException {
    IAlleleBeeSpecies species = null;
    for (String uid : AlleleManager.alleleRegistry.getRegisteredAlleles().keySet()) {
        if (!uid.equals(speciesName)) {
            continue;
        }
        IAllele allele = AlleleManager.alleleRegistry.getAllele(uid);
        if (allele instanceof IAlleleBeeSpecies) {
            species = (IAlleleBeeSpecies) allele;
            break;
        }
    }
    if (species == null) {
        for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) {
            if (allele instanceof IAlleleBeeSpecies && allele.getAlleleName().equals(speciesName)) {
                species = (IAlleleBeeSpecies) allele;
                break;
            }
        }
    }
    if (species == null) {
        throw new SpeciesNotFoundException(speciesName);
    }
    IAllele[] template = BeeManager.beeRoot.getTemplate(species);
    return BeeManager.beeRoot.templateAsGenome(template);
}
Also used : IAlleleBeeSpecies(forestry.api.apiculture.IAlleleBeeSpecies) IAllele(forestry.api.genetics.IAllele) SpeciesNotFoundException(forestry.core.commands.SpeciesNotFoundException)

Example 2 with SpeciesNotFoundException

use of forestry.core.commands.SpeciesNotFoundException in project ForestryMC by ForestryMC.

the class TreeGenHelper method getTreeGenome.

private static ITreeGenome getTreeGenome(String speciesName) throws SpeciesNotFoundException, TemplateNotFoundException {
    IAlleleTreeSpecies species = null;
    for (String uid : AlleleManager.alleleRegistry.getRegisteredAlleles().keySet()) {
        if (!uid.equals(speciesName)) {
            continue;
        }
        IAllele allele = AlleleManager.alleleRegistry.getAllele(uid);
        if (allele instanceof IAlleleTreeSpecies) {
            species = (IAlleleTreeSpecies) allele;
            break;
        }
    }
    if (species == null) {
        for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) {
            if (allele instanceof IAlleleTreeSpecies && allele.getAlleleName().replaceAll("\\s", "").equals(speciesName)) {
                species = (IAlleleTreeSpecies) allele;
                break;
            }
        }
    }
    if (species == null) {
        throw new SpeciesNotFoundException(speciesName);
    }
    IAllele[] template = TreeManager.treeRoot.getTemplate(species);
    return TreeManager.treeRoot.templateAsGenome(template);
}
Also used : IAllele(forestry.api.genetics.IAllele) IAlleleTreeSpecies(forestry.api.arboriculture.IAlleleTreeSpecies) SpeciesNotFoundException(forestry.core.commands.SpeciesNotFoundException)

Aggregations

IAllele (forestry.api.genetics.IAllele)2 SpeciesNotFoundException (forestry.core.commands.SpeciesNotFoundException)2 IAlleleBeeSpecies (forestry.api.apiculture.IAlleleBeeSpecies)1 IAlleleTreeSpecies (forestry.api.arboriculture.IAlleleTreeSpecies)1