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));
}
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;
}
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();
}
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();
}
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("");
}
});
}
Aggregations