Search in sources :

Example 6 with Gene

use of binnie.core.genetics.Gene in project Binnie by ForestryMC.

the class ItemSerum method getSubItems.

@Override
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) {
    if (this.isInCreativeTab(tab)) {
        for (ISpeciesRoot root : AlleleManager.alleleRegistry.getSpeciesRoot().values()) {
            Map<IChromosomeType, List<IAllele>> chromosomeMap = Binnie.GENETICS.getChromosomeMap(root);
            if (chromosomeMap != null) {
                for (Map.Entry<IChromosomeType, List<IAllele>> entry : chromosomeMap.entrySet()) {
                    IChromosomeType chromosome = entry.getKey();
                    for (final IAllele allele : entry.getValue()) {
                        Gene gene = Gene.create(allele, chromosome, root);
                        IGeneItem geneItem = new GeneItem(gene);
                        ItemStack stack = new ItemStack(this);
                        geneItem.writeToItem(stack);
                        items.add(stack);
                    }
                }
            }
        }
    }
}
Also used : IAllele(forestry.api.genetics.IAllele) ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IGeneItem(binnie.genetics.genetics.IGeneItem) Gene(binnie.core.genetics.Gene) IGene(binnie.core.api.genetics.IGene) GeneItem(binnie.genetics.genetics.GeneItem) IGeneItem(binnie.genetics.genetics.IGeneItem) List(java.util.List) NonNullList(net.minecraft.util.NonNullList) IChromosomeType(forestry.api.genetics.IChromosomeType) ItemStack(net.minecraft.item.ItemStack) Map(java.util.Map)

Example 7 with Gene

use of binnie.core.genetics.Gene in project Binnie by ForestryMC.

the class ItemSerumArray method getSubItems.

@Override
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) {
    if (this.isInCreativeTab(tab)) {
        for (ISpeciesRoot root : AlleleManager.alleleRegistry.getSpeciesRoot().values()) {
            for (IIndividual template : root.getIndividualTemplates()) {
                if (template.getGenome().getPrimary().isSecret()) {
                    continue;
                }
                IGeneItem geneItem = new GeneArrayItem();
                for (IChromosomeType type : root.getKaryotype()) {
                    IChromosome chromosome = template.getGenome().getChromosomes()[type.ordinal()];
                    if (chromosome != null) {
                        IAllele active = chromosome.getActiveAllele();
                        geneItem.addGene(new Gene(active, type, root));
                    }
                }
                ItemStack array = new ItemStack(this);
                geneItem.writeToItem(array);
                items.add(array);
            }
        }
    }
}
Also used : IAllele(forestry.api.genetics.IAllele) ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IGeneItem(binnie.genetics.genetics.IGeneItem) IIndividual(forestry.api.genetics.IIndividual) Gene(binnie.core.genetics.Gene) IGene(binnie.core.api.genetics.IGene) IChromosome(forestry.api.genetics.IChromosome) IChromosomeType(forestry.api.genetics.IChromosomeType) ItemStack(net.minecraft.item.ItemStack) GeneArrayItem(binnie.genetics.genetics.GeneArrayItem)

Example 8 with Gene

use of binnie.core.genetics.Gene in project Binnie by ForestryMC.

the class ControlGeneScroll method refresh.

