Search in sources :

Example 6 with ITree

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

the class TileTreeContainer method writeData.

@Override
public void writeData(PacketBufferForestry data) {
    String speciesUID = "";
    ITree tree = getTree();
    if (tree != null) {
        speciesUID = tree.getIdent();
    }
    data.writeString(speciesUID);
}
Also used : ITree(forestry.api.arboriculture.ITree)

Example 7 with ITree

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

the class TileTreeContainer method readData.

@Override
public void readData(PacketBufferForestry data) throws IOException {
    String speciesUID = data.readString();
    ITree tree = getTree(speciesUID);
    setTree(tree);
}
Also used : ITree(forestry.api.arboriculture.ITree)

Example 8 with ITree

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

the class TreeRoot method tryConvertToPollinatable.

@Override
@Nullable
public IPollinatable tryConvertToPollinatable(@Nullable GameProfile owner, World world, BlockPos pos, IIndividual individual) {
    Preconditions.checkArgument(individual instanceof ITree, "pollen must be an instance of ITree");
    ITree pollen = (ITree) individual;
    if (pollen.setLeaves(world, owner, pos)) {
        return TileUtil.getTile(world, pos, IPollinatable.class);
    } else {
        return null;
    }
}
Also used : ITree(forestry.api.arboriculture.ITree) Nullable(javax.annotation.Nullable)

Example 9 with ITree

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

the class ItemGermlingGE method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
    RayTraceResult raytraceresult = this.rayTrace(worldIn, playerIn, true);
    ItemStack itemStack = playerIn.getHeldItem(handIn);
    if (raytraceresult != null && raytraceresult.typeOfHit == RayTraceResult.Type.BLOCK) {
        BlockPos pos = raytraceresult.getBlockPos();
        ITree tree = TreeManager.treeRoot.getMember(itemStack);
        if (tree != null) {
            if (type == EnumGermlingType.SAPLING) {
                return onItemRightClickSapling(itemStack, worldIn, playerIn, pos, tree);
            } else if (type == EnumGermlingType.POLLEN) {
                return onItemRightClickPollen(itemStack, worldIn, playerIn, pos, tree);
            }
        }
    }
    return new ActionResult<>(EnumActionResult.PASS, itemStack);
}
Also used : ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) RayTraceResult(net.minecraft.util.math.RayTraceResult) BlockPos(net.minecraft.util.math.BlockPos) ITree(forestry.api.arboriculture.ITree) ItemStack(net.minecraft.item.ItemStack)

Example 10 with ITree

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

Aggregations

ITree (forestry.api.arboriculture.ITree)33 ItemStack (net.minecraft.item.ItemStack)9 ITreeGenome (forestry.api.arboriculture.ITreeGenome)8 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)5 IAlleleTreeSpecies (forestry.api.arboriculture.IAlleleTreeSpecies)4 IFruitProvider (forestry.api.arboriculture.IFruitProvider)4 IAllele (forestry.api.genetics.IAllele)4 EnumGermlingType (forestry.api.arboriculture.EnumGermlingType)3 IAlleleFruit (forestry.api.arboriculture.IAlleleFruit)3 TileSapling (forestry.arboriculture.tiles.TileSapling)3 GuiAlyzer (forestry.core.gui.GuiAlyzer)3 TextLayoutHelper (forestry.core.gui.TextLayoutHelper)3 TileLeaves (forestry.arboriculture.tiles.TileLeaves)2 ArrayList (java.util.ArrayList)2 Nullable (javax.annotation.Nullable)2 IBlockState (net.minecraft.block.state.IBlockState)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 BlockPos (net.minecraft.util.math.BlockPos)2 Biome (net.minecraft.world.biome.Biome)2 WorldGenerator (net.minecraft.world.gen.feature.WorldGenerator)2