Search in sources :

Example 1 with ISpeciesPlugin

use of forestry.api.genetics.ISpeciesPlugin in project ForestryMC by ForestryMC.

the class GuiElementFactory method createMutation.

public IGuiElementLayout createMutation(int x, int y, int width, int height, IMutation mutation, IAllele species, IBreedingTracker breedingTracker) {
    if (breedingTracker.isDiscovered(mutation)) {
        GuiElementPanel element = new GuiElementPanel(x, y, width, height);
        ISpeciesRoot speciesRoot = mutation.getRoot();
        int speciesIndex = speciesRoot.getSpeciesChromosomeType().ordinal();
        ISpeciesPlugin plugin = mutation.getRoot().getSpeciesPlugin();
        Map<String, ItemStack> iconStacks = plugin.getIndividualStacks();
        ItemStack partner = iconStacks.get(mutation.getPartner(species).getUID());
        IAllele resultAllele = mutation.getTemplate()[speciesIndex];
        ItemStack result = iconStacks.get(resultAllele.getUID());
        element.addElements(new GuiElementItemStack(0, 0, partner), new GuiElementItemStack(33, 0, result));
        element.addElements(createProbabilityArrow(mutation, 18, 4, breedingTracker));
        return element;
    }
    // Do not display secret undiscovered mutations.
    if (mutation.isSecret()) {
        return null;
    }
    return createUnknownMutationGroup(x, y, width, height, mutation, breedingTracker);
}
Also used : IAllele(forestry.api.genetics.IAllele) ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) ISpeciesPlugin(forestry.api.genetics.ISpeciesPlugin) ItemStack(net.minecraft.item.ItemStack)

Example 2 with ISpeciesPlugin

use of forestry.api.genetics.ISpeciesPlugin in project ForestryMC by ForestryMC.

the class DatabaseScreenLogic method getTabs.

private IDatabaseTab[] getTabs(ISpeciesRoot speciesRoot) {
    ISpeciesPlugin databasePlugin = speciesRoot.getSpeciesPlugin();
    if (databasePlugin == null) {
        // no plugin ofr this species
        return null;
    }
    this.databasePlugin = databasePlugin;
    IDatabaseTab[] tabs = new IDatabaseTab[4];
    IDatabaseTab speciesTab = databasePlugin.getSpeciesTab(true);
    if (speciesTab == null) {
        // the plugin does not support the database
        return null;
    }
    IDatabaseTab productsTab = databasePlugin.getProductsTab();
    IDatabaseTab mutationTab = databasePlugin.getMutationTab();
    if (productsTab == null) {
        productsTab = DatabaseTab.PRODUCTS;
    }
    if (mutationTab == null) {
        mutationTab = DatabaseTab.MUTATIONS;
    }
    tabs[0] = speciesTab;
    tabs[1] = databasePlugin.getSpeciesTab(false);
    tabs[2] = productsTab;
    tabs[3] = mutationTab;
    return tabs;
}
Also used : ISpeciesPlugin(forestry.api.genetics.ISpeciesPlugin) IDatabaseTab(forestry.api.genetics.IDatabaseTab)

Aggregations

ISpeciesPlugin (forestry.api.genetics.ISpeciesPlugin)2 IAllele (forestry.api.genetics.IAllele)1 IDatabaseTab (forestry.api.genetics.IDatabaseTab)1 ISpeciesRoot (forestry.api.genetics.ISpeciesRoot)1 ItemStack (net.minecraft.item.ItemStack)1