Search in sources :

Example 31 with ISpeciesRoot

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);
    }
}
Also used : ForestryEvent(forestry.api.core.ForestryEvent) ISpeciesRoot(forestry.api.genetics.ISpeciesRoot)

Example 32 with ISpeciesRoot

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);
    }
}
Also used : ForestryEvent(forestry.api.core.ForestryEvent) ISpeciesRoot(forestry.api.genetics.ISpeciesRoot)

Example 33 with ISpeciesRoot

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;
}
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 34 with ISpeciesRoot

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;
}
Also used : ICheckPollinatable(forestry.api.genetics.ICheckPollinatable) ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IBlockState(net.minecraft.block.state.IBlockState) IIndividual(forestry.api.genetics.IIndividual) Nullable(javax.annotation.Nullable)

Example 35 with ISpeciesRoot

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());
}
Also used : ISpeciesRoot(forestry.api.genetics.ISpeciesRoot)

Aggregations

ISpeciesRoot (forestry.api.genetics.ISpeciesRoot)49 IIndividual (forestry.api.genetics.IIndividual)30 ItemStack (net.minecraft.item.ItemStack)20 IAllele (forestry.api.genetics.IAllele)17 IChromosomeType (forestry.api.genetics.IChromosomeType)11 Gene (binnie.core.genetics.Gene)10 IBreedingTracker (forestry.api.genetics.IBreedingTracker)7 IGenome (forestry.api.genetics.IGenome)7 ArrayList (java.util.ArrayList)7 IBreedingSystem (binnie.core.api.genetics.IBreedingSystem)6 ISpeciesType (forestry.api.genetics.ISpeciesType)6 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)6 IGene (binnie.core.api.genetics.IGene)4 IAlleleSpecies (forestry.api.genetics.IAlleleSpecies)4 IFilterData (forestry.api.genetics.IFilterData)3 List (java.util.List)3 Random (java.util.Random)3 Nullable (javax.annotation.Nullable)3 IGeneItem (binnie.genetics.genetics.IGeneItem)2 ForestryEvent (forestry.api.core.ForestryEvent)2