Search in sources :

Example 21 with IAlleleSpecies

use of forestry.api.genetics.IAlleleSpecies in project ForestryMC by ForestryMC.

the class ItemGermlingGE method getItemStackDisplayName.

@Override
public String getItemStackDisplayName(ItemStack itemstack) {
    if (itemstack.getTagCompound() == null) {
        return "Unknown";
    }
    IAlleleSpecies species = getSpecies(itemstack);
    String customTreeKey = "for.trees.custom." + type.getName() + "." + species.getUnlocalizedName().replace("trees.species.", "");
    if (Translator.canTranslateToLocal(customTreeKey)) {
        return Translator.translateToLocal(customTreeKey);
    }
    String typeString = Translator.translateToLocal("for.trees.grammar." + type.getName() + ".type");
    return Translator.translateToLocal("for.trees.grammar." + type.getName()).replaceAll("%SPECIES", species.getAlleleName()).replaceAll("%TYPE", typeString);
}
Also used : IAlleleSpecies(forestry.api.genetics.IAlleleSpecies)

Example 22 with IAlleleSpecies

use of forestry.api.genetics.IAlleleSpecies in project ForestryMC by ForestryMC.

the class ButterflyGenome method getSpecies.

// NBT RETRIEVAL
public static IAlleleButterflySpecies getSpecies(ItemStack itemStack) {
    Preconditions.checkArgument(ButterflyManager.butterflyRoot.isMember(itemStack), "Must be a butterfly");
    IAlleleSpecies species = getSpeciesDirectly(ButterflyManager.butterflyRoot, itemStack);
    if (species instanceof IAlleleButterflySpecies) {
        return (IAlleleButterflySpecies) species;
    }
    return (IAlleleButterflySpecies) getActiveAllele(itemStack, EnumButterflyChromosome.SPECIES, ButterflyManager.butterflyRoot);
}
Also used : IAlleleSpecies(forestry.api.genetics.IAlleleSpecies) IAlleleButterflySpecies(forestry.api.lepidopterology.IAlleleButterflySpecies)

Example 23 with IAlleleSpecies

use of forestry.api.genetics.IAlleleSpecies in project ForestryMC by ForestryMC.

the class AlleleRegistry method registerAllele.

@Override
public void registerAllele(IAllele allele, IChromosomeType... chromosomeTypes) {
    addValidAlleleTypes(allele, chromosomeTypes);
    alleleMap.put(allele.getUID(), allele);
    if (allele instanceof IAlleleSpecies) {
        IClassification branch = ((IAlleleSpecies) allele).getBranch();
        branch.addMemberSpecies((IAlleleSpecies) allele);
    }
    for (IAlleleHandler handler : this.alleleHandlers) {
        handler.onRegisterAllele(allele);
    }
}
Also used : IAlleleSpecies(forestry.api.genetics.IAlleleSpecies) IAlleleHandler(forestry.api.genetics.IAlleleHandler) IClassification(forestry.api.genetics.IClassification)

Example 24 with IAlleleSpecies

use of forestry.api.genetics.IAlleleSpecies in project ForestryMC by ForestryMC.

the class EscritoireGame method probe.

public void probe(ItemStack specimen, IInventory inventory, int startSlot, int slotCount) {
    if (status != Status.PLAYING) {
        return;
    }
    IIndividual individual = AlleleManager.alleleRegistry.getIndividual(specimen);
    if (individual == null) {
        return;
    }
    if (bountyLevel > 1) {
        bountyLevel--;
    }
    IAlleleSpecies species = individual.getGenome().getPrimary();
    gameBoard.hideProbedTokens();
    int revealCount = getSampleSize(slotCount);
    for (int i = 0; i < revealCount; i++) {
        ItemStack sample = inventory.decrStackSize(startSlot + i, 1);
        if (!sample.isEmpty()) {
            if (rand.nextFloat() < species.getResearchSuitability(sample)) {
                gameBoard.probe();
            }
        }
    }
    lastUpdate = System.currentTimeMillis();
}
Also used : IIndividual(forestry.api.genetics.IIndividual) IAlleleSpecies(forestry.api.genetics.IAlleleSpecies) ItemStack(net.minecraft.item.ItemStack)

