Search in sources :

Example 31 with IIndividual

use of forestry.api.genetics.IIndividual in project Binnie by ForestryMC.

the class ItemSerumArray method getSubItems.

@Override
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) {
    if (this.isInCreativeTab(tab)) {
        for (ISpeciesRoot root : AlleleManager.alleleRegistry.getSpeciesRoot().values()) {
            for (IIndividual template : root.getIndividualTemplates()) {
                if (template.getGenome().getPrimary().isSecret()) {
                    continue;
                }
                IGeneItem geneItem = new GeneArrayItem();
                for (IChromosomeType type : root.getKaryotype()) {
                    IChromosome chromosome = template.getGenome().getChromosomes()[type.ordinal()];
                    if (chromosome != null) {
                        IAllele active = chromosome.getActiveAllele();
                        geneItem.addGene(new Gene(active, type, root));
                    }
                }
                ItemStack array = new ItemStack(this);
                geneItem.writeToItem(array);
                items.add(array);
            }
        }
    }
}
Also used : IAllele(forestry.api.genetics.IAllele) ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IGeneItem(binnie.genetics.genetics.IGeneItem) IIndividual(forestry.api.genetics.IIndividual) Gene(binnie.core.genetics.Gene) IGene(binnie.core.api.genetics.IGene) IChromosome(forestry.api.genetics.IChromosome) IChromosomeType(forestry.api.genetics.IChromosomeType) ItemStack(net.minecraft.item.ItemStack) GeneArrayItem(binnie.genetics.genetics.GeneArrayItem)

Example 32 with IIndividual

use of forestry.api.genetics.IIndividual in project Binnie by ForestryMC.

the class ToleranceSystem method canAlter.

public boolean canAlter(final ItemStack stack, final ItemStack acclim) {
    final IIndividual member = AlleleManager.alleleRegistry.getIndividual(stack);
    final IGenome genome = member.getGenome();
    final IAlleleTolerance tolAllele = (IAlleleTolerance) genome.getActiveAllele(this.chromosomeType);
    final Tolerance tol = Tolerance.get(tolAllele.getValue());
    final float effect = this.type.getEffect(acclim);
    return (effect > 0.0f && tol.getBounds()[1] < 5) || (effect < 0.0f && tol.getBounds()[0] > -5);
}
Also used : IGenome(forestry.api.genetics.IGenome) IAlleleTolerance(forestry.api.genetics.IAlleleTolerance) IIndividual(forestry.api.genetics.IIndividual) Tolerance(binnie.core.genetics.Tolerance) IAlleleTolerance(forestry.api.genetics.IAlleleTolerance)

Example 33 with IIndividual

use of forestry.api.genetics.IIndividual in project EnderIO by SleepyTrousers.

the class SpeciesItemFilter method setItem.

@Nonnull
private ItemStack setItem(int slot, @Nonnull ItemStack itemStack) {
    if (slot < 0 || slot >= items.size()) {
        return ItemStack.EMPTY;
    }
    ItemStack prevStack = items.get(slot);
    if (!prevStack.isEmpty()) {
        this.primarySpeciesUids[slot] = null;
        this.secondarySpeciesUids[slot] = null;
    }
    items.set(slot, itemStack);
    ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(itemStack);
    if (speciesRoot != null) {
        IIndividual member = speciesRoot.getMember(itemStack);
        if (member != null) {
            IGenome genome = member.getGenome();
            primarySpeciesUids[slot] = genome.getPrimary().getUID();
            secondarySpeciesUids[slot] = genome.getSecondary().getUID();
        }
    }
    return prevStack;
}
Also used : IGenome(forestry.api.genetics.IGenome) ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IIndividual(forestry.api.genetics.IIndividual) ItemStack(net.minecraft.item.ItemStack) Nonnull(javax.annotation.Nonnull)

Example 34 with IIndividual

use of forestry.api.genetics.IIndividual 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 35 with IIndividual

use of forestry.api.genetics.IIndividual 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)

Aggregations

IIndividual (forestry.api.genetics.IIndividual)49 ISpeciesRoot (forestry.api.genetics.ISpeciesRoot)30 ItemStack (net.minecraft.item.ItemStack)29 IAllele (forestry.api.genetics.IAllele)14 IGenome (forestry.api.genetics.IGenome)10 ISpeciesType (forestry.api.genetics.ISpeciesType)8 Nullable (javax.annotation.Nullable)7 Gene (binnie.core.genetics.Gene)6 IChromosomeType (forestry.api.genetics.IChromosomeType)6 ArrayList (java.util.ArrayList)6 IBreedingSystem (binnie.core.api.genetics.IBreedingSystem)5 Random (java.util.Random)5 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)5 IGene (binnie.core.api.genetics.IGene)4 IAlleleSpecies (forestry.api.genetics.IAlleleSpecies)4 IBreedingTracker (forestry.api.genetics.IBreedingTracker)3 IFilterData (forestry.api.genetics.IFilterData)3 Tolerance (binnie.core.genetics.Tolerance)2 Point (binnie.core.gui.geometry.Point)2 ControlItemDisplay (binnie.core.gui.minecraft.control.ControlItemDisplay)2