Search in sources :

Example 6 with IGene

use of binnie.core.api.genetics.IGene in project Binnie by ForestryMC.

the class InoculatorLogic method isValidSerum.

@Nullable
public ErrorState isValidSerum() {
    final ItemStack serum = this.getUtil().getStack(Inoculator.SLOT_SERUM_VIAL);
    final ItemStack target = this.getUtil().getStack(Inoculator.SLOT_TARGET);
    final IGene[] genes = Engineering.getGenes(serum);
    if (genes.length == 0) {
        return new ErrorState(GeneticsErrorCode.INVALID_SERUM_NO);
    }
    if (!genes[0].getSpeciesRoot().isMember(target)) {
        return new ErrorState(GeneticsErrorCode.INVALID_SERUM_MISMATCH);
    }
    final IIndividual individual = genes[0].getSpeciesRoot().getMember(target);
    if (individual != null) {
        final IGenome genome = individual.getGenome();
        for (final IGene gene : genes) {
            final IAllele a = genome.getActiveAllele(gene.getChromosome());
            final IAllele b = genome.getInactiveAllele(gene.getChromosome());
            if (!a.getUID().equals(gene.getAllele().getUID()) || !b.getUID().equals(gene.getAllele().getUID())) {
                return null;
            }
        }
    }
    return new ErrorState(GeneticsErrorCode.DEFUNCT_SERUM);
}
Also used : IAllele(forestry.api.genetics.IAllele) IGenome(forestry.api.genetics.IGenome) IIndividual(forestry.api.genetics.IIndividual) ErrorState(binnie.core.machines.errors.ErrorState) IGene(binnie.core.api.genetics.IGene) ItemStack(net.minecraft.item.ItemStack) Nullable(javax.annotation.Nullable)

Example 7 with IGene

use of binnie.core.api.genetics.IGene in project Binnie by ForestryMC.

the class ItemSerum method getGenes.

@Override
public IGene[] getGenes(ItemStack stack) {
    GeneItem geneItem = this.getGeneItem(stack);
    Preconditions.checkNotNull(geneItem, "Cannot get genes from itemStack that is not a valid serum.");
    return new IGene[] { geneItem.getGene() };
}
Also used : GeneItem(binnie.genetics.genetics.GeneItem) IGeneItem(binnie.genetics.genetics.IGeneItem) IGene(binnie.core.api.genetics.IGene)

Example 8 with IGene

use of binnie.core.api.genetics.IGene in project Binnie by ForestryMC.

the class ControlGene method getTooltip.

@Override
public void getTooltip(final Tooltip tooltip, ITooltipFlag tooltipFlag) {
    IBreedingSystem system = Binnie.GENETICS.getSystem(this.gene.getSpeciesRoot());
    final String cName = system.getChromosomeName(this.gene.getChromosome());
    tooltip.add(cName + ": " + this.gene.getName());
    if (this.isMouseOver() && this.canFill(Window.get(this).getHeldItemStack())) {
        tooltip.add("Left click to assign gene");
        final IGene existingGene = Engineering.getGene(Window.get(this).getHeldItemStack(), this.gene.getChromosome().ordinal());
        if (existingGene == null) {
            return;
        }
        final String dName = system.getChromosomeName(this.gene.getChromosome());
        tooltip.add("Will replace " + dName + ": " + existingGene.getName());
    }
}
Also used : IGene(binnie.core.api.genetics.IGene) IBreedingSystem(binnie.core.api.genetics.IBreedingSystem)

Example 9 with IGene

use of binnie.core.api.genetics.IGene in project Binnie by ForestryMC.

the class GeneArrayItem method writeToNBT.

@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
    if (genes.isEmpty()) {
        return nbt;
    }
    NBTTagList list = new NBTTagList();
    for (IGene gene : genes) {
        list.appendTag(gene.getNBTTagCompound());
    }
    nbt.setTag(GENES_NBT, list);
    return nbt;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) IGene(binnie.core.api.genetics.IGene)

Example 10 with IGene

use of binnie.core.api.genetics.IGene in project Binnie by ForestryMC.

the class GeneTracker method writeToNBT.

@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
    for (ISpeciesRoot root : AlleleManager.alleleRegistry.getSpeciesRoot().values()) {
        NBTTagCompound nbtRoot = new NBTTagCompound();
        for (IChromosomeType chromo : root.getKaryotype()) {
            NBTTagList nbtChromo = new NBTTagList();
            for (IGene gene : discoveredGenes) {
                if (gene.getSpeciesRoot() == root && gene.getChromosome() == chromo) {
                    nbtChromo.appendTag(new NBTTagString(gene.getAllele().getUID()));
                }
            }
            nbtRoot.setTag(String.valueOf(chromo.ordinal()), nbtChromo);
        }
        nbt.setTag(root.getUID(), nbtRoot);
    }
    return nbt;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IGene(binnie.core.api.genetics.IGene) NBTTagString(net.minecraft.nbt.NBTTagString) IChromosomeType(forestry.api.genetics.IChromosomeType)

Aggregations

IGene (binnie.core.api.genetics.IGene)10 ItemStack (net.minecraft.item.ItemStack)4 IItemSerum (binnie.genetics.api.IItemSerum)3 IIndividual (forestry.api.genetics.IIndividual)3 IBreedingSystem (binnie.core.api.genetics.IBreedingSystem)2 ErrorState (binnie.core.machines.errors.ErrorState)2 IAllele (forestry.api.genetics.IAllele)2 Nullable (javax.annotation.Nullable)2 NBTTagList (net.minecraft.nbt.NBTTagList)2 GeneItem (binnie.genetics.genetics.GeneItem)1 IGeneItem (binnie.genetics.genetics.IGeneItem)1 IChromosomeType (forestry.api.genetics.IChromosomeType)1 IGenome (forestry.api.genetics.IGenome)1 ISpeciesRoot (forestry.api.genetics.ISpeciesRoot)1 ArrayList (java.util.ArrayList)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 NBTTagString (net.minecraft.nbt.NBTTagString)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1