Search in sources :

Example 26 with ISpeciesRoot

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

the class ItemSerum method getSubItems.

@Override
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) {
    if (this.isInCreativeTab(tab)) {
        for (ISpeciesRoot root : AlleleManager.alleleRegistry.getSpeciesRoot().values()) {
            Map<IChromosomeType, List<IAllele>> chromosomeMap = Binnie.GENETICS.getChromosomeMap(root);
            if (chromosomeMap != null) {
                for (Map.Entry<IChromosomeType, List<IAllele>> entry : chromosomeMap.entrySet()) {
                    IChromosomeType chromosome = entry.getKey();
                    for (final IAllele allele : entry.getValue()) {
                        Gene gene = Gene.create(allele, chromosome, root);
                        IGeneItem geneItem = new GeneItem(gene);
                        ItemStack stack = new ItemStack(this);
                        geneItem.writeToItem(stack);
                        items.add(stack);
                    }
                }
            }
        }
    }
}
Also used : IAllele(forestry.api.genetics.IAllele) ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IGeneItem(binnie.genetics.genetics.IGeneItem) Gene(binnie.core.genetics.Gene) IGene(binnie.core.api.genetics.IGene) GeneItem(binnie.genetics.genetics.GeneItem) IGeneItem(binnie.genetics.genetics.IGeneItem) List(java.util.List) NonNullList(net.minecraft.util.NonNullList) IChromosomeType(forestry.api.genetics.IChromosomeType) ItemStack(net.minecraft.item.ItemStack) Map(java.util.Map)

Example 27 with ISpeciesRoot

use of forestry.api.genetics.ISpeciesRoot 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 28 with ISpeciesRoot

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

the class SequencerRecipeMaker method create.

public static List<SequencerRecipeWrapper> create() {
    List<SequencerRecipeWrapper> recipes = new ArrayList<>();
    Collection<ISpeciesRoot> roots = AlleleManager.alleleRegistry.getSpeciesRoot().values();
    for (ISpeciesRoot root : roots) {
        IChromosomeType speciesChromosomeType = root.getSpeciesChromosomeType();
        IAllele[] defaultTemplate = root.getDefaultTemplate();
        IAllele species = defaultTemplate[speciesChromosomeType.ordinal()];
        ItemStack filledSequence = ItemSequence.create(new Gene(species, speciesChromosomeType, root), false);
        recipes.add(new SequencerRecipeWrapper(filledSequence));
        filledSequence = filledSequence.copy();
        filledSequence.setItemDamage(0);
        recipes.add(new SequencerRecipeWrapper(filledSequence));
    }
    return recipes;
}
Also used : IAllele(forestry.api.genetics.IAllele) ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) Gene(binnie.core.genetics.Gene) ArrayList(java.util.ArrayList) IChromosomeType(forestry.api.genetics.IChromosomeType) ItemStack(net.minecraft.item.ItemStack)

Example 29 with ISpeciesRoot

use of forestry.api.genetics.ISpeciesRoot 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 30 with ISpeciesRoot

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

the class EntityButterfly method readEntityFromNBT.

@Override
public void readEntityFromNBT(NBTTagCompound nbttagcompound) {
    super.readEntityFromNBT(nbttagcompound);
    IButterfly butterfly = null;
    if (nbttagcompound.hasKey("BTFLY")) {
        butterfly = new Butterfly((NBTTagCompound) nbttagcompound.getTag("BTFLY"));
    }
    setIndividual(butterfly);
    if (nbttagcompound.hasKey("PLN")) {
        NBTTagCompound pollenNBT = nbttagcompound.getCompoundTag("PLN");
        ISpeciesRoot root;
        if (pollenNBT.hasKey("Root")) {
            root = AlleleManager.alleleRegistry.getSpeciesRoot(pollenNBT.getString("Root"));
        } else {
            root = TreeManager.treeRoot;
        }
        pollen = root.getMember(pollenNBT);
    }
    EnumButterflyState state = EnumButterflyState.VALUES[nbttagcompound.getByte("STATE")];
    setState(state);
    exhaustion = nbttagcompound.getInteger("EXH");
    BlockPos home = new BlockPos(nbttagcompound.getInteger("homeX"), nbttagcompound.getInteger("homeY"), nbttagcompound.getInteger("homeZ"));
    setHomePosAndDistance(home, ModuleLepidopterology.maxDistance);
}
Also used : ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IButterfly(forestry.api.lepidopterology.IButterfly) IEntityButterfly(forestry.api.lepidopterology.IEntityButterfly) IButterfly(forestry.api.lepidopterology.IButterfly) Butterfly(forestry.lepidopterology.genetics.Butterfly) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) BlockPos(net.minecraft.util.math.BlockPos)

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