Search in sources :

Example 11 with IBreedingSystem

use of binnie.core.api.genetics.IBreedingSystem in project Binnie by ForestryMC.

the class ControlAnalystChromosome method getTooltip.

@Override
public void getTooltip(Tooltip tooltip, ITooltipFlag tooltipFlag) {
    IBreedingSystem system = Binnie.GENETICS.getSystem(root);
    tooltip.add(system.getChromosomeName(chromosomeType));
    if (isHomozygous()) {
        tooltip.add(system.getAlleleName(chromosomeType, allele0));
    } else {
        tooltip.add("Active: " + system.getAlleleName(chromosomeType, allele0));
        tooltip.add("Inactive: " + system.getAlleleName(chromosomeType, allele1));
    }
}
Also used : IBreedingSystem(binnie.core.api.genetics.IBreedingSystem)

Example 12 with IBreedingSystem

use of binnie.core.api.genetics.IBreedingSystem in project Binnie by ForestryMC.

the class ManagerGenetics method loadAlleles.

private void loadAlleles() {
    this.invalidChromosomeTypes.clear();
    for (IBreedingSystem system : BREEDING_SYSTEMS.values()) {
        ISpeciesRoot root = system.getSpeciesRoot();
        Map<IChromosomeType, List<IAllele>> chromosomeMap = new LinkedHashMap<>();
        for (IChromosomeType chromosome : root.getKaryotype()) {
            TreeSet<IAllele> alleles = new TreeSet<>(new ComparatorAllele());
            for (IIndividual individual : root.getIndividualTemplates()) {
                IGenome genome = individual.getGenome();
                IAllele activeAllele = genome.getActiveAllele(chromosome);
                IAllele inactiveAllele = genome.getInactiveAllele(chromosome);
                if (chromosome.getAlleleClass().isInstance(activeAllele)) {
                    alleles.add(activeAllele);
                }
                if (!chromosome.getAlleleClass().isInstance(inactiveAllele)) {
                    continue;
                }
                alleles.add(inactiveAllele);
            }
            system.addExtraAlleles(chromosome, alleles);
            if (alleles.size() == 0) {
                this.invalidChromosomeTypes.add(chromosome);
            } else {
                final List<IAllele> alleleList = new ArrayList<>(alleles);
                chromosomeMap.put(chromosome, alleleList);
            }
        }
        this.chromosomeArray.put(root, chromosomeMap);
    }
}
Also used : IIndividual(forestry.api.genetics.IIndividual) ArrayList(java.util.ArrayList) IBreedingSystem(binnie.core.api.genetics.IBreedingSystem) LinkedHashMap(java.util.LinkedHashMap) IAllele(forestry.api.genetics.IAllele) IGenome(forestry.api.genetics.IGenome) ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) List(java.util.List) IChromosomeType(forestry.api.genetics.IChromosomeType)

Example 13 with IBreedingSystem

use of binnie.core.api.genetics.IBreedingSystem in project Binnie by ForestryMC.

the class ManagerGenetics method getFirstActiveSystem.

public IBreedingSystem getFirstActiveSystem() {
    Collection<IBreedingSystem> activeSystems = getActiveSystems();
    IBreedingSystem first = Iterables.getFirst(activeSystems, null);
    if (first == null) {
        throw new IllegalStateException("There are no breeding systems");
    }
    return first;
}
Also used : IBreedingSystem(binnie.core.api.genetics.IBreedingSystem)

Example 14 with IBreedingSystem

use of binnie.core.api.genetics.IBreedingSystem in project Binnie by ForestryMC.

the class WindowGeneBank method initialiseClient.

