Search in sources :

Example 46 with IIndividual

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

the class ControlIndividualDisplay method setSpecies.

public void setSpecies(final IAlleleSpecies species, EnumDiscoveryState state) {
    final ISpeciesRoot speciesRoot = Binnie.GENETICS.getSpeciesRoot(species);
    final IBreedingSystem system = Binnie.GENETICS.getSystem(speciesRoot);
    final IAllele[] template = system.getSpeciesRoot().getTemplate(species);
    final IIndividual ind = system.getSpeciesRoot().templateAsIndividual(template);
    super.setItemStack(system.getSpeciesRoot().getMemberStack(ind, system.getDefaultType()));
    this.species = species;
    final GameProfile username = Window.get(this).getUsername();
    if (state == EnumDiscoveryState.UNDETERMINED) {
        state = (system.isSpeciesDiscovered(species, Window.get(this).getWorld(), username) ? EnumDiscoveryState.DISCOVERED : EnumDiscoveryState.UNDISCOVERED);
    }
    if (Window.get(this) instanceof WindowAbstractDatabase && ((WindowAbstractDatabase) Window.get(this)).isMaster()) {
        state = EnumDiscoveryState.SHOW;
    }
    this.discovered = state;
    this.addAttribute(Attribute.MOUSE_OVER);
}
Also used : IAllele(forestry.api.genetics.IAllele) ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IIndividual(forestry.api.genetics.IIndividual) GameProfile(com.mojang.authlib.GameProfile) IBreedingSystem(binnie.core.api.genetics.IBreedingSystem)

Example 47 with IIndividual

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

the class ManagerGenetics method analyse.

public static ItemStack analyse(ItemStack stack, World world, GameProfile username) {
    if (!stack.isEmpty()) {
        ItemStack conv = Binnie.GENETICS.getConversionStack(stack).copy();
        if (!conv.isEmpty()) {
            conv.setCount(stack.getCount());
            stack = conv;
        }
        ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(stack);
        if (root != null) {
            final IIndividual ind = root.getMember(stack);
            ind.analyze();
            IBreedingTracker breedingTracker = ind.getGenome().getSpeciesRoot().getBreedingTracker(world, username);
            breedingTracker.registerBirth(ind);
            final NBTTagCompound nbttagcompound = new NBTTagCompound();
            ind.writeToNBT(nbttagcompound);
            stack.setTagCompound(nbttagcompound);
            return stack;
        }
        if (stack.getItem() instanceof IItemAnalysable) {
            return ((IItemAnalysable) stack.getItem()).analyse(stack);
        }
    }
    return stack;
}
Also used : ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IIndividual(forestry.api.genetics.IIndividual) IBreedingTracker(forestry.api.genetics.IBreedingTracker) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IItemAnalysable(binnie.core.api.genetics.IItemAnalysable) ItemStack(net.minecraft.item.ItemStack)

Example 48 with IIndividual

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

the class InoculatorRecipeMaker method create.

public static List<InoculatorRecipeWrapper> create() {
    List<InoculatorRecipeWrapper> recipes = new ArrayList<>();
    for (IBreedingSystem system : Binnie.GENETICS.getActiveSystems()) {
        ISpeciesRoot root = system.getSpeciesRoot();
        IChromosomeType speciesChromosomeType = root.getSpeciesChromosomeType();
        IAllele[] defaultTemplate = root.getDefaultTemplate();
        IIndividual individual = root.templateAsIndividual(defaultTemplate);
        for (ISpeciesType speciesType : system.getActiveTypes()) {
            if (system.isDNAManipulable(speciesType)) {
                ItemStack memberStack = root.getMemberStack(individual, speciesType);
                memberStack.setItemDamage(OreDictionary.WILDCARD_VALUE);
                IAllele species = defaultTemplate[speciesChromosomeType.ordinal()];
                ItemStack serum = ItemSerum.create(new Gene(species, speciesChromosomeType, root));
                // set fully charged
                serum.setItemDamage(0);
                recipes.add(new InoculatorRecipeWrapper(serum, memberStack));
                recipes.add(new SplicerRecipeWrapper(serum, memberStack));
                ItemStack serumArray = ItemSerumArray.create(new Gene(species, speciesChromosomeType, root));
                // set fully charged
                serumArray.setItemDamage(0);
                for (IChromosomeType chromosomeType : root.getKaryotype()) {
                    if (chromosomeType != speciesChromosomeType) {
                        IAllele allele = defaultTemplate[chromosomeType.ordinal()];
                        Engineering.addGene(serumArray, new Gene(allele, chromosomeType, root));
                    }
                }
                recipes.add(new InoculatorRecipeWrapper(serumArray, memberStack));
                recipes.add(new SplicerRecipeWrapper(serumArray, memberStack));
            }
        }
    }
    return recipes;
}
Also used : IIndividual(forestry.api.genetics.IIndividual) ISpeciesType(forestry.api.genetics.ISpeciesType) ArrayList(java.util.ArrayList) IBreedingSystem(binnie.core.api.genetics.IBreedingSystem) IAllele(forestry.api.genetics.IAllele) ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) Gene(binnie.core.genetics.Gene) IChromosomeType(forestry.api.genetics.IChromosomeType) ItemStack(net.minecraft.item.ItemStack)

Example 49 with IIndividual

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

the class IsolatorRecipeMaker method create.

public static List<IsolatorRecipeWrapper> create() {
    List<IsolatorRecipeWrapper> recipes = new ArrayList<>();
    Collection<ISpeciesRoot> roots = AlleleManager.alleleRegistry.getSpeciesRoot().values();
    for (ISpeciesRoot root : roots) {
        ISpeciesType[] speciesTypes = root.getIconType().getClass().getEnumConstants();
        IChromosomeType speciesChromosomeType = root.getSpeciesChromosomeType();
        IAllele[] defaultTemplate = root.getDefaultTemplate();
        IIndividual individual = root.templateAsIndividual(defaultTemplate);
        for (ISpeciesType speciesType : speciesTypes) {
            ItemStack memberStack = root.getMemberStack(individual, speciesType);
            memberStack.setItemDamage(OreDictionary.WILDCARD_VALUE);
            IAllele species = defaultTemplate[speciesChromosomeType.ordinal()];
            ItemStack filledSequence = ItemSequence.create(new Gene(species, speciesChromosomeType, root), false);
            IsolatorRecipeWrapper recipeWrapper = new IsolatorRecipeWrapper(memberStack, filledSequence);
            recipes.add(recipeWrapper);
        }
    }
    return recipes;
}
Also used : IIndividual(forestry.api.genetics.IIndividual) ISpeciesType(forestry.api.genetics.ISpeciesType) ArrayList(java.util.ArrayList) IAllele(forestry.api.genetics.IAllele) ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) Gene(binnie.core.genetics.Gene) IChromosomeType(forestry.api.genetics.IChromosomeType) 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