Search in sources :

Example 1 with IIndividual

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

the class GeneticsUtil method convertToGeneticEquivalent.

public static ItemStack convertToGeneticEquivalent(ItemStack foreign) {
    if (AlleleManager.alleleRegistry.getSpeciesRoot(foreign) == null) {
        IIndividual individual = getGeneticEquivalent(foreign);
        if (individual != null) {
            ItemStack equivalent = TreeManager.treeRoot.getMemberStack(individual, EnumGermlingType.SAPLING);
            equivalent.setCount(foreign.getCount());
            return equivalent;
        }
    }
    return foreign;
}
Also used : IIndividual(forestry.api.genetics.IIndividual) ItemStack(net.minecraft.item.ItemStack)

Example 2 with IIndividual

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

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

the class DatabaseScreenLogic method onItemChange.

public ScreenState onItemChange(ItemStack itemStack) {
    ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(itemStack);
    // No individual, abort
    if (speciesRoot == null) {
        return ScreenState.NO_INDIVIDUAL;
    }
    IIndividual individual = speciesRoot.getMember(itemStack);
    // Check if a individual is selected and analyzed
    if (individual == null) {
        this.individual = null;
        this.itemStack = ItemStack.EMPTY;
        return ScreenState.NO_INDIVIDUAL;
    } else if (!individual.isAnalyzed()) {
        this.individual = null;
        this.itemStack = ItemStack.EMPTY;
        return ScreenState.NOT_ANALYZED;
    }
    this.individual = individual;
    this.itemStack = itemStack;
    if (speciesRoot != this.speciesRoot) {
        IDatabaseTab[] tabs = getTabs(speciesRoot);
        if (tabs == null) {
            this.tabs = new IDatabaseTab[4];
            return ScreenState.NO_PLUGIN;
        }
        this.tabs = tabs;
        // Select the first tab
        onTabChange(tabs[0]);
    } else {
        // Update the gui
        onTabChange(selectedTab);
    }
    this.speciesRoot = speciesRoot;
    return ScreenState.SUCCESS;
}
Also used : ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IIndividual(forestry.api.genetics.IIndividual) IDatabaseTab(forestry.api.genetics.IDatabaseTab)

Example 4 with IIndividual

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

the class EntityButterfly method dropFewItems.

/* LOOT */
@Override
protected void dropFewItems(boolean playerKill, int lootLevel) {
    for (ItemStack stack : contained.getLootDrop(this, playerKill, lootLevel)) {
        ItemStackUtil.dropItemStackAsEntity(stack, world, posX, posY, posZ);
    }
    // Drop pollen if any
    IIndividual pollen = getPollen();
    if (pollen != null) {
        ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(pollen);
        ItemStack pollenStack = root.getMemberStack(pollen, EnumGermlingType.POLLEN);
        ItemStackUtil.dropItemStackAsEntity(pollenStack, world, posX, posY, posZ);
    }
}
Also used : ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IIndividual(forestry.api.genetics.IIndividual) ItemStack(net.minecraft.item.ItemStack)

Example 5 with IIndividual

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

the class ItemButterflyGE method addCreativeItems.

public void addCreativeItems(NonNullList<ItemStack> subItems, boolean hideSecrets) {
    if (type == EnumFlutterType.COCOON) {
        for (int age = 0; age < 3; age++) {
            for (IIndividual individual : ButterflyManager.butterflyRoot.getIndividualTemplates()) {
                // Don't show secret butterflies unless ordered to.
                if (hideSecrets && individual.isSecret() && !Config.isDebug) {
                    continue;
                }
                ItemStack butterfly = ButterflyManager.butterflyRoot.getMemberStack(individual, type);
                ItemButterflyGE.setAge(butterfly, age);
                subItems.add(butterfly);
            }
        }
    } else {
        for (IIndividual individual : ButterflyManager.butterflyRoot.getIndividualTemplates()) {
            // Don't show secret butterflies unless ordered to.
            if (hideSecrets && individual.isSecret() && !Config.isDebug) {
                continue;
            }
            subItems.add(ButterflyManager.butterflyRoot.getMemberStack(individual, type));
        }
    }
}
Also used : IIndividual(forestry.api.genetics.IIndividual) ItemStack(net.minecraft.item.ItemStack)

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