Search in sources :

Example 16 with IIndividual

use of forestry.api.genetics.IIndividual 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 17 with IIndividual

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

the class GuiNaturalistInventory method drawGuiContainerBackgroundLayer.

@Override
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
    super.drawGuiContainerBackgroundLayer(f, i, j);
    String header = Translator.translateToLocal("for.gui.page") + " " + (pageCurrent + 1) + "/" + pageMax;
    fontRenderer.drawString(header, guiLeft + 95 + textLayout.getCenteredOffset(header, 98), guiTop + 10, ColourProperties.INSTANCE.get("gui.title"));
    IIndividual individual = getIndividualAtPosition(i, j);
    if (individual == null) {
        displayBreedingStatistics(10);
    }
    if (individual != null) {
        RenderHelper.enableGUIStandardItemLighting();
        textLayout.startPage();
        displaySpeciesInformation(true, individual.getGenome().getPrimary(), iconStacks.get(individual.getIdent()), 10);
        if (!individual.isPureBred(EnumTreeChromosome.SPECIES)) {
            displaySpeciesInformation(individual.isAnalyzed(), individual.getGenome().getSecondary(), iconStacks.get(individual.getGenome().getSecondary().getUID()), 10);
        }
        textLayout.endPage();
    }
}
Also used : IIndividual(forestry.api.genetics.IIndividual)

Example 18 with IIndividual

use of forestry.api.genetics.IIndividual 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)

Example 19 with IIndividual

use of forestry.api.genetics.IIndividual in project Binnie by ForestryMC.

the class PageSpeciesFlowerGenome method onValueChanged.

@Override
public void onValueChanged(IAlleleSpecies species) {
    deleteAllChildren();
    IAllele[] template = BotanyAPI.flowerRoot.getTemplate(species.getUID());
    if (template == null) {
        return;
    }
    IFlower flower = BotanyAPI.flowerRoot.templateAsIndividual(template);
    IFlowerGenome genome = flower.getGenome();
    IAlleleFlowerSpecies flowerSpecies = genome.getPrimary();
    int w = 144;
    int h = 176;
    new ControlText(this, new Area(0, 4, w, 16), I18N.localise(DatabaseConstants.BOTANY_GENOME_KEY + ".title"), TextJustification.MIDDLE_CENTER);
    ControlScrollableContent scrollable = new ControlScrollableContent(this, 4, 20, w - 8, h - 8 - 16, 12);
    Control contents = new Control(scrollable, 0, 0, w - 8 - 12, h - 8 - 16);
    int tw = w - 8 - 12;
    int w2 = 55;
    int w3 = tw - 50;
    int y = 0;
    int th = 14;
    int th2 = 18;
    new ControlText(contents, new Area(0, y, w2, th), I18N.localise(DatabaseConstants.BOTANY_GENOME_KEY + ".temp"), TextJustification.MIDDLE_RIGHT);
    new ControlText(contents, new Area(w2, y, w3, th), flowerSpecies.getTemperature().getName(), TextJustification.MIDDLE_LEFT);
    y += th;
    new ControlText(contents, new Area(0, y, w2, th), I18N.localise(DatabaseConstants.BOTANY_GENOME_KEY + ".moist"), TextJustification.MIDDLE_RIGHT);
    new ControlText(contents, new Area(w2, y, w3, th), EnumHelper.getLocalisedName(flowerSpecies.getMoisture(), false), TextJustification.MIDDLE_LEFT);
    y += th;
    new ControlText(contents, new Area(0, y, w2, th), I18N.localise(DatabaseConstants.BOTANY_GENOME_KEY + ".ph"), TextJustification.MIDDLE_RIGHT);
    new ControlText(contents, new Area(w2, y, w3, th), EnumHelper.getLocalisedName(flowerSpecies.getPH(), false), TextJustification.MIDDLE_LEFT);
    y += th;
    new ControlText(contents, new Area(0, y, w2, th), I18N.localise(DatabaseConstants.BOTANY_GENOME_KEY + ".fertility"), TextJustification.MIDDLE_RIGHT);
    new ControlText(contents, new Area(w2, y, w3, th), genome.getFertility() + "x", TextJustification.MIDDLE_LEFT);
    y += th;
    float lifespan = genome.getLifespan() * 68.27f / genome.getAgeChance() / 24000.0f;
    String lifespanValue = String.format("%.2f", lifespan);
    new ControlText(contents, new Area(0, y, w2, th), I18N.localise(DatabaseConstants.BOTANY_GENOME_KEY + ".lifespan"), TextJustification.MIDDLE_RIGHT);
    new ControlText(contents, new Area(w2, y, w3, th), I18N.localise(DatabaseConstants.BOTANY_GENOME_KEY + ".lifespan.value", lifespanValue), TextJustification.MIDDLE_LEFT);
    y += th;
    new ControlText(contents, new Area(0, y, w2, th), I18N.localise(DatabaseConstants.BOTANY_GENOME_KEY + ".nectar"), TextJustification.MIDDLE_RIGHT);
    new ControlText(contents, new Area(w2, y, w3, th), genome.getActiveAllele(EnumFlowerChromosome.SAPPINESS).getAlleleName(), TextJustification.MIDDLE_LEFT);
    y += th;
    int x = w2;
    int tot = 0;
    for (IIndividual vid : BotanyCore.getFlowerRoot().getIndividualTemplates()) {
        if (vid.getGenome().getPrimary() == flowerSpecies) {
            if (tot > 0 && tot % 3 == 0) {
                x -= 54;
                y += 18;
            }
            ItemStack stack = BotanyCore.getFlowerRoot().getMemberStack(vid, EnumFlowerStage.FLOWER);
            ControlItemDisplay display = new ControlItemDisplay(contents, x, y);
            display.setItemStack(stack);
            ++tot;
            x += 18;
        }
    }
    int numOfLines = 1 + (tot - 1) / 3;
    new ControlText(contents, new Area(0, y - (numOfLines - 1) * 18, w2, 4 + 18 * numOfLines), I18N.localise(DatabaseConstants.BOTANY_GENOME_KEY + ".varieties"), TextJustification.MIDDLE_RIGHT);
    y += th;
    contents.setSize(new Point(contents.getSize().xPos(), y));
    scrollable.setScrollableContent(contents);
}
Also used : IFlowerGenome(binnie.botany.api.genetics.IFlowerGenome) ControlItemDisplay(binnie.core.gui.minecraft.control.ControlItemDisplay) IFlower(binnie.botany.api.genetics.IFlower) IIndividual(forestry.api.genetics.IIndividual) ControlText(binnie.core.gui.controls.ControlText) Point(binnie.core.gui.geometry.Point) IAlleleFlowerSpecies(binnie.botany.api.genetics.IAlleleFlowerSpecies) Point(binnie.core.gui.geometry.Point) IAllele(forestry.api.genetics.IAllele) Area(binnie.core.gui.geometry.Area) Control(binnie.core.gui.controls.core.Control) ItemStack(net.minecraft.item.ItemStack) ControlScrollableContent(binnie.core.gui.controls.scroll.ControlScrollableContent)

