Search in sources :

Example 6 with IFruitProvider

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

the class BlockDefaultLeaves method getLeafDrop.

@Override
protected void getLeafDrop(NonNullList<ItemStack> drops, World world, @Nullable GameProfile playerProfile, BlockPos pos, float saplingModifier, int fortune) {
    ITree tree = getTree(world, pos);
    if (tree == null) {
        return;
    }
    // Add saplings
    List<ITree> saplings = tree.getSaplings(world, playerProfile, pos, saplingModifier);
    for (ITree sapling : saplings) {
        if (sapling != null) {
            drops.add(TreeManager.treeRoot.getMemberStack(sapling, EnumGermlingType.SAPLING));
        }
    }
    // Add fruits
    ITreeGenome genome = tree.getGenome();
    IFruitProvider fruitProvider = genome.getFruitProvider();
    if (fruitProvider.isFruitLeaf(genome, world, pos)) {
        NonNullList<ItemStack> produceStacks = tree.produceStacks(world, pos, Integer.MAX_VALUE);
        drops.addAll(produceStacks);
    }
}
Also used : ITree(forestry.api.arboriculture.ITree) ItemStack(net.minecraft.item.ItemStack) ITreeGenome(forestry.api.arboriculture.ITreeGenome) IFruitProvider(forestry.api.arboriculture.IFruitProvider)

Example 7 with IFruitProvider

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

the class BlockDefaultLeaves method colorMultiplier.

@Override
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockState state, @Nullable IBlockAccess worldIn, @Nullable BlockPos pos, int tintIndex) {
    TreeDefinition treeDefinition = getTreeDefinition(state);
    if (treeDefinition == null) {
        treeDefinition = TreeDefinition.Oak;
    }
    ITreeGenome genome = treeDefinition.getGenome();
    if (tintIndex == BlockAbstractLeaves.FRUIT_COLOR_INDEX) {
        IFruitProvider fruitProvider = genome.getFruitProvider();
        return fruitProvider.getDecorativeColor();
    }
    ILeafSpriteProvider spriteProvider = genome.getPrimary().getLeafSpriteProvider();
    return spriteProvider.getColor(false);
}
Also used : ILeafSpriteProvider(forestry.api.arboriculture.ILeafSpriteProvider) TreeDefinition(forestry.arboriculture.genetics.TreeDefinition) ITreeGenome(forestry.api.arboriculture.ITreeGenome) IFruitProvider(forestry.api.arboriculture.IFruitProvider) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 8 with IFruitProvider

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

the class TreeRoot method getFruitProvidersForFruitFamily.

@Override
public Collection<IFruitProvider> getFruitProvidersForFruitFamily(IFruitFamily fruitFamily) {
    if (providersForFamilies.isEmpty()) {
        @SuppressWarnings("unchecked") Collection<IAlleleFruit> fruitAlleles = (Collection<IAlleleFruit>) (Object) AlleleManager.alleleRegistry.getRegisteredAlleles(EnumTreeChromosome.FRUITS);
        for (IAlleleFruit alleleFruit : fruitAlleles) {
            IFruitProvider fruitProvider = alleleFruit.getProvider();
            Collection<IFruitProvider> fruitProviders = providersForFamilies.computeIfAbsent(fruitProvider.getFamily(), k -> new ArrayList<>());
            fruitProviders.add(fruitProvider);
        }
    }
    return providersForFamilies.computeIfAbsent(fruitFamily, k -> new ArrayList<>());
}
Also used : Collection(java.util.Collection) IAlleleFruit(forestry.api.arboriculture.IAlleleFruit) IFruitProvider(forestry.api.arboriculture.IFruitProvider)

Example 9 with IFruitProvider

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

the class TileLeaves method setTree.

@Override
public void setTree(ITree tree) {
    super.setTree(tree);
    ITreeGenome genome = tree.getGenome();
    species = genome.getPrimary();
    if (tree.canBearFruit()) {
        IFruitProvider fruitProvider = genome.getFruitProvider();
        isFruitLeaf = fruitProvider.isFruitLeaf(genome, world, getPos());
        if (isFruitLeaf) {
            // Hardcoded because vanilla oak trees don't show fruits.
            if (species == TreeDefinition.Oak.getGenome().getPrimary() && fruitProvider == AlleleFruits.fruitApple.getProvider()) {
                fruitSprite = null;
            } else {
                fruitSprite = fruitProvider.getSprite(genome, world, getPos(), getRipeningTime());
            }
            ripeningPeriod = (short) tree.getGenome().getFruitProvider().getRipeningPeriod();
        }
    } else {
        isFruitLeaf = false;
        fruitSprite = null;
    }
    markDirty();
}
Also used : ITreeGenome(forestry.api.arboriculture.ITreeGenome) IFruitProvider(forestry.api.arboriculture.IFruitProvider)

Example 10 with IFruitProvider

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

the class AlleleTreeSpecies method getResearchSuitability.

@Override
public float getResearchSuitability(ItemStack itemstack) {
    if (itemstack.isEmpty()) {
        return 0f;
    }
    List<IFruitFamily> suitableFruit = getSuitableFruit();
    for (IFruitFamily fruitFamily : suitableFruit) {
        Collection<IFruitProvider> fruitProviders = TreeManager.treeRoot.getFruitProvidersForFruitFamily(fruitFamily);
        for (IFruitProvider fruitProvider : fruitProviders) {
            Map<ItemStack, Float> products = fruitProvider.getProducts();
            for (ItemStack stack : products.keySet()) {
                if (stack.isItemEqual(itemstack)) {
                    return 1.0f;
                }
            }
            Map<ItemStack, Float> specialtyChances = fruitProvider.getSpecialty();
            for (ItemStack stack : specialtyChances.keySet()) {
                if (stack.isItemEqual(itemstack)) {
                    return 1.0f;
                }
            }
        }
    }
    return super.getResearchSuitability(itemstack);
}
Also used : IFruitFamily(forestry.api.genetics.IFruitFamily) ItemStack(net.minecraft.item.ItemStack) IFruitProvider(forestry.api.arboriculture.IFruitProvider)

Aggregations

IFruitProvider (forestry.api.arboriculture.IFruitProvider)15 ITreeGenome (forestry.api.arboriculture.ITreeGenome)11 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)6 ITree (forestry.api.arboriculture.ITree)4 ItemStack (net.minecraft.item.ItemStack)4 ETTreeDefinition (binnie.extratrees.genetics.ETTreeDefinition)3 ILeafSpriteProvider (forestry.api.arboriculture.ILeafSpriteProvider)3 IFruitFamily (forestry.api.genetics.IFruitFamily)3 TreeDefinition (forestry.arboriculture.genetics.TreeDefinition)3 IBreedingSystem (binnie.core.api.genetics.IBreedingSystem)1 ControlText (binnie.core.gui.controls.ControlText)1 Control (binnie.core.gui.controls.core.Control)1 ControlScrollableContent (binnie.core.gui.controls.scroll.ControlScrollableContent)1 Area (binnie.core.gui.geometry.Area)1 Point (binnie.core.gui.geometry.Point)1 ControlItemDisplay (binnie.core.gui.minecraft.control.ControlItemDisplay)1 BlockETDecorativeLeaves (binnie.extratrees.blocks.BlockETDecorativeLeaves)1 IAlleleFruit (forestry.api.arboriculture.IAlleleFruit)1 IAlleleTreeSpecies (forestry.api.arboriculture.IAlleleTreeSpecies)1 IAllele (forestry.api.genetics.IAllele)1