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