Example 20 with IIndividual

use of forestry.api.genetics.IIndividual in project Binnie by ForestryMC.

the class WindowGenesis method refreshPickup.

private void refreshPickup() {
    this.panelPickup.deleteAllChildren();
    int i = 0;
    IBreedingSystem system = Binnie.GENETICS.getSystem(this.root);
    for (ISpeciesType type : system.getActiveTypes()) {
        IIndividual ind = this.root.templateAsIndividual(this.template);
        ind.analyze();
        ItemStack stack = this.root.getMemberStack(ind, type);
        ControlItemDisplay display = new ControlItemDisplay(this.panelPickup, 4 + i % 3 * 18, 4 + i / 3 * 18);
        display.setItemStack(stack);
        display.setTooltip();
        display.addEventHandler(EventMouse.Down.class, EventHandlerOrigin.SELF, display, event -> {
            NBTTagCompound nbt = new NBTTagCompound();
            stack.writeToNBT(nbt);
            Window.get(event.getOrigin()).sendClientAction(ACTION_GENESIS, nbt);
        });
        ++i;
    }
}
Also used : ControlItemDisplay(binnie.core.gui.minecraft.control.ControlItemDisplay) IIndividual(forestry.api.genetics.IIndividual) ISpeciesType(forestry.api.genetics.ISpeciesType) EventMouse(binnie.core.gui.events.EventMouse) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IBreedingSystem(binnie.core.api.genetics.IBreedingSystem) ItemStack(net.minecraft.item.ItemStack)

Aggregations

IIndividual (forestry.api.genetics.IIndividual)49 ISpeciesRoot (forestry.api.genetics.ISpeciesRoot)30 ItemStack (net.minecraft.item.ItemStack)29 IAllele (forestry.api.genetics.IAllele)14 IGenome (forestry.api.genetics.IGenome)10 ISpeciesType (forestry.api.genetics.ISpeciesType)8 Nullable (javax.annotation.Nullable)7 Gene (binnie.core.genetics.Gene)6 IChromosomeType (forestry.api.genetics.IChromosomeType)6 ArrayList (java.util.ArrayList)6 IBreedingSystem (binnie.core.api.genetics.IBreedingSystem)5 Random (java.util.Random)5 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)5 IGene (binnie.core.api.genetics.IGene)4 IAlleleSpecies (forestry.api.genetics.IAlleleSpecies)4 IBreedingTracker (forestry.api.genetics.IBreedingTracker)3 IFilterData (forestry.api.genetics.IFilterData)3 Tolerance (binnie.core.genetics.Tolerance)2 Point (binnie.core.gui.geometry.Point)2 ControlItemDisplay (binnie.core.gui.minecraft.control.ControlItemDisplay)2