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);
}
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() };
}
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());
}
}
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;
}
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;
}
Aggregations