@Override
@SideOnly(Side.CLIENT)
public void initialiseClient() {
    super.initialiseClient();
    this.addEventHandler(EventValueChanged.class, event -> {
        if (event.getValue() instanceof BreedingSystem) {
            WindowGeneBank.this.genes.setValue((IBreedingSystem) event.getValue());
        }
    });
    int x = 16;
    final int y = 32;
    new ControlPlayerInventory(this, x, y);
    x += 124;
    int boxX = x;
    final int geneBoxWidth = 120;
    new Panel(this, boxX + 24, 32, geneBoxWidth, 120, MinecraftGUI.PanelType.BLACK);
    new Panel(this, boxX + 24 + geneBoxWidth, 32, 14, 120, MinecraftGUI.PanelType.GRAY);
    final ControlScrollableContent<ControlGeneScroll> scroll = new ControlScrollableContent<>(this, boxX + 24 + 2, 34, geneBoxWidth + 10, 116, 12);
    final ControlTextEdit edit = new ControlTextEdit(this, boxX + 27 + geneBoxWidth - 70, 18, 80, 12);
    this.addEventHandler(EventTextEdit.class, EventHandlerOrigin.SELF, edit, event -> {
        String value = event.getValue();
        if (value == null) {
            value = "";
        }
        WindowGeneBank.this.genes.setFilter(value);
    });
    this.genes = new ControlGeneScroll(scroll, 1, 1, geneBoxWidth, 116);
    scroll.setScrollableContent(this.genes);
    this.genes.setGenes(Binnie.GENETICS.getFirstActiveSystem());
    final ControlTabBar<IBreedingSystem> tabBar = new GeneBankTabBar(this, boxX);
    tabBar.setValue(Binnie.GENETICS.getFirstActiveSystem());
    boxX -= 8;
    final ControlTabBar<String> infoTabs = new ControlTabBar<>(this, boxX + 8, 160, 16, 50, Alignment.LEFT, Arrays.asList("Info", "Stats", "Ranking"));
    final Panel panelProject = new Panel(this, boxX + 24, 160, geneBoxWidth + 20, 50, MinecraftGUI.PanelType.BLACK);
    int totalGenes = 0;
    int seqGenes = 0;
    for (final IBreedingSystem system : Binnie.GENETICS.getActiveSystems()) {
        final GeneTracker tracker = GeneTracker.getTracker(this.getWorld(), this.getUsername());
        final Map<IChromosomeType, List<IAllele>> genes = Binnie.GENETICS.getChromosomeMap(system.getSpeciesRoot());
        for (final Map.Entry<IChromosomeType, List<IAllele>> entry : genes.entrySet()) {
            totalGenes += entry.getValue().size();
            for (final IAllele allele : entry.getValue()) {
                final Gene gene = new Gene(allele, entry.getKey(), system.getSpeciesRoot());
                if (tracker.isSequenced(gene)) {
                    ++seqGenes;
                }
            }
        }
    }
    new ControlText(panelProject, new Point(4, 4), "§nFull Genome Project");
    new ControlText(panelProject, new Point(4, 18), "§oSequenced §r" + seqGenes + '/' + totalGenes + " §oGenes");
}
Also used : BreedingSystem(binnie.core.genetics.BreedingSystem) IBreedingSystem(binnie.core.api.genetics.IBreedingSystem) ControlTextEdit(binnie.core.gui.controls.ControlTextEdit) ControlText(binnie.core.gui.controls.ControlText) IBreedingSystem(binnie.core.api.genetics.IBreedingSystem) Point(binnie.core.gui.geometry.Point) Point(binnie.core.gui.geometry.Point) ControlTabBar(binnie.core.gui.controls.tab.ControlTabBar) IAllele(forestry.api.genetics.IAllele) Panel(binnie.core.gui.window.Panel) Gene(binnie.core.genetics.Gene) ControlPlayerInventory(binnie.core.gui.minecraft.control.ControlPlayerInventory) List(java.util.List) IChromosomeType(forestry.api.genetics.IChromosomeType) GeneTracker(binnie.genetics.genetics.GeneTracker) Map(java.util.Map) ControlScrollableContent(binnie.core.gui.controls.scroll.ControlScrollableContent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 15 with IBreedingSystem

use of binnie.core.api.genetics.IBreedingSystem in project Binnie by ForestryMC.

the class PagePlanksTrees method getTreesThatMakePlanks.

private static Collection<IAlleleSpecies> getTreesThatMakePlanks(ItemStack fruit, boolean master, World world, GameProfile player) {
    if (fruit == null) {
        return new ArrayList<>();
    }
    ITreeRoot treeRoot = TreeManager.treeRoot;
    IBreedingSystem system = Binnie.GENETICS.getSystem(treeRoot);
    final Collection<IAlleleSpecies> set = master ? system.getAllSpecies() : system.getDiscoveredSpecies(world, player);
    final List<IAlleleSpecies> found = new ArrayList<>();
    for (final IAlleleSpecies species : set) {
        final IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
        ITreeGenome genome = treeRoot.templateAsGenome(treeRoot.getTemplate(tSpecies));
        IAlleleTreeSpecies treeSpecies = genome.getPrimary();
        final ItemStack woodStack = treeSpecies.getWoodProvider().getWoodStack();
        ItemStack plankProduct = LumbermillRecipeManager.getPlankProduct(woodStack, world);
        if (!plankProduct.isEmpty() && fruit.isItemEqual(plankProduct)) {
            found.add(species);
        }
    }
    return found;
}
Also used : IAlleleTreeSpecies(forestry.api.arboriculture.IAlleleTreeSpecies) ITreeRoot(forestry.api.arboriculture.ITreeRoot) IAlleleSpecies(forestry.api.genetics.IAlleleSpecies) ArrayList(java.util.ArrayList) IBreedingSystem(binnie.core.api.genetics.IBreedingSystem) ItemStack(net.minecraft.item.ItemStack) ITreeGenome(forestry.api.arboriculture.ITreeGenome)

Aggregations

IBreedingSystem (binnie.core.api.genetics.IBreedingSystem)22 ArrayList (java.util.ArrayList)8 IAllele (forestry.api.genetics.IAllele)7 ISpeciesRoot (forestry.api.genetics.ISpeciesRoot)6 IChromosomeType (forestry.api.genetics.IChromosomeType)5 IIndividual (forestry.api.genetics.IIndividual)5 ItemStack (net.minecraft.item.ItemStack)5 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)5 IAlleleSpecies (forestry.api.genetics.IAlleleSpecies)4 Gene (binnie.core.genetics.Gene)3 Point (binnie.core.gui.geometry.Point)3 ControlPlayerInventory (binnie.core.gui.minecraft.control.ControlPlayerInventory)3 List (java.util.List)3 IGene (binnie.core.api.genetics.IGene)2 BreedingSystem (binnie.core.genetics.BreedingSystem)2 ControlText (binnie.core.gui.controls.ControlText)2 Control (binnie.core.gui.controls.core.Control)2 ControlScrollableContent (binnie.core.gui.controls.scroll.ControlScrollableContent)2 Area (binnie.core.gui.geometry.Area)2 ControlItemDisplay (binnie.core.gui.minecraft.control.ControlItemDisplay)2