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;
}
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;
}
Aggregations