Search in sources :

Example 11 with IChromosomeType

use of forestry.api.genetics.IChromosomeType 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 12 with IChromosomeType

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

Example 13 with IChromosomeType

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

the class Genome method chromosomesToString.

private String chromosomesToString(IChromosome[] chromosomes) {
    StringBuilder stringBuilder = new StringBuilder();
    IChromosomeType[] karyotype = getSpeciesRoot().getKaryotype();
    for (int i = 0; i < chromosomes.length; i++) {
        IChromosomeType chromosomeType = karyotype[i];
        IChromosome chromosome = chromosomes[i];
        stringBuilder.append(chromosomeType.getName()).append(": ").append(chromosome).append("\n");
    }
    return stringBuilder.toString();
}
Also used : IChromosome(forestry.api.genetics.IChromosome) IChromosomeType(forestry.api.genetics.IChromosomeType)

Example 14 with IChromosomeType

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

the class WindowGenesis method refreshTemplate.

private void refreshTemplate(@Nullable IChromosomeType selection) {
    List<Gene> genes = new ArrayList<>();
    IChromosomeType[] chromosomeTypes = Binnie.GENETICS.getChromosomeMap(this.root).keySet().toArray(new IChromosomeType[0]);
    for (IChromosomeType type : chromosomeTypes) {
        IAllele allele = this.template[type.ordinal()];
        if (allele == null) {
            throw new NullPointerException("Allele missing for Chromosome " + type.getName());
        }
        genes.add(new Gene(allele, type, this.root));
    }
    geneList.setOptions(genes);
    if (selection != null) {
        this.geneList.setValue(new Gene(this.template[selection.ordinal()], selection, this.root));
    } else {
        this.geneOptions.setOptions(new ArrayList<>());
    }
    this.refreshPickup();
}
Also used : IAllele(forestry.api.genetics.IAllele) Gene(binnie.core.genetics.Gene) ArrayList(java.util.ArrayList) IChromosomeType(forestry.api.genetics.IChromosomeType)

Example 15 with IChromosomeType

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

the class WindowFieldKit method initialiseClient.

@Override
@SideOnly(Side.CLIENT)
public void initialiseClient() {
    this.setTitle(I18N.localise("binniecore.gui.fieldkit.title"));
    CraftGUI.RENDER.setStyleSheet(StyleSheetManager.getSheet(StyleSheetManager.PUNNETT_SHEET));
    WindowInventory inventory = this.getWindowInventory();
    inventory.createSlot(INDIVIDUAL_SLOT);
    inventory.createSlot(PAPER_SLOT);
    this.setupValidators();
    new ControlPlayerInventory(this);
    final Point handGlass = new Point(16, 32);
    this.GlassControl = new ControlImage(this, handGlass.xPos(), handGlass.yPos(), new StandardTexture(0, 160, 96, 96, BinnieCoreTexture.GUI_PUNNETT));
    new ControlSlot.Builder(this, handGlass.xPos() + 54, handGlass.yPos() + 26).assign(InventoryType.WINDOW, 0);
    new ControlSlot.Builder(this, 208, 8).assign(InventoryType.WINDOW, 1);
    (this.text = new ControlText(this, new Point(232, 13), I18N.localise("binniecore.gui.fieldkit.paper"))).setColor(2236962);
    (this.text = new ControlText(this, new Area(0, 120, this.getWidth(), 24), "", TextJustification.MIDDLE_CENTER)).setColor(2236962);
    this.chromo = new ControlChromosome(this, 150, 24);
    this.addEventHandler(EventValueChanged.class, EventHandlerOrigin.DIRECT_CHILD, this.chromo, event -> {
        final IChromosomeType type = (IChromosomeType) event.getValue();
        if (type != null && WindowFieldKit.this.info.containsKey(type)) {
            final String t = WindowFieldKit.this.info.get(type);
            WindowFieldKit.this.text.setValue(t);
        } else {
            WindowFieldKit.this.text.setValue("");
        }
    });
}
Also used : StandardTexture(binnie.core.gui.resource.textures.StandardTexture) Area(binnie.core.gui.geometry.Area) WindowInventory(binnie.core.gui.minecraft.WindowInventory) ControlPlayerInventory(binnie.core.gui.minecraft.control.ControlPlayerInventory) ControlText(binnie.core.gui.controls.ControlText) ControlSlot(binnie.core.gui.minecraft.control.ControlSlot) Point(binnie.core.gui.geometry.Point) ControlImage(binnie.core.gui.minecraft.control.ControlImage) IChromosomeType(forestry.api.genetics.IChromosomeType) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

IChromosomeType (forestry.api.genetics.IChromosomeType)20 IAllele (forestry.api.genetics.IAllele)14 Gene (binnie.core.genetics.Gene)11 ISpeciesRoot (forestry.api.genetics.ISpeciesRoot)11 ArrayList (java.util.ArrayList)8 ItemStack (net.minecraft.item.ItemStack)7 IIndividual (forestry.api.genetics.IIndividual)6 IBreedingSystem (binnie.core.api.genetics.IBreedingSystem)5 List (java.util.List)5 IGene (binnie.core.api.genetics.IGene)4 Point (binnie.core.gui.geometry.Point)4 IChromosome (forestry.api.genetics.IChromosome)4 Map (java.util.Map)4 ControlText (binnie.core.gui.controls.ControlText)3 ControlPlayerInventory (binnie.core.gui.minecraft.control.ControlPlayerInventory)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 NBTTagList (net.minecraft.nbt.NBTTagList)3 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)3 BreedingSystem (binnie.core.genetics.BreedingSystem)2 Area (binnie.core.gui.geometry.Area)2