use of forestry.api.genetics.ISpeciesRoot in project ForestryMC by ForestryMC.
the class BreedingTracker method registerSpecies.
@Override
public void registerSpecies(IAlleleSpecies species) {
if (!discoveredSpecies.contains(species.getUID())) {
discoveredSpecies.add(species.getUID());
ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(speciesRootUID());
ForestryEvent event = new ForestryEvent.SpeciesDiscovered(speciesRoot, username, species, this);
MinecraftForge.EVENT_BUS.post(event);
syncToPlayer(Collections.singleton(species.getUID()), emptyStringCollection, emptyStringCollection);
}
}
use of forestry.api.genetics.ISpeciesRoot in project ForestryMC by ForestryMC.
the class BreedingTracker method registerMutation.
@Override
public void registerMutation(IMutation mutation) {
String mutationString = getMutationString(mutation);
if (!discoveredMutations.contains(mutationString)) {
discoveredMutations.add(mutationString);
markDirty();
ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(speciesRootUID());
ForestryEvent event = new ForestryEvent.MutationDiscovered(speciesRoot, username, mutation, this);
MinecraftForge.EVENT_BUS.post(event);
syncToPlayer(emptyStringCollection, Collections.singleton(mutationString), emptyStringCollection);
}
}
use of forestry.api.genetics.ISpeciesRoot 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;
}
use of forestry.api.genetics.ISpeciesRoot in project ForestryMC by ForestryMC.
the class GeneticsUtil method getPollen.
/**
* Gets pollen from a location. Does not affect the pollen source.
*/
@Nullable
public static IIndividual getPollen(World world, final BlockPos pos) {
if (!world.isBlockLoaded(pos)) {
return null;
}
ICheckPollinatable checkPollinatable = TileUtil.getTile(world, pos, ICheckPollinatable.class);
if (checkPollinatable != null) {
return checkPollinatable.getPollen();
}
IBlockState blockState = world.getBlockState(pos);
for (ISpeciesRoot root : AlleleManager.alleleRegistry.getSpeciesRoot().values()) {
IIndividual individual = root.translateMember(blockState);
if (individual != null) {
return individual;
}
}
return null;
}
use of forestry.api.genetics.ISpeciesRoot in project ForestryMC by ForestryMC.
the class ApiaristTracker method registerPickup.
@Override
public void registerPickup(IIndividual individual) {
ISpeciesRoot speciesRoot = individual.getGenome().getPrimary().getRoot();
if (!speciesRoot.getUID().equals(speciesRootUID())) {
return;
}
if (!individual.isPureBred(EnumBeeChromosome.SPECIES)) {
return;
}
if (!speciesRoot.getCombinations(individual.getGenome().getPrimary()).isEmpty()) {
return;
}
registerSpecies(individual.getGenome().getPrimary());
}
Aggregations