Search in sources :

Example 1 with IAlleleInteger

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

the class TreeAlyzerPlugin method drawAnalyticsPage1.

@SideOnly(Side.CLIENT)
@Override
public void drawAnalyticsPage1(GuiScreen gui, ItemStack itemStack) {
    if (gui instanceof GuiAlyzer) {
        GuiAlyzer guiAlyzer = (GuiAlyzer) gui;
        ITree tree = TreeManager.treeRoot.getMember(itemStack);
        if (tree == null) {
            return;
        }
        EnumGermlingType type = TreeManager.treeRoot.getType(itemStack);
        if (type == null) {
            return;
        }
        TextLayoutHelper textLayout = guiAlyzer.getTextLayout();
        textLayout.startPage(GuiAlyzer.COLUMN_0, GuiAlyzer.COLUMN_1, GuiAlyzer.COLUMN_2);
        textLayout.drawLine(Translator.translateToLocal("for.gui.active"), GuiAlyzer.COLUMN_1);
        textLayout.drawLine(Translator.translateToLocal("for.gui.inactive"), GuiAlyzer.COLUMN_2);
        textLayout.newLine();
        textLayout.newLine();
        {
            String customPrimaryTreeKey = "trees.custom.treealyzer." + type.getName() + "." + tree.getGenome().getPrimary().getUnlocalizedName().replace("trees.species.", "");
            String customSecondaryTreeKey = "trees.custom.treealyzer." + type.getName() + "." + tree.getGenome().getSecondary().getUnlocalizedName().replace("trees.species.", "");
            guiAlyzer.drawSpeciesRow(Translator.translateToLocal("for.gui.species"), tree, EnumTreeChromosome.SPECIES, GuiAlyzer.checkCustomName(customPrimaryTreeKey), GuiAlyzer.checkCustomName(customSecondaryTreeKey));
            textLayout.newLine();
        }
        guiAlyzer.drawChromosomeRow(Translator.translateToLocal("for.gui.saplings"), tree, EnumTreeChromosome.FERTILITY);
        textLayout.newLineCompressed();
        guiAlyzer.drawChromosomeRow(Translator.translateToLocal("for.gui.maturity"), tree, EnumTreeChromosome.MATURATION);
        textLayout.newLineCompressed();
        guiAlyzer.drawChromosomeRow(Translator.translateToLocal("for.gui.height"), tree, EnumTreeChromosome.HEIGHT);
        textLayout.newLineCompressed();
        IAlleleInteger activeGirth = (IAlleleInteger) tree.getGenome().getActiveAllele(EnumTreeChromosome.GIRTH);
        IAlleleInteger inactiveGirth = (IAlleleInteger) tree.getGenome().getInactiveAllele(EnumTreeChromosome.GIRTH);
        textLayout.drawLine(Translator.translateToLocal("for.gui.girth"), GuiAlyzer.COLUMN_0);
        guiAlyzer.drawLine(String.format("%sx%s", activeGirth.getValue(), activeGirth.getValue()), GuiAlyzer.COLUMN_1, tree, EnumTreeChromosome.GIRTH, false);
        guiAlyzer.drawLine(String.format("%sx%s", inactiveGirth.getValue(), inactiveGirth.getValue()), GuiAlyzer.COLUMN_2, tree, EnumTreeChromosome.GIRTH, true);
        textLayout.newLineCompressed();
        guiAlyzer.drawChromosomeRow(Translator.translateToLocal("for.gui.yield"), tree, EnumTreeChromosome.YIELD);
        textLayout.newLineCompressed();
        guiAlyzer.drawChromosomeRow(Translator.translateToLocal("for.gui.sappiness"), tree, EnumTreeChromosome.SAPPINESS);
        textLayout.newLineCompressed();
        guiAlyzer.drawChromosomeRow(Translator.translateToLocal("for.gui.effect"), tree, EnumTreeChromosome.EFFECT);
        textLayout.endPage();
    }
}
Also used : TextLayoutHelper(forestry.core.gui.TextLayoutHelper) IAlleleInteger(forestry.api.genetics.IAlleleInteger) EnumGermlingType(forestry.api.arboriculture.EnumGermlingType) ITree(forestry.api.arboriculture.ITree) GuiAlyzer(forestry.core.gui.GuiAlyzer) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with IAlleleInteger

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

the class AlleleHelper method init.

