Search in sources :

Example 1 with EnumGermlingType

use of forestry.api.arboriculture.EnumGermlingType 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 EnumGermlingType

use of forestry.api.arboriculture.EnumGermlingType in project ForestryMC by ForestryMC.

the class TreeRoot method getMemberStack.

@Override
public ItemStack getMemberStack(IIndividual tree, ISpeciesType type) {
    Preconditions.checkArgument(tree instanceof ITree, "individual is not a tree");
    Preconditions.checkArgument(type instanceof EnumGermlingType, "type is not an EnumGermlingType");
    ItemRegistryArboriculture items = ModuleArboriculture.getItems();
    Item germlingItem;
    switch((EnumGermlingType) type) {
        case SAPLING:
            germlingItem = items.sapling;
            break;
        case POLLEN:
            germlingItem = items.pollenFertile;
            break;
        default:
            throw new RuntimeException("Cannot instantiate a tree of type " + type);
    }
    NBTTagCompound nbttagcompound = new NBTTagCompound();
    tree.writeToNBT(nbttagcompound);
    ItemStack treeStack = new ItemStack(germlingItem);
    treeStack.setTagCompound(nbttagcompound);
    return treeStack;
}
Also used : Item(net.minecraft.item.Item) ItemRegistryArboriculture(forestry.arboriculture.items.ItemRegistryArboriculture) EnumGermlingType(forestry.api.arboriculture.EnumGermlingType) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ITree(forestry.api.arboriculture.ITree) ItemStack(net.minecraft.item.ItemStack)

Aggregations

EnumGermlingType (forestry.api.arboriculture.EnumGermlingType)2 ITree (forestry.api.arboriculture.ITree)2 IAlleleInteger (forestry.api.genetics.IAlleleInteger)1 ItemRegistryArboriculture (forestry.arboriculture.items.ItemRegistryArboriculture)1 GuiAlyzer (forestry.core.gui.GuiAlyzer)1 TextLayoutHelper (forestry.core.gui.TextLayoutHelper)1 Item (net.minecraft.item.Item)1 ItemStack (net.minecraft.item.ItemStack)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1