use of forestry.api.genetics.IAlleleSpecies in project ForestryMC by ForestryMC.
the class BeeGenome method getSpecies.
// NBT RETRIEVAL
public static IAlleleBeeSpecies getSpecies(ItemStack itemStack) {
Preconditions.checkArgument(BeeManager.beeRoot.isMember(itemStack), "itemStack must be a bee");
IAlleleSpecies species = getSpeciesDirectly(BeeManager.beeRoot, itemStack);
if (species instanceof IAlleleBeeSpecies) {
return (IAlleleBeeSpecies) species;
}
return (IAlleleBeeSpecies) getActiveAllele(itemStack, EnumBeeChromosome.SPECIES, BeeManager.beeRoot);
}
use of forestry.api.genetics.IAlleleSpecies in project ForestryMC by ForestryMC.
the class ApicultureJeiPlugin method registerItemSubtypes.
@Override
public void registerItemSubtypes(ISubtypeRegistry subtypeRegistry) {
if (!ForestryAPI.enabledModules.contains(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.APICULTURE))) {
return;
}
ItemRegistryApiculture items = ModuleApiculture.getItems();
Preconditions.checkNotNull(items);
ISubtypeRegistry.ISubtypeInterpreter beeSubtypeInterpreter = itemStack -> {
IAlleleSpecies species = Genome.getSpeciesDirectly(BeeManager.beeRoot, itemStack);
return species == null ? ISubtypeRegistry.ISubtypeInterpreter.NONE : species.getUID();
};
subtypeRegistry.registerSubtypeInterpreter(items.beeDroneGE, beeSubtypeInterpreter);
subtypeRegistry.registerSubtypeInterpreter(items.beePrincessGE, beeSubtypeInterpreter);
subtypeRegistry.registerSubtypeInterpreter(items.beeQueenGE, beeSubtypeInterpreter);
}
use of forestry.api.genetics.IAlleleSpecies in project ForestryMC by ForestryMC.
the class CommandSaveStats method executeSubCommand.
@Override
public void executeSubCommand(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
if (args.length > 1) {
printHelp(sender);
return;
}
String newLine = System.getProperty("line.separator");
World world = sender.getEntityWorld();
EntityPlayerMP player;
if (args.length > 0) {
player = CommandBase.getPlayer(server, sender, args[0]);
} else {
player = CommandBase.getPlayer(server, sender, sender.getName());
}
Collection<String> statistics = new ArrayList<>();
String date = DateFormat.getInstance().format(new Date());
statistics.add(Translator.translateToLocalFormatted(saveHelper.getUnlocalizedSaveStatsString(), player.getDisplayName(), date));
statistics.add("");
statistics.add(Translator.translateToLocalFormatted("for.chat.command.forestry.stats.save.mode", modeHelper.getModeName(world)));
statistics.add("");
IBreedingTracker tracker = saveHelper.getBreedingTracker(world, player.getGameProfile());
saveHelper.addExtraInfo(statistics, tracker);
Collection<IAlleleSpecies> species = saveHelper.getSpecies();
String speciesCount = Translator.translateToLocal("for.gui.speciescount");
String speciesCountLine = String.format("%s (%s):", speciesCount, species.size());
statistics.add(speciesCountLine);
statistics.add(StringUtil.line(speciesCountLine.length()));
statistics.add(discoveredSymbol + ": " + Translator.translateToLocal("for.chat.command.forestry.stats.save.key.discovered"));
statistics.add(blacklistedSymbol + ": " + Translator.translateToLocal("for.chat.command.forestry.stats.save.key.blacklisted"));
statistics.add(notCountedSymbol + ": " + Translator.translateToLocal("for.chat.command.forestry.stats.save.key.notCounted"));
statistics.add("");
String header = generateSpeciesListHeader();
statistics.add(header);
statistics.add(StringUtil.line(header.length()));
statistics.add("");
for (IAlleleSpecies allele : species) {
statistics.add(generateSpeciesListEntry(allele, tracker));
}
File file = new File(Proxies.common.getForestryRoot(), "config/" + Constants.MOD_ID + "/stats/" + player.getDisplayNameString() + '-' + saveHelper.getFileSuffix() + ".log");
try {
File folder = file.getParentFile();
if (folder != null && !folder.exists()) {
boolean success = file.getParentFile().mkdirs();
if (!success) {
CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.stats.save.error1");
return;
}
}
if (!file.exists() && !file.createNewFile()) {
CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.stats.save.error1");
return;
}
if (!file.canWrite()) {
CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.stats.save.error2");
return;
}
FileOutputStream fileout = new FileOutputStream(file);
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(fileout, "UTF-8"));
writer.write("# " + Constants.MOD_ID + newLine + "# " + Constants.VERSION + newLine);
for (String line : statistics) {
writer.write(line + newLine);
}
writer.close();
} catch (IOException ex) {
CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.stats.save.error3");
Log.error(Translator.translateToLocal("for.for.chat.command.forestry.stats.save.error3"), ex);
return;
}
CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.stats.save.saved", player.getDisplayName());
}
use of forestry.api.genetics.IAlleleSpecies in project ForestryMC by ForestryMC.
the class GuiAlyzer method drawSpeciesRow.
public final void drawSpeciesRow(String text0, IIndividual individual, IChromosomeType chromosome, @Nullable String customPrimaryName, @Nullable String customSecondaryName) {
IAlleleSpecies primary = individual.getGenome().getPrimary();
IAlleleSpecies secondary = individual.getGenome().getSecondary();
textLayout.drawLine(text0, textLayout.column0);
int columnwidth = textLayout.column2 - textLayout.column1 - 2;
Map<String, ItemStack> iconStacks = chromosome.getSpeciesRoot().getAlyzerPlugin().getIconStacks();
GuiUtil.drawItemStack(this, iconStacks.get(primary.getUID()), guiLeft + textLayout.column1 + columnwidth - 20, guiTop + 10);
GuiUtil.drawItemStack(this, iconStacks.get(secondary.getUID()), guiLeft + textLayout.column2 + columnwidth - 20, guiTop + 10);
String primaryName = customPrimaryName == null ? primary.getAlleleName() : customPrimaryName;
String secondaryName = customSecondaryName == null ? secondary.getAlleleName() : customSecondaryName;
drawSplitLine(primaryName, textLayout.column1, columnwidth, individual, chromosome, false);
drawSplitLine(secondaryName, textLayout.column2, columnwidth, individual, chromosome, true);
textLayout.newLine();
}
use of forestry.api.genetics.IAlleleSpecies in project ForestryMC by ForestryMC.
the class GuiAlyzer method drawAnalyticsPageMutations.
public void drawAnalyticsPageMutations(IIndividual individual) {
textLayout.startPage(COLUMN_0, COLUMN_1, COLUMN_2);
textLayout.drawLine(Translator.translateToLocal("for.gui.beealyzer.mutations") + ":", COLUMN_0);
textLayout.newLine();
RenderHelper.enableGUIStandardItemLighting();
IGenome genome = individual.getGenome();
ISpeciesRoot speciesRoot = genome.getSpeciesRoot();
IAlleleSpecies species = genome.getPrimary();
int columnWidth = 50;
int x = 0;
EntityPlayer player = Minecraft.getMinecraft().player;
IBreedingTracker breedingTracker = speciesRoot.getBreedingTracker(player.world, player.getGameProfile());
for (IMutation mutation : speciesRoot.getCombinations(species)) {
if (breedingTracker.isDiscovered(mutation)) {
drawMutationInfo(mutation, species, COLUMN_0 + x, breedingTracker);
} else {
// Do not display secret undiscovered mutations.
if (mutation.isSecret()) {
continue;
}
drawUnknownMutation(mutation, COLUMN_0 + x, breedingTracker);
}
x += columnWidth;
if (x >= columnWidth * 4) {
x = 0;
textLayout.newLine(16);
}
}
textLayout.endPage();
}
Aggregations