Search in sources :

Example 11 with ISpeciesRoot

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

the class EscritoireGameBoard method initialize.

public boolean initialize(ItemStack specimen) {
    IIndividual individual = AlleleManager.alleleRegistry.getIndividual(specimen);
    if (individual == null) {
        return false;
    }
    IGenome genome = individual.getGenome();
    ISpeciesRoot root = genome.getPrimary().getRoot();
    tokenCount = getTokenCount(genome);
    for (int i = 0; i < tokenCount / 2; i++) {
        IAllele[] randomTemplate = root.getRandomTemplate(rand);
        String speciesUid = randomTemplate[root.getSpeciesChromosomeType().ordinal()].getUID();
        gameTokens.add(new EscritoireGameToken(speciesUid));
        gameTokens.add(new EscritoireGameToken(speciesUid));
    }
    Collections.shuffle(gameTokens);
    return true;
}
Also used : IAllele(forestry.api.genetics.IAllele) IGenome(forestry.api.genetics.IGenome) ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IIndividual(forestry.api.genetics.IIndividual)

Example 12 with ISpeciesRoot

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

the class EscritoireGameToken method setTokenSpecies.

private void setTokenSpecies(String speciesUid) {
    IAllele allele = AlleleManager.alleleRegistry.getAllele(speciesUid);
    if (allele instanceof IAlleleSpecies) {
        IAlleleSpecies species = (IAlleleSpecies) allele;
        ISpeciesRoot root = species.getRoot();
        IAllele[] template = root.getTemplate(species);
        this.tokenIndividual = root.templateAsIndividual(template);
        this.tokenStack = root.getMemberStack(this.tokenIndividual, root.getIconType());
    }
}
Also used : IAllele(forestry.api.genetics.IAllele) ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IAlleleSpecies(forestry.api.genetics.IAlleleSpecies)

Example 13 with ISpeciesRoot

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

the class GuiAlyzer method drawGuiContainerBackgroundLayer.

@Override
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
    super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
    widgetManager.clear();
    int specimenSlot = getSpecimenSlot();
    if (specimenSlot < ItemInventoryAlyzer.SLOT_ANALYZE_1) {
        drawAnalyticsOverview();
        return;
    }
    ItemStack stackInSlot = itemInventory.getStackInSlot(specimenSlot);
    ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(stackInSlot);
    if (speciesRoot == null) {
        return;
    }
    switch(specimenSlot) {
        case ItemInventoryAlyzer.SLOT_ANALYZE_1:
            {
                speciesRoot.getAlyzerPlugin().drawAnalyticsPage1(this, stackInSlot);
                break;
            }
        case ItemInventoryAlyzer.SLOT_ANALYZE_2:
            {
                speciesRoot.getAlyzerPlugin().drawAnalyticsPage2(this, stackInSlot);
                break;
            }
        case ItemInventoryAlyzer.SLOT_ANALYZE_3:
            {
                speciesRoot.getAlyzerPlugin().drawAnalyticsPage3(this, stackInSlot);
                break;
            }
        case ItemInventoryAlyzer.SLOT_ANALYZE_4:
            {
                IIndividual individual = speciesRoot.getMember(stackInSlot);
                drawAnalyticsPageMutations(individual);
                break;
            }
        case ItemInventoryAlyzer.SLOT_ANALYZE_5:
            {
                IIndividual individual = speciesRoot.getMember(stackInSlot);
                drawAnalyticsPageClassification(individual);
                break;
            }
        default:
            drawAnalyticsOverview();
    }
}
Also used : ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IIndividual(forestry.api.genetics.IIndividual) ItemStack(net.minecraft.item.ItemStack)

Example 14 with ISpeciesRoot

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

the class GuiAlyzer method getSpecimenSlot.

private int getSpecimenSlot() {
    for (int k = ItemInventoryAlyzer.SLOT_SPECIMEN; k <= ItemInventoryAlyzer.SLOT_ANALYZE_5; k++) {
        ItemStack stackInSlot = itemInventory.getStackInSlot(k);
        if (stackInSlot.isEmpty()) {
            continue;
        }
        ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(stackInSlot);
        if (speciesRoot == null) {
            continue;
        }
        IIndividual individual = speciesRoot.getMember(stackInSlot);
        if (!individual.isAnalyzed()) {
            continue;
        }
        return k;
    }
    return -1;
}
Also used : ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IIndividual(forestry.api.genetics.IIndividual) ItemStack(net.minecraft.item.ItemStack)

Example 15 with ISpeciesRoot

use of forestry.api.genetics.ISpeciesRoot in project EnderIO by SleepyTrousers.

the class SpeciesItemFilter method itemMatched.

private boolean itemMatched(@Nonnull ItemStack item) {
    if (Prep.isInvalid(item)) {
        return false;
    }
    ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(item);
    if (speciesRoot == null) {
        return false;
    }
    IIndividual member = speciesRoot.getMember(item);
    if (member == null) {
        return false;
    }
    IGenome genome = member.getGenome();
    String primarySpeciesUid = genome.getPrimary().getUID();
    String secondarySpeciesUid = genome.getSecondary().getUID();
    for (int slot = 0; slot < items.size(); slot++) {
        ItemStack slotItem = items.get(slot);
        if (slotItem.getItem() == item.getItem()) {
            switch(speciesMode) {
                case BOTH:
                    if (primarySpeciesUids[slot].equals(primarySpeciesUid) && secondarySpeciesUids[slot].equals(secondarySpeciesUid)) {
                        return true;
                    }
                    break;
                case PRIMARY:
                    if (primarySpeciesUids[slot].equals(primarySpeciesUid)) {
                        return true;
                    }
                    break;
                case SECONDARY:
                    if (secondarySpeciesUids[slot].equals(secondarySpeciesUid)) {
                        return true;
                    }
                    break;
            }
        }
    }
    return false;
}
Also used : IGenome(forestry.api.genetics.IGenome) ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IIndividual(forestry.api.genetics.IIndividual) TextComponentString(net.minecraft.util.text.TextComponentString) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ISpeciesRoot (forestry.api.genetics.ISpeciesRoot)49 IIndividual (forestry.api.genetics.IIndividual)30 ItemStack (net.minecraft.item.ItemStack)20 IAllele (forestry.api.genetics.IAllele)17 IChromosomeType (forestry.api.genetics.IChromosomeType)11 Gene (binnie.core.genetics.Gene)10 IBreedingTracker (forestry.api.genetics.IBreedingTracker)7 IGenome (forestry.api.genetics.IGenome)7 ArrayList (java.util.ArrayList)7 IBreedingSystem (binnie.core.api.genetics.IBreedingSystem)6 ISpeciesType (forestry.api.genetics.ISpeciesType)6 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)6 IGene (binnie.core.api.genetics.IGene)4 IAlleleSpecies (forestry.api.genetics.IAlleleSpecies)4 IFilterData (forestry.api.genetics.IFilterData)3 List (java.util.List)3 Random (java.util.Random)3 Nullable (javax.annotation.Nullable)3 IGeneItem (binnie.genetics.genetics.IGeneItem)2 ForestryEvent (forestry.api.core.ForestryEvent)2