use of forestry.api.genetics.ISpeciesRoot in project ForestryMC by ForestryMC.
the class EscritoireGameBoard method initialize.
public boolean initialize(ItemStack specimen) {
IIndividual individual = AlleleManager.alleleRegistry.getIndividual(specimen);
if (individual == null) {
return false;
}
IGenome genome = individual.getGenome();
ISpeciesRoot root = genome.getPrimary().getRoot();
tokenCount = getTokenCount(genome);
for (int i = 0; i < tokenCount / 2; i++) {
IAllele[] randomTemplate = root.getRandomTemplate(rand);
String speciesUid = randomTemplate[root.getSpeciesChromosomeType().ordinal()].getUID();
gameTokens.add(new EscritoireGameToken(speciesUid));
gameTokens.add(new EscritoireGameToken(speciesUid));
}
Collections.shuffle(gameTokens);
return true;
}
use of forestry.api.genetics.ISpeciesRoot in project ForestryMC by ForestryMC.
the class EscritoireGameToken method setTokenSpecies.
private void setTokenSpecies(String speciesUid) {
IAllele allele = AlleleManager.alleleRegistry.getAllele(speciesUid);
if (allele instanceof IAlleleSpecies) {
IAlleleSpecies species = (IAlleleSpecies) allele;
ISpeciesRoot root = species.getRoot();
IAllele[] template = root.getTemplate(species);
this.tokenIndividual = root.templateAsIndividual(template);
this.tokenStack = root.getMemberStack(this.tokenIndividual, root.getIconType());
}
}
use of forestry.api.genetics.ISpeciesRoot in project ForestryMC by ForestryMC.
the class GuiAlyzer method drawGuiContainerBackgroundLayer.
@Override
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
widgetManager.clear();
int specimenSlot = getSpecimenSlot();
if (specimenSlot < ItemInventoryAlyzer.SLOT_ANALYZE_1) {
drawAnalyticsOverview();
return;
}
ItemStack stackInSlot = itemInventory.getStackInSlot(specimenSlot);
ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(stackInSlot);
if (speciesRoot == null) {
return;
}
switch(specimenSlot) {
case ItemInventoryAlyzer.SLOT_ANALYZE_1:
{
speciesRoot.getAlyzerPlugin().drawAnalyticsPage1(this, stackInSlot);
break;
}
case ItemInventoryAlyzer.SLOT_ANALYZE_2:
{
speciesRoot.getAlyzerPlugin().drawAnalyticsPage2(this, stackInSlot);
break;
}
case ItemInventoryAlyzer.SLOT_ANALYZE_3:
{
speciesRoot.getAlyzerPlugin().drawAnalyticsPage3(this, stackInSlot);
break;
}
case ItemInventoryAlyzer.SLOT_ANALYZE_4:
{
IIndividual individual = speciesRoot.getMember(stackInSlot);
drawAnalyticsPageMutations(individual);
break;
}
case ItemInventoryAlyzer.SLOT_ANALYZE_5:
{
IIndividual individual = speciesRoot.getMember(stackInSlot);
drawAnalyticsPageClassification(individual);
break;
}
default:
drawAnalyticsOverview();
}
}
use of forestry.api.genetics.ISpeciesRoot in project ForestryMC by ForestryMC.
the class GuiAlyzer method getSpecimenSlot.
private int getSpecimenSlot() {
for (int k = ItemInventoryAlyzer.SLOT_SPECIMEN; k <= ItemInventoryAlyzer.SLOT_ANALYZE_5; k++) {
ItemStack stackInSlot = itemInventory.getStackInSlot(k);
if (stackInSlot.isEmpty()) {
continue;
}
ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(stackInSlot);
if (speciesRoot == null) {
continue;
}
IIndividual individual = speciesRoot.getMember(stackInSlot);
if (!individual.isAnalyzed()) {
continue;
}
return k;
}
return -1;
}
use of forestry.api.genetics.ISpeciesRoot in project EnderIO by SleepyTrousers.
the class SpeciesItemFilter method itemMatched.
private boolean itemMatched(@Nonnull ItemStack item) {
if (Prep.isInvalid(item)) {
return false;
}
ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(item);
if (speciesRoot == null) {
return false;
}
IIndividual member = speciesRoot.getMember(item);
if (member == null) {
return false;
}
IGenome genome = member.getGenome();
String primarySpeciesUid = genome.getPrimary().getUID();
String secondarySpeciesUid = genome.getSecondary().getUID();
for (int slot = 0; slot < items.size(); slot++) {
ItemStack slotItem = items.get(slot);
if (slotItem.getItem() == item.getItem()) {
switch(speciesMode) {
case BOTH:
if (primarySpeciesUids[slot].equals(primarySpeciesUid) && secondarySpeciesUids[slot].equals(secondarySpeciesUid)) {
return true;
}
break;
case PRIMARY:
if (primarySpeciesUids[slot].equals(primarySpeciesUid)) {
return true;
}
break;
case SECONDARY:
if (secondarySpeciesUids[slot].equals(secondarySpeciesUid)) {
return true;
}
break;
}
}
}
return false;
}
Aggregations