Example 25 with IAlleleSpecies

use of forestry.api.genetics.IAlleleSpecies in project ForestryMC by ForestryMC.

the class BeeDatabaseTab method createElements.

@Override
public void createElements(IGuiElementHelper elementHelper, IBee bee, ItemStack itemStack) {
    EnumBeeType type = BeeManager.beeRoot.getType(itemStack);
    if (type == null) {
        return;
    }
    IAlleleSpecies primarySpecies = bee.getGenome().getPrimary();
    boolean active = tab == EnumDatabaseTab.ACTIVE_SPECIES;
    elementHelper.addText(Translator.translateToLocal("for.gui.database.tab." + tab.name().toLowerCase() + ".name"), GuiElementAlignment.CENTER, 0xcfb53b);
    elementHelper.addAllele(Translator.translateToLocal("for.gui.species"), bee, EnumBeeChromosome.SPECIES, active);
    IAlleleTolerance tempTolerance = (IAlleleTolerance) (active ? bee.getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE) : bee.getGenome().getInactiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE));
    elementHelper.addText(TextFormatting.UNDERLINE + Translator.translateToLocal("for.gui.climate"), GuiElementAlignment.CENTER);
    elementHelper.addToleranceInfo(tempTolerance, primarySpecies, AlleleManager.climateHelper.toDisplay(primarySpecies.getTemperature()));
    IAlleleTolerance humidTolerance = (IAlleleTolerance) (active ? bee.getGenome().getActiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE) : bee.getGenome().getInactiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE));
    elementHelper.addText(TextFormatting.UNDERLINE + Translator.translateToLocal("for.gui.humidity"), GuiElementAlignment.CENTER);
    elementHelper.addToleranceInfo(humidTolerance, primarySpecies, AlleleManager.climateHelper.toDisplay(primarySpecies.getHumidity()));
    elementHelper.addAllele(Translator.translateToLocal("for.gui.lifespan"), bee, EnumBeeChromosome.LIFESPAN, active);
    elementHelper.addAllele(Translator.translateToLocal("for.gui.speed"), bee, EnumBeeChromosome.SPEED, active);
    elementHelper.addAllele(Translator.translateToLocal("for.gui.pollination"), bee, EnumBeeChromosome.FLOWERING, active);
    elementHelper.addAllele(Translator.translateToLocal("for.gui.flowers"), bee, EnumBeeChromosome.FLOWER_PROVIDER, active);
    IAlleleInteger primaryFertility = (IAlleleInteger) (active ? bee.getGenome().getActiveAllele(EnumBeeChromosome.FERTILITY) : bee.getGenome().getInactiveAllele(EnumBeeChromosome.FERTILITY));
    elementHelper.addText(TextFormatting.UNDERLINE + Translator.translateToLocal("for.gui.fertility"), GuiElementAlignment.CENTER);
    elementHelper.addFertilityInfo(primaryFertility, 0, 0);
    elementHelper.addAllele(Translator.translateToLocal("for.gui.area"), bee, EnumBeeChromosome.TERRITORY, active);
    elementHelper.addAllele(Translator.translateToLocal("for.gui.effect"), bee, EnumBeeChromosome.EFFECT, active);
    String yes = Translator.translateToLocal("for.yes");
    String no = Translator.translateToLocal("for.no");
    String diurnal, nocturnal;
    if (active) {
        if (bee.getGenome().getNeverSleeps()) {
            nocturnal = diurnal = yes;
        } else {
            nocturnal = bee.getGenome().getPrimary().isNocturnal() ? yes : no;
            diurnal = !bee.getGenome().getPrimary().isNocturnal() ? yes : no;
        }
    } else {
        if (((AlleleBoolean) bee.getGenome().getInactiveAllele(EnumButterflyChromosome.NOCTURNAL)).getValue()) {
            nocturnal = diurnal = yes;
        } else {
            nocturnal = bee.getGenome().getSecondary().isNocturnal() ? yes : no;
            diurnal = !bee.getGenome().getSecondary().isNocturnal() ? yes : no;
        }
    }
    elementHelper.addText(TextFormatting.UNDERLINE + Translator.translateToLocal("for.gui.diurnal"), GuiElementAlignment.CENTER);
    elementHelper.addText(diurnal, GuiElementAlignment.CENTER, elementHelper.factory().getColorCoding(false));
    elementHelper.addText(TextFormatting.UNDERLINE + Translator.translateToLocal("for.gui.nocturnal"), GuiElementAlignment.CENTER);
    elementHelper.addText(nocturnal, GuiElementAlignment.CENTER, elementHelper.factory().getColorCoding(false));
    String flyer = StringUtil.readableBoolean(active ? bee.getGenome().getToleratesRain() : ((AlleleBoolean) bee.getGenome().getInactiveAllele(EnumBeeChromosome.TOLERATES_RAIN)).getValue(), yes, no);
    elementHelper.addAllele(Translator.translateToLocal("for.gui.flyer"), (a) -> flyer, bee, EnumButterflyChromosome.TOLERANT_FLYER, active);
    String cave = StringUtil.readableBoolean(active ? bee.getGenome().getCaveDwelling() : ((AlleleBoolean) bee.getGenome().getInactiveAllele(EnumBeeChromosome.CAVE_DWELLING)).getValue(), yes, no);
    elementHelper.addAllele(Translator.translateToLocal("for.gui.fireresist"), (a) -> cave, bee, EnumButterflyChromosome.FIRE_RESIST, active);
    String displayText;
    if (type == EnumBeeType.PRINCESS || type == EnumBeeType.QUEEN) {
        String displayTextKey = "for.bees.stock.pristine";
        if (!bee.isNatural()) {
            displayTextKey = "for.bees.stock.ignoble";
        }
        displayText = Translator.translateToLocal(displayTextKey);
        elementHelper.addText(displayText, GuiElementAlignment.CENTER, ColourProperties.INSTANCE.get("gui.beealyzer.binomial"));
    }
}
Also used : IAlleleTolerance(forestry.api.genetics.IAlleleTolerance) IAlleleInteger(forestry.api.genetics.IAlleleInteger) IAlleleSpecies(forestry.api.genetics.IAlleleSpecies) EnumBeeType(forestry.api.apiculture.EnumBeeType) AlleleBoolean(forestry.core.genetics.alleles.AlleleBoolean)

Aggregations

IAlleleSpecies (forestry.api.genetics.IAlleleSpecies)37 ItemStack (net.minecraft.item.ItemStack)11 IAlleleTreeSpecies (forestry.api.arboriculture.IAlleleTreeSpecies)7 ITreeGenome (forestry.api.arboriculture.ITreeGenome)6 IAllele (forestry.api.genetics.IAllele)6 ArrayList (java.util.ArrayList)6 IBreedingSystem (binnie.core.api.genetics.IBreedingSystem)5 IIndividual (forestry.api.genetics.IIndividual)4 ISpeciesRoot (forestry.api.genetics.ISpeciesRoot)4 ControlText (binnie.core.gui.controls.ControlText)3 ControlSpeciesBox (binnie.core.gui.database.ControlSpeciesBox)3 WindowAbstractDatabase (binnie.core.gui.database.WindowAbstractDatabase)3 Area (binnie.core.gui.geometry.Area)3 IBreedingTracker (forestry.api.genetics.IBreedingTracker)3 IClassification (forestry.api.genetics.IClassification)3 IMutation (forestry.api.genetics.IMutation)3 Nullable (javax.annotation.Nullable)3 ITreeBreedingSystem (binnie.genetics.api.ITreeBreedingSystem)2 GameProfile (com.mojang.authlib.GameProfile)2 Alignment (binnie.core.api.gui.Alignment)1