Search in sources :

Example 16 with Gene

use of binnie.core.genetics.Gene in project Binnie by ForestryMC.

the class GeneArrayItem method readFromNBT.

@Override
public void readFromNBT(@Nullable NBTTagCompound nbt) {
    genes.clear();
    if (nbt == null) {
        return;
    }
    NBTTagList list = nbt.getTagList(GENES_NBT, 10);
    for (int i = 0; i < list.tagCount(); ++i) {
        Gene gene = Gene.create(list.getCompoundTagAt(i));
        genes.add(gene);
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) Gene(binnie.core.genetics.Gene) IGene(binnie.core.api.genetics.IGene)

Example 17 with Gene

use of binnie.core.genetics.Gene in project Binnie by ForestryMC.

the class GeneTracker method readFromNBT.

@Override
public void readFromNBT(NBTTagCompound nbt) {
    for (ISpeciesRoot root : AlleleManager.alleleRegistry.getSpeciesRoot().values()) {
        if (!nbt.hasKey(root.getUID())) {
            continue;
        }
        NBTTagCompound nbtRoot = nbt.getCompoundTag(root.getUID());
        for (IChromosomeType chromo : root.getKaryotype()) {
            if (!nbtRoot.hasKey(String.valueOf(chromo.ordinal()))) {
                continue;
            }
            NBTTagList nbtChromo = nbtRoot.getTagList(String.valueOf(chromo.ordinal()), 8);
            for (int i = 0; i < nbtChromo.tagCount(); ++i) {
                String uid = nbtChromo.getStringTagAt(i);
                IAllele allele = AlleleManager.alleleRegistry.getAllele(uid);
                if (allele == null) {
                    continue;
                }
                Gene gene = new Gene(allele, chromo, root);
                if (!discoveredGenes.contains(gene)) {
                    discoveredGenes.add(gene);
                }
            }
        }
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) IAllele(forestry.api.genetics.IAllele) ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) Gene(binnie.core.genetics.Gene) IGene(binnie.core.api.genetics.IGene) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IChromosomeType(forestry.api.genetics.IChromosomeType) NBTTagString(net.minecraft.nbt.NBTTagString)

Example 18 with Gene

use of binnie.core.genetics.Gene in project Binnie by ForestryMC.

the class SequencerItem method create.

@Nullable
public static SequencerItem create(ItemStack itemStack) {
    NBTTagCompound nbt = itemStack.getTagCompound();
    if (nbt != null && nbt.hasKey("gene", Constants.NBT.TAG_COMPOUND) && nbt.hasKey("seq", Constants.NBT.TAG_BYTE) && nbt.hasKey("ana")) {
        NBTTagCompound geneNbt = nbt.getCompoundTag("gene");
        Gene gene = Gene.create(geneNbt);
        SequencerItem sequencerItem = new SequencerItem(gene);
        sequencerItem.sequenced = nbt.getByte("seq");
        sequencerItem.analysed = nbt.getBoolean("ana");
        return sequencerItem;
    }
    return null;
}
Also used : Gene(binnie.core.genetics.Gene) IGene(binnie.core.api.genetics.IGene) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Nullable(javax.annotation.Nullable)

Aggregations

Gene (binnie.core.genetics.Gene)18 IAllele (forestry.api.genetics.IAllele)11 IChromosomeType (forestry.api.genetics.IChromosomeType)11 ISpeciesRoot (forestry.api.genetics.ISpeciesRoot)10 ItemStack (net.minecraft.item.ItemStack)8 IGene (binnie.core.api.genetics.IGene)7 IIndividual (forestry.api.genetics.IIndividual)6 ArrayList (java.util.ArrayList)6 List (java.util.List)4 IBreedingSystem (binnie.core.api.genetics.IBreedingSystem)3 Map (java.util.Map)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 BreedingSystem (binnie.core.genetics.BreedingSystem)2 ControlText (binnie.core.gui.controls.ControlText)2 Point (binnie.core.gui.geometry.Point)2 ControlPlayerInventory (binnie.core.gui.minecraft.control.ControlPlayerInventory)2 Panel (binnie.core.gui.window.Panel)2 GeneTracker (binnie.genetics.genetics.GeneTracker)2 IGeneItem (binnie.genetics.genetics.IGeneItem)2 IGenome (forestry.api.genetics.IGenome)2