public void init() {
    if (ForestryAPI.enabledModules.contains(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.APICULTURE))) {
        createAlleles(EnumAllele.Fertility.class, EnumBeeChromosome.FERTILITY);
        createAlleles(EnumAllele.Flowering.class, EnumBeeChromosome.FLOWERING);
        createAlleles(EnumAllele.Territory.class, EnumBeeChromosome.TERRITORY);
    }
    if (ForestryAPI.enabledModules.contains(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.APICULTURE)) || ForestryAPI.enabledModules.contains(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.LEPIDOPTEROLOGY))) {
        createAlleles(EnumAllele.Speed.class, EnumBeeChromosome.SPEED, EnumButterflyChromosome.SPEED);
        createAlleles(EnumAllele.Lifespan.class, EnumBeeChromosome.LIFESPAN, EnumButterflyChromosome.LIFESPAN);
        createAlleles(EnumAllele.Tolerance.class, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumBeeChromosome.HUMIDITY_TOLERANCE, EnumButterflyChromosome.TEMPERATURE_TOLERANCE, EnumButterflyChromosome.HUMIDITY_TOLERANCE);
        createAlleles(EnumAllele.Flowers.class, EnumBeeChromosome.FLOWER_PROVIDER, EnumButterflyChromosome.FLOWER_PROVIDER);
    }
    if (ForestryAPI.enabledModules.contains(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.ARBORICULTURE))) {
        createAlleles(EnumAllele.Height.class, EnumTreeChromosome.HEIGHT);
        createAlleles(EnumAllele.Saplings.class, EnumTreeChromosome.FERTILITY);
        createAlleles(EnumAllele.Yield.class, EnumTreeChromosome.YIELD);
        createAlleles(EnumAllele.Fireproof.class, EnumTreeChromosome.FIREPROOF);
        createAlleles(EnumAllele.Maturation.class, EnumTreeChromosome.MATURATION);
        createAlleles(EnumAllele.Sappiness.class, EnumTreeChromosome.SAPPINESS);
    }
    if (ForestryAPI.enabledModules.contains(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.LEPIDOPTEROLOGY))) {
        createAlleles(EnumAllele.Size.class, EnumButterflyChromosome.SIZE);
    }
    Map<Integer, IAlleleInteger> integers = new HashMap<>();
    for (int i = 1; i <= 10; i++) {
        IAlleleInteger alleleInteger = new AlleleInteger(modId, "i", i + "d", i, true);
        AlleleManager.alleleRegistry.registerAllele(alleleInteger, EnumTreeChromosome.GIRTH, EnumButterflyChromosome.METABOLISM, EnumButterflyChromosome.FERTILITY);
        integers.put(i, alleleInteger);
    }
    alleleMaps.put(Integer.class, integers);
    Map<Boolean, IAlleleBoolean> booleans = new HashMap<>();
    booleans.put(true, new AlleleBoolean(modId, "bool", true, false));
    booleans.put(false, new AlleleBoolean(modId, "bool", false, false));
    for (IAlleleBoolean alleleBoolean : booleans.values()) {
        AlleleManager.alleleRegistry.registerAllele(alleleBoolean, EnumBeeChromosome.NEVER_SLEEPS, EnumBeeChromosome.TOLERATES_RAIN, EnumBeeChromosome.CAVE_DWELLING, EnumButterflyChromosome.NOCTURNAL, EnumButterflyChromosome.TOLERANT_FLYER, EnumButterflyChromosome.FIRE_RESIST);
    }
    alleleMaps.put(Boolean.class, booleans);
}
Also used : IAlleleInteger(forestry.api.genetics.IAlleleInteger) IAlleleBoolean(forestry.api.genetics.IAlleleBoolean) IAlleleInteger(forestry.api.genetics.IAlleleInteger) HashMap(java.util.HashMap) ResourceLocation(net.minecraft.util.ResourceLocation) IAlleleBoolean(forestry.api.genetics.IAlleleBoolean) IAlleleInteger(forestry.api.genetics.IAlleleInteger) IAlleleBoolean(forestry.api.genetics.IAlleleBoolean)

Example 3 with IAlleleInteger

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

the class FlutterlyzerPlugin method drawAnalyticsPage1.