public void refresh() {
    if (system == null) {
        return;
    }
    this.deleteAllChildren();
    final GeneTracker tracker = GeneTracker.getTracker(Window.get(this).getWorld(), Window.get(this).getUsername());
    final Map<IChromosomeType, List<IAllele>> genes = Binnie.GENETICS.getChromosomeMap(this.system.getSpeciesRoot());
    int x = 0;
    int y = 0;
    final boolean master = ((WindowGeneBank) Window.get(this)).isMaster();
    for (final Map.Entry<IChromosomeType, List<IAllele>> entry : genes.entrySet()) {
        final List<IAllele> discovered = new ArrayList<>();
        for (final IAllele allele : entry.getValue()) {
            final Gene gene = new Gene(allele, entry.getKey(), this.system.getSpeciesRoot());
            if ((master || tracker.isSequenced(new Gene(allele, entry.getKey(), this.system.getSpeciesRoot()))) && gene.getName().toLowerCase().contains(this.filter)) {
                discovered.add(allele);
            }
        }
        if (discovered.size() == 0) {
            continue;
        }
        x = 0;
        new ControlText(this, new Point(x, y), this.system.getChromosomeName(entry.getKey()));
        y += 12;
        for (final IAllele allele : discovered) {
            if (x + 18 > this.getSize().xPos()) {
                y += 20;
                x = 0;
            }
            new ControlGene(this, x, y, new Gene(allele, entry.getKey(), this.system.getSpeciesRoot()));
            x += 18;
        }
        y += 24;
    }
    this.setSize(new Point(this.getSize().xPos(), y));
}
Also used : ControlText(binnie.core.gui.controls.ControlText) ArrayList(java.util.ArrayList) Point(binnie.core.gui.geometry.Point) Point(binnie.core.gui.geometry.Point) IAllele(forestry.api.genetics.IAllele) Gene(binnie.core.genetics.Gene) ArrayList(java.util.ArrayList) List(java.util.List) IChromosomeType(forestry.api.genetics.IChromosomeType) GeneTracker(binnie.genetics.genetics.GeneTracker) Map(java.util.Map)

Example 9 with Gene

use of binnie.core.genetics.Gene in project Binnie by ForestryMC.

the class ItemSequence method getSubItems.

@Override
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) {
    if (this.isInCreativeTab(tab)) {
        final IAlleleBeeSpecies species = (IAlleleBeeSpecies) AlleleManager.alleleRegistry.getAllele("forestry.speciesMeadows");
        Preconditions.checkNotNull(species);
        items.add(create(new Gene(species, EnumBeeChromosome.SPECIES, BeeManager.beeRoot), false));
    }
}
Also used : IAlleleBeeSpecies(forestry.api.apiculture.IAlleleBeeSpecies) IGene(binnie.core.api.genetics.IGene) Gene(binnie.core.genetics.Gene)

Example 10 with Gene

use of binnie.core.genetics.Gene in project Binnie by ForestryMC.

the class SequencerRecipeMaker method create.

public static List<SequencerRecipeWrapper> create() {
    List<SequencerRecipeWrapper> recipes = new ArrayList<>();
    Collection<ISpeciesRoot> roots = AlleleManager.alleleRegistry.getSpeciesRoot().values();
    for (ISpeciesRoot root : roots) {
        IChromosomeType speciesChromosomeType = root.getSpeciesChromosomeType();
        IAllele[] defaultTemplate = root.getDefaultTemplate();
        IAllele species = defaultTemplate[speciesChromosomeType.ordinal()];
        ItemStack filledSequence = ItemSequence.create(new Gene(species, speciesChromosomeType, root), false);
        recipes.add(new SequencerRecipeWrapper(filledSequence));
        filledSequence = filledSequence.copy();
        filledSequence.setItemDamage(0);
        recipes.add(new SequencerRecipeWrapper(filledSequence));
    }
    return recipes;
}
Also used : IAllele(forestry.api.genetics.IAllele) ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) Gene(binnie.core.genetics.Gene) ArrayList(java.util.ArrayList) IChromosomeType(forestry.api.genetics.IChromosomeType) ItemStack(net.minecraft.item.ItemStack)

Aggregations

Gene (binnie.core.genetics.Gene)18 IAllele (forestry.api.genetics.IAllele)11 IChromosomeType (forestry.api.genetics.IChromosomeType)11 ISpeciesRoot (forestry.api.genetics.ISpeciesRoot)10 ItemStack (net.minecraft.item.ItemStack)8 IGene (binnie.core.api.genetics.IGene)7 IIndividual (forestry.api.genetics.IIndividual)6 ArrayList (java.util.ArrayList)6 List (java.util.List)4 IBreedingSystem (binnie.core.api.genetics.IBreedingSystem)3 Map (java.util.Map)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 BreedingSystem (binnie.core.genetics.BreedingSystem)2 ControlText (binnie.core.gui.controls.ControlText)2 Point (binnie.core.gui.geometry.Point)2 ControlPlayerInventory (binnie.core.gui.minecraft.control.ControlPlayerInventory)2 Panel (binnie.core.gui.window.Panel)2 GeneTracker (binnie.genetics.genetics.GeneTracker)2 IGeneItem (binnie.genetics.genetics.IGeneItem)2 IGenome (forestry.api.genetics.IGenome)2