Search in sources :

Example 1 with ISpeciesRootPollinatable

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

the class GeneticsUtil method getOrCreatePollinatable.

/**
 * Returns an IPollinatable that can be mated. This will convert vanilla leaves to Forestry leaves.
 */
@Nullable
public static IPollinatable getOrCreatePollinatable(@Nullable GameProfile owner, World world, final BlockPos pos, boolean convertVanilla) {
    IPollinatable pollinatable = TileUtil.getTile(world, pos, IPollinatable.class);
    if (pollinatable == null && convertVanilla) {
        final IIndividual pollen = getPollen(world, pos);
        if (pollen != null) {
            ISpeciesRoot root = pollen.getGenome().getSpeciesRoot();
            if (root instanceof ISpeciesRootPollinatable) {
                ISpeciesRootPollinatable rootPollinatable = (ISpeciesRootPollinatable) root;
                pollinatable = rootPollinatable.tryConvertToPollinatable(owner, world, pos, pollen);
            }
        }
    }
    return pollinatable;
}
Also used : ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IIndividual(forestry.api.genetics.IIndividual) ISpeciesRootPollinatable(forestry.api.genetics.ISpeciesRootPollinatable) IPollinatable(forestry.api.genetics.IPollinatable) Nullable(javax.annotation.Nullable)

Example 2 with ISpeciesRootPollinatable

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

the class GeneticsUtil method getCheckPollinatable.

/**
 * Returns an ICheckPollinatable that can be checked but not mated.
 * Used to check for pollination traits without altering the world by changing vanilla leaves to forestry ones.
 */
@Nullable
public static ICheckPollinatable getCheckPollinatable(World world, final BlockPos pos) {
    IPollinatable tile = TileUtil.getTile(world, pos, IPollinatable.class);
    if (tile != null) {
        return tile;
    }
    IIndividual pollen = getPollen(world, pos);
    if (pollen != null) {
        ISpeciesRoot root = pollen.getGenome().getSpeciesRoot();
        if (root instanceof ISpeciesRootPollinatable) {
            return ((ISpeciesRootPollinatable) root).createPollinatable(pollen);
        }
    }
    return null;
}
Also used : ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IIndividual(forestry.api.genetics.IIndividual) ISpeciesRootPollinatable(forestry.api.genetics.ISpeciesRootPollinatable) IPollinatable(forestry.api.genetics.IPollinatable) Nullable(javax.annotation.Nullable)

Aggregations

IIndividual (forestry.api.genetics.IIndividual)2 IPollinatable (forestry.api.genetics.IPollinatable)2 ISpeciesRoot (forestry.api.genetics.ISpeciesRoot)2 ISpeciesRootPollinatable (forestry.api.genetics.ISpeciesRootPollinatable)2 Nullable (javax.annotation.Nullable)2