@SideOnly(Side.CLIENT)
@Override
public void drawAnalyticsPage1(GuiScreen gui, ItemStack itemStack) {
    if (gui instanceof GuiAlyzer) {
        GuiAlyzer guiAlyzer = (GuiAlyzer) gui;
        IButterfly butterfly = ButterflyManager.butterflyRoot.getMember(itemStack);
        if (butterfly == null) {
            return;
        }
        TextLayoutHelper textLayout = guiAlyzer.getTextLayout();
        textLayout.startPage(GuiAlyzer.COLUMN_0, GuiAlyzer.COLUMN_1, GuiAlyzer.COLUMN_2);
        textLayout.drawLine(Translator.translateToLocal("for.gui.active"), GuiAlyzer.COLUMN_1);
        textLayout.drawLine(Translator.translateToLocal("for.gui.inactive"), GuiAlyzer.COLUMN_2);
        textLayout.newLine();
        textLayout.newLine();
        guiAlyzer.drawSpeciesRow(Translator.translateToLocal("for.gui.species"), butterfly, EnumButterflyChromosome.SPECIES, null, null);
        textLayout.newLine();
        guiAlyzer.drawRow(Translator.translateToLocal("for.gui.size"), butterfly.getGenome().getActiveAllele(EnumButterflyChromosome.SIZE).getAlleleName(), butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.SIZE).getAlleleName(), butterfly, EnumButterflyChromosome.SPEED);
        textLayout.newLine();
        guiAlyzer.drawRow(Translator.translateToLocal("for.gui.lifespan"), butterfly.getGenome().getActiveAllele(EnumButterflyChromosome.LIFESPAN).getAlleleName(), butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.LIFESPAN).getAlleleName(), butterfly, EnumButterflyChromosome.LIFESPAN);
        textLayout.newLine();
        guiAlyzer.drawRow(Translator.translateToLocal("for.gui.speed"), butterfly.getGenome().getActiveAllele(EnumButterflyChromosome.SPEED).getAlleleName(), butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.SPEED).getAlleleName(), butterfly, EnumButterflyChromosome.SPEED);
        textLayout.newLine();
        guiAlyzer.drawRow(Translator.translateToLocal("for.gui.metabolism"), GenericRatings.rateMetabolism(butterfly.getGenome().getMetabolism()), GenericRatings.rateMetabolism(((IAlleleInteger) butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.METABOLISM)).getValue()), butterfly, EnumButterflyChromosome.METABOLISM);
        textLayout.newLine();
        textLayout.drawLine(Translator.translateToLocal("for.gui.fertility"), GuiAlyzer.COLUMN_0);
        guiAlyzer.drawFertilityInfo(butterfly.getGenome().getFertility(), GuiAlyzer.COLUMN_1, guiAlyzer.getColorCoding(butterfly.getGenome().getActiveAllele(EnumButterflyChromosome.FERTILITY).isDominant()), 8);
        guiAlyzer.drawFertilityInfo(((IAlleleInteger) butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.FERTILITY)).getValue(), GuiAlyzer.COLUMN_2, guiAlyzer.getColorCoding(butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.FERTILITY).isDominant()), 8);
        textLayout.newLine();
        guiAlyzer.drawRow(Translator.translateToLocal("for.gui.flowers"), butterfly.getGenome().getFlowerProvider().getDescription(), ((IAlleleFlowers) butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.FLOWER_PROVIDER)).getProvider().getDescription(), butterfly, EnumButterflyChromosome.FLOWER_PROVIDER);
        textLayout.newLine();
        guiAlyzer.drawRow(Translator.translateToLocal("for.gui.effect"), butterfly.getGenome().getEffect().getAlleleName(), butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.EFFECT).getAlleleName(), butterfly, EnumButterflyChromosome.EFFECT);
        textLayout.newLine();
        textLayout.endPage();
    }
}
Also used : TextLayoutHelper(forestry.core.gui.TextLayoutHelper) IAlleleFlowers(forestry.api.genetics.IAlleleFlowers) IButterfly(forestry.api.lepidopterology.IButterfly) IAlleleInteger(forestry.api.genetics.IAlleleInteger) GuiAlyzer(forestry.core.gui.GuiAlyzer) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 4 with IAlleleInteger

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

the class BeeAlyzerPlugin method drawAnalyticsPage1.

