use of forestry.api.genetics.IAlleleSpecies in project ForestryMC by ForestryMC.
the class ItemGermlingGE method getItemStackDisplayName.
@Override
public String getItemStackDisplayName(ItemStack itemstack) {
if (itemstack.getTagCompound() == null) {
return "Unknown";
}
IAlleleSpecies species = getSpecies(itemstack);
String customTreeKey = "for.trees.custom." + type.getName() + "." + species.getUnlocalizedName().replace("trees.species.", "");
if (Translator.canTranslateToLocal(customTreeKey)) {
return Translator.translateToLocal(customTreeKey);
}
String typeString = Translator.translateToLocal("for.trees.grammar." + type.getName() + ".type");
return Translator.translateToLocal("for.trees.grammar." + type.getName()).replaceAll("%SPECIES", species.getAlleleName()).replaceAll("%TYPE", typeString);
}
use of forestry.api.genetics.IAlleleSpecies in project ForestryMC by ForestryMC.
the class ButterflyGenome method getSpecies.
// NBT RETRIEVAL
public static IAlleleButterflySpecies getSpecies(ItemStack itemStack) {
Preconditions.checkArgument(ButterflyManager.butterflyRoot.isMember(itemStack), "Must be a butterfly");
IAlleleSpecies species = getSpeciesDirectly(ButterflyManager.butterflyRoot, itemStack);
if (species instanceof IAlleleButterflySpecies) {
return (IAlleleButterflySpecies) species;
}
return (IAlleleButterflySpecies) getActiveAllele(itemStack, EnumButterflyChromosome.SPECIES, ButterflyManager.butterflyRoot);
}
use of forestry.api.genetics.IAlleleSpecies in project ForestryMC by ForestryMC.
the class AlleleRegistry method registerAllele.
@Override
public void registerAllele(IAllele allele, IChromosomeType... chromosomeTypes) {
addValidAlleleTypes(allele, chromosomeTypes);
alleleMap.put(allele.getUID(), allele);
if (allele instanceof IAlleleSpecies) {
IClassification branch = ((IAlleleSpecies) allele).getBranch();
branch.addMemberSpecies((IAlleleSpecies) allele);
}
for (IAlleleHandler handler : this.alleleHandlers) {
handler.onRegisterAllele(allele);
}
}
use of forestry.api.genetics.IAlleleSpecies in project ForestryMC by ForestryMC.
the class EscritoireGame method probe.
public void probe(ItemStack specimen, IInventory inventory, int startSlot, int slotCount) {
if (status != Status.PLAYING) {
return;
}
IIndividual individual = AlleleManager.alleleRegistry.getIndividual(specimen);
if (individual == null) {
return;
}
if (bountyLevel > 1) {
bountyLevel--;
}
IAlleleSpecies species = individual.getGenome().getPrimary();
gameBoard.hideProbedTokens();
int revealCount = getSampleSize(slotCount);
for (int i = 0; i < revealCount; i++) {
ItemStack sample = inventory.decrStackSize(startSlot + i, 1);
if (!sample.isEmpty()) {
if (rand.nextFloat() < species.getResearchSuitability(sample)) {
gameBoard.probe();
}
}
}
lastUpdate = System.currentTimeMillis();
}
use of forestry.api.genetics.IAlleleSpecies in project ForestryMC by ForestryMC.
the class BeeDatabaseTab method createElements.
@Override
public void createElements(IGuiElementHelper elementHelper, IBee bee, ItemStack itemStack) {
EnumBeeType type = BeeManager.beeRoot.getType(itemStack);
if (type == null) {
return;
}
IAlleleSpecies primarySpecies = bee.getGenome().getPrimary();
boolean active = tab == EnumDatabaseTab.ACTIVE_SPECIES;
elementHelper.addText(Translator.translateToLocal("for.gui.database.tab." + tab.name().toLowerCase() + ".name"), GuiElementAlignment.CENTER, 0xcfb53b);
elementHelper.addAllele(Translator.translateToLocal("for.gui.species"), bee, EnumBeeChromosome.SPECIES, active);
IAlleleTolerance tempTolerance = (IAlleleTolerance) (active ? bee.getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE) : bee.getGenome().getInactiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE));
elementHelper.addText(TextFormatting.UNDERLINE + Translator.translateToLocal("for.gui.climate"), GuiElementAlignment.CENTER);
elementHelper.addToleranceInfo(tempTolerance, primarySpecies, AlleleManager.climateHelper.toDisplay(primarySpecies.getTemperature()));
IAlleleTolerance humidTolerance = (IAlleleTolerance) (active ? bee.getGenome().getActiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE) : bee.getGenome().getInactiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE));
elementHelper.addText(TextFormatting.UNDERLINE + Translator.translateToLocal("for.gui.humidity"), GuiElementAlignment.CENTER);
elementHelper.addToleranceInfo(humidTolerance, primarySpecies, AlleleManager.climateHelper.toDisplay(primarySpecies.getHumidity()));
elementHelper.addAllele(Translator.translateToLocal("for.gui.lifespan"), bee, EnumBeeChromosome.LIFESPAN, active);
elementHelper.addAllele(Translator.translateToLocal("for.gui.speed"), bee, EnumBeeChromosome.SPEED, active);
elementHelper.addAllele(Translator.translateToLocal("for.gui.pollination"), bee, EnumBeeChromosome.FLOWERING, active);
elementHelper.addAllele(Translator.translateToLocal("for.gui.flowers"), bee, EnumBeeChromosome.FLOWER_PROVIDER, active);
IAlleleInteger primaryFertility = (IAlleleInteger) (active ? bee.getGenome().getActiveAllele(EnumBeeChromosome.FERTILITY) : bee.getGenome().getInactiveAllele(EnumBeeChromosome.FERTILITY));
elementHelper.addText(TextFormatting.UNDERLINE + Translator.translateToLocal("for.gui.fertility"), GuiElementAlignment.CENTER);
elementHelper.addFertilityInfo(primaryFertility, 0, 0);
elementHelper.addAllele(Translator.translateToLocal("for.gui.area"), bee, EnumBeeChromosome.TERRITORY, active);
elementHelper.addAllele(Translator.translateToLocal("for.gui.effect"), bee, EnumBeeChromosome.EFFECT, active);
String yes = Translator.translateToLocal("for.yes");
String no = Translator.translateToLocal("for.no");
String diurnal, nocturnal;
if (active) {
if (bee.getGenome().getNeverSleeps()) {
nocturnal = diurnal = yes;
} else {
nocturnal = bee.getGenome().getPrimary().isNocturnal() ? yes : no;
diurnal = !bee.getGenome().getPrimary().isNocturnal() ? yes : no;
}
} else {
if (((AlleleBoolean) bee.getGenome().getInactiveAllele(EnumButterflyChromosome.NOCTURNAL)).getValue()) {
nocturnal = diurnal = yes;
} else {
nocturnal = bee.getGenome().getSecondary().isNocturnal() ? yes : no;
diurnal = !bee.getGenome().getSecondary().isNocturnal() ? yes : no;
}
}
elementHelper.addText(TextFormatting.UNDERLINE + Translator.translateToLocal("for.gui.diurnal"), GuiElementAlignment.CENTER);
elementHelper.addText(diurnal, GuiElementAlignment.CENTER, elementHelper.factory().getColorCoding(false));
elementHelper.addText(TextFormatting.UNDERLINE + Translator.translateToLocal("for.gui.nocturnal"), GuiElementAlignment.CENTER);
elementHelper.addText(nocturnal, GuiElementAlignment.CENTER, elementHelper.factory().getColorCoding(false));
String flyer = StringUtil.readableBoolean(active ? bee.getGenome().getToleratesRain() : ((AlleleBoolean) bee.getGenome().getInactiveAllele(EnumBeeChromosome.TOLERATES_RAIN)).getValue(), yes, no);
elementHelper.addAllele(Translator.translateToLocal("for.gui.flyer"), (a) -> flyer, bee, EnumButterflyChromosome.TOLERANT_FLYER, active);
String cave = StringUtil.readableBoolean(active ? bee.getGenome().getCaveDwelling() : ((AlleleBoolean) bee.getGenome().getInactiveAllele(EnumBeeChromosome.CAVE_DWELLING)).getValue(), yes, no);
elementHelper.addAllele(Translator.translateToLocal("for.gui.fireresist"), (a) -> cave, bee, EnumButterflyChromosome.FIRE_RESIST, active);
String displayText;
if (type == EnumBeeType.PRINCESS || type == EnumBeeType.QUEEN) {
String displayTextKey = "for.bees.stock.pristine";
if (!bee.isNatural()) {
displayTextKey = "for.bees.stock.ignoble";
}
displayText = Translator.translateToLocal(displayTextKey);
elementHelper.addText(displayText, GuiElementAlignment.CENTER, ColourProperties.INSTANCE.get("gui.beealyzer.binomial"));
}
}
Aggregations