Search in sources :

Example 26 with IAlleleSpecies

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);
}
Also used : IAlleleBeeSpecies(forestry.api.apiculture.IAlleleBeeSpecies) IAlleleSpecies(forestry.api.genetics.IAlleleSpecies)

Example 27 with IAlleleSpecies

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);
}
Also used : JEIPlugin(mezz.jei.api.JEIPlugin) IModRegistry(mezz.jei.api.IModRegistry) IAlleleSpecies(forestry.api.genetics.IAlleleSpecies) JeiUtil(forestry.core.utils.JeiUtil) ForestryModuleUids(forestry.modules.ForestryModuleUids) BeeManager(forestry.api.apiculture.BeeManager) ISubtypeRegistry(mezz.jei.api.ISubtypeRegistry) IModPlugin(mezz.jei.api.IModPlugin) ForestryAPI(forestry.api.core.ForestryAPI) Constants(forestry.core.config.Constants) ItemRegistryApiculture(forestry.apiculture.items.ItemRegistryApiculture) ResourceLocation(net.minecraft.util.ResourceLocation) Preconditions(com.google.common.base.Preconditions) Genome(forestry.core.genetics.Genome) ModuleApiculture(forestry.apiculture.ModuleApiculture) ResourceLocation(net.minecraft.util.ResourceLocation) ItemRegistryApiculture(forestry.apiculture.items.ItemRegistryApiculture) IAlleleSpecies(forestry.api.genetics.IAlleleSpecies) ISubtypeRegistry(mezz.jei.api.ISubtypeRegistry)

Example 28 with IAlleleSpecies

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());
}
Also used : IBreedingTracker(forestry.api.genetics.IBreedingTracker) ArrayList(java.util.ArrayList) IOException(java.io.IOException) World(net.minecraft.world.World) Date(java.util.Date) BufferedWriter(java.io.BufferedWriter) IAlleleSpecies(forestry.api.genetics.IAlleleSpecies) FileOutputStream(java.io.FileOutputStream) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) OutputStreamWriter(java.io.OutputStreamWriter) File(java.io.File)

Example 29 with IAlleleSpecies

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();
}
Also used : IAlleleSpecies(forestry.api.genetics.IAlleleSpecies) ItemStack(net.minecraft.item.ItemStack)

Example 30 with IAlleleSpecies

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();
}
Also used : IGenome(forestry.api.genetics.IGenome) ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IMutation(forestry.api.genetics.IMutation) IBreedingTracker(forestry.api.genetics.IBreedingTracker) IAlleleSpecies(forestry.api.genetics.IAlleleSpecies) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Aggregations

IAlleleSpecies (forestry.api.genetics.IAlleleSpecies)37 ItemStack (net.minecraft.item.ItemStack)11 IAlleleTreeSpecies (forestry.api.arboriculture.IAlleleTreeSpecies)7 ITreeGenome (forestry.api.arboriculture.ITreeGenome)6 IAllele (forestry.api.genetics.IAllele)6 ArrayList (java.util.ArrayList)6 IBreedingSystem (binnie.core.api.genetics.IBreedingSystem)5 IIndividual (forestry.api.genetics.IIndividual)4 ISpeciesRoot (forestry.api.genetics.ISpeciesRoot)4 ControlText (binnie.core.gui.controls.ControlText)3 ControlSpeciesBox (binnie.core.gui.database.ControlSpeciesBox)3 WindowAbstractDatabase (binnie.core.gui.database.WindowAbstractDatabase)3 Area (binnie.core.gui.geometry.Area)3 IBreedingTracker (forestry.api.genetics.IBreedingTracker)3 IClassification (forestry.api.genetics.IClassification)3 IMutation (forestry.api.genetics.IMutation)3 Nullable (javax.annotation.Nullable)3 ITreeBreedingSystem (binnie.genetics.api.ITreeBreedingSystem)2 GameProfile (com.mojang.authlib.GameProfile)2 Alignment (binnie.core.api.gui.Alignment)1