@SideOnly(Side.CLIENT)
@Override
public void drawAnalyticsPage1(GuiScreen gui, ItemStack itemStack) {
    if (gui instanceof GuiAlyzer) {
        GuiAlyzer guiAlyzer = (GuiAlyzer) gui;
        IBee bee = BeeManager.beeRoot.getMember(itemStack);
        if (bee == null) {
            return;
        }
        EnumBeeType type = BeeManager.beeRoot.getType(itemStack);
        if (type == null) {
            return;
        }
        TextLayoutHelper textLayout = guiAlyzer.getTextLayout();
        textLayout.startPage(GuiAlyzer.COLUMN_0, GuiAlyzer.COLUMN_1, GuiAlyzer.COLUMN_2);
        textLayout.drawLine(Translator.translateToLocal("for.gui.active"), GuiAlyzer.COLUMN_1);
        textLayout.drawLine(Translator.translateToLocal("for.gui.inactive"), GuiAlyzer.COLUMN_2);
        textLayout.newLine();
        textLayout.newLine();
        {
            String customPrimaryBeeKey = "for.bees.custom.beealyzer." + type.getName() + "." + bee.getGenome().getPrimary().getUnlocalizedName().replace("bees.species.", "");
            String customSecondaryBeeKey = "for.bees.custom.beealyzer." + type.getName() + "." + bee.getGenome().getSecondary().getUnlocalizedName().replace("bees.species.", "");
            guiAlyzer.drawSpeciesRow(Translator.translateToLocal("for.gui.species"), bee, EnumBeeChromosome.SPECIES, GuiAlyzer.checkCustomName(customPrimaryBeeKey), GuiAlyzer.checkCustomName(customSecondaryBeeKey));
            textLayout.newLine();
        }
        guiAlyzer.drawChromosomeRow(Translator.translateToLocal("for.gui.lifespan"), bee, EnumBeeChromosome.LIFESPAN);
        textLayout.newLine();
        guiAlyzer.drawChromosomeRow(Translator.translateToLocal("for.gui.speed"), bee, EnumBeeChromosome.SPEED);
        textLayout.newLine();
        guiAlyzer.drawChromosomeRow(Translator.translateToLocal("for.gui.pollination"), bee, EnumBeeChromosome.FLOWERING);
        textLayout.newLine();
        guiAlyzer.drawChromosomeRow(Translator.translateToLocal("for.gui.flowers"), bee, EnumBeeChromosome.FLOWER_PROVIDER);
        textLayout.newLine();
        textLayout.drawLine(Translator.translateToLocal("for.gui.fertility"), GuiAlyzer.COLUMN_0);
        IAlleleInteger primaryFertility = (IAlleleInteger) bee.getGenome().getActiveAllele(EnumBeeChromosome.FERTILITY);
        IAlleleInteger secondaryFertility = (IAlleleInteger) bee.getGenome().getInactiveAllele(EnumBeeChromosome.FERTILITY);
        guiAlyzer.drawFertilityInfo(primaryFertility.getValue(), GuiAlyzer.COLUMN_1, guiAlyzer.getColorCoding(primaryFertility.isDominant()), 0);
        guiAlyzer.drawFertilityInfo(secondaryFertility.getValue(), GuiAlyzer.COLUMN_2, guiAlyzer.getColorCoding(secondaryFertility.isDominant()), 0);
        textLayout.newLine();
        guiAlyzer.drawChromosomeRow(Translator.translateToLocal("for.gui.area"), bee, EnumBeeChromosome.TERRITORY);
        textLayout.newLine();
        guiAlyzer.drawChromosomeRow(Translator.translateToLocal("for.gui.effect"), bee, EnumBeeChromosome.EFFECT);
        textLayout.newLine();
        textLayout.endPage();
    }
}
Also used : TextLayoutHelper(forestry.core.gui.TextLayoutHelper) IAlleleInteger(forestry.api.genetics.IAlleleInteger) IBee(forestry.api.apiculture.IBee) GuiAlyzer(forestry.core.gui.GuiAlyzer) EnumBeeType(forestry.api.apiculture.EnumBeeType) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 5 with IAlleleInteger

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

the class TreeDatabaseTab method createElements.

@Override
public void createElements(IGuiElementHelper elementHelper, ITree tree, ItemStack itemStack) {
    IAlleleTreeSpecies primarySpecies = tree.getGenome().getPrimary();
    boolean active = tab == EnumDatabaseTab.ACTIVE_SPECIES;
    IAlleleTreeSpecies species = active ? primarySpecies : tree.getGenome().getSecondary();
    int speciesColor = elementHelper.factory().getColorCoding(species.isDominant());
    elementHelper.addText(Translator.translateToLocal("for.gui.database.tab." + tab.name().toLowerCase() + ".name"), GuiElementAlignment.CENTER, 0xcfb53b);
    elementHelper.addAllele(Translator.translateToLocal("for.gui.species"), tree, EnumTreeChromosome.SPECIES, active);
    elementHelper.addAllele(Translator.translateToLocal("for.gui.saplings"), tree, EnumTreeChromosome.FERTILITY, active);
    elementHelper.addAllele(Translator.translateToLocal("for.gui.maturity"), tree, EnumTreeChromosome.MATURATION, active);
    elementHelper.addAllele(Translator.translateToLocal("for.gui.height"), tree, EnumTreeChromosome.HEIGHT, active);
    IAlleleInteger girth = (IAlleleInteger) (active ? tree.getGenome().getActiveAllele(EnumTreeChromosome.GIRTH) : tree.getGenome().getInactiveAllele(EnumTreeChromosome.GIRTH));
    elementHelper.addText(TextFormatting.UNDERLINE + Translator.translateToLocal("for.gui.girth"), GuiElementAlignment.CENTER);
    elementHelper.addText(String.format("%sx%s", girth.getValue(), girth.getValue()), GuiElementAlignment.CENTER, elementHelper.factory().getColorCoding(girth.isDominant()));
    elementHelper.addAllele(Translator.translateToLocal("for.gui.yield"), tree, EnumTreeChromosome.YIELD, active);
    elementHelper.addAllele(Translator.translateToLocal("for.gui.sappiness"), tree, EnumTreeChromosome.SAPPINESS, active);
    elementHelper.addAllele(Translator.translateToLocal("for.gui.effect"), tree, EnumTreeChromosome.EFFECT, active);
    elementHelper.addText(TextFormatting.UNDERLINE + Translator.translateToLocal("for.gui.native"), GuiElementAlignment.CENTER);
    elementHelper.addText(Translator.translateToLocal("for.gui." + tree.getGenome().getPrimary().getPlantType().toString().toLowerCase(Locale.ENGLISH)), GuiElementAlignment.CENTER, speciesColor);
    elementHelper.addText(TextFormatting.UNDERLINE + Translator.translateToLocal("for.gui.supports"), GuiElementAlignment.CENTER);
    List<IFruitFamily> families = new ArrayList<>(tree.getGenome().getPrimary().getSuitableFruit());
    for (IFruitFamily fruitFamily : families) {
        elementHelper.addText(fruitFamily.getName(), GuiElementAlignment.CENTER, speciesColor);
    }
    IAlleleFruit fruit = (IAlleleFruit) (active ? tree.getGenome().getActiveAllele(EnumTreeChromosome.FRUITS) : tree.getGenome().getInactiveAllele(EnumTreeChromosome.FRUITS));
    int colorCoding = elementHelper.factory().getColorCoding(tree.getGenome().getActiveAllele(EnumTreeChromosome.FRUITS).isDominant());
    elementHelper.addText(TextFormatting.UNDERLINE + Translator.translateToLocal("for.gui.fruits"), GuiElementAlignment.CENTER);
    String strike = "";
    if (!species.getSuitableFruit().contains(fruit.getProvider().getFamily()) && fruit != AlleleFruits.fruitNone) {
        strike = TextFormatting.STRIKETHROUGH.toString();
    }
    elementHelper.addText(strike + fruit.getProvider().getDescription(), GuiElementAlignment.CENTER, colorCoding);
    IFruitFamily family = fruit.getProvider().getFamily();
    if (family != null && !family.getUID().equals(EnumFruitFamily.NONE.getUID())) {
        elementHelper.addText(TextFormatting.UNDERLINE + Translator.translateToLocal("for.gui.family"), GuiElementAlignment.CENTER);
        elementHelper.addText(family.getName(), GuiElementAlignment.CENTER, colorCoding);
    }
}
Also used : IAlleleTreeSpecies(forestry.api.arboriculture.IAlleleTreeSpecies) IAlleleInteger(forestry.api.genetics.IAlleleInteger) IFruitFamily(forestry.api.genetics.IFruitFamily) ArrayList(java.util.ArrayList) IAlleleFruit(forestry.api.arboriculture.IAlleleFruit)

Aggregations

IAlleleInteger (forestry.api.genetics.IAlleleInteger)8 GuiAlyzer (forestry.core.gui.GuiAlyzer)3 TextLayoutHelper (forestry.core.gui.TextLayoutHelper)3 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)3 EnumBeeType (forestry.api.apiculture.EnumBeeType)2 IAlleleTolerance (forestry.api.genetics.IAlleleTolerance)2 AlleleBoolean (forestry.core.genetics.alleles.AlleleBoolean)2 IBee (forestry.api.apiculture.IBee)1 EnumGermlingType (forestry.api.arboriculture.EnumGermlingType)1 IAlleleFruit (forestry.api.arboriculture.IAlleleFruit)1 IAlleleTreeSpecies (forestry.api.arboriculture.IAlleleTreeSpecies)1 ITree (forestry.api.arboriculture.ITree)1 IAlleleBoolean (forestry.api.genetics.IAlleleBoolean)1 IAlleleFlowers (forestry.api.genetics.IAlleleFlowers)1 IAlleleSpecies (forestry.api.genetics.IAlleleSpecies)1 IFruitFamily (forestry.api.genetics.IFruitFamily)1 IAlleleButterflySpecies (forestry.api.lepidopterology.IAlleleButterflySpecies)1 IButterfly (forestry.api.lepidopterology.IButterfly)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1