use of binnie.genetics.api.IItemSerum in project Binnie by ForestryMC.
the class Engineering method isGeneAcceptor.
public static boolean isGeneAcceptor(ItemStack stack) {
if (stack.isEmpty()) {
return false;
}
Item item = stack.getItem();
if (item instanceof IItemSerum) {
return ((IItemSerum) item).getCharges(stack) == 0;
}
int metadata = stack.getMetadata();
return item == Genetics.items().getItemGenetics() && (metadata == GeneticsItems.EMPTY_SERUM.ordinal() || metadata == GeneticsItems.EMPTY_GENOME.ordinal());
}
use of binnie.genetics.api.IItemSerum in project Binnie by ForestryMC.
the class Engineering method addGene.
public static ItemStack addGene(ItemStack stack, IGene gene) {
Item item = stack.getItem();
int metadata = stack.getMetadata();
if (item instanceof IItemSerum) {
((IItemSerum) item).addGene(stack, gene);
}
if (item == Genetics.items().getItemGenetics()) {
if (metadata == GeneticsItems.EMPTY_SERUM.ordinal()) {
return ItemSerum.create(gene);
} else if (metadata == GeneticsItems.EMPTY_GENOME.ordinal()) {
return ItemSerumArray.create(gene);
}
}
return stack;
}
use of binnie.genetics.api.IItemSerum in project Binnie by ForestryMC.
the class SplicerLogic method getGenesToUse.
public static int getGenesToUse(ItemStack serum, ItemStack target) {
if (serum.isEmpty() || target.isEmpty()) {
return 1;
}
final IIndividual ind = AlleleManager.alleleRegistry.getIndividual(target);
final IGene[] genes = ((IItemSerum) serum.getItem()).getGenes(serum);
if (ind.getGenome().getSpeciesRoot() != ((IItemSerum) serum.getItem()).getSpeciesRoot(serum)) {
return 1;
}
int i = 0;
for (final IGene gene : genes) {
if (ind.getGenome().getActiveAllele(gene.getChromosome()) != gene.getAllele() || ind.getGenome().getInactiveAllele(gene.getChromosome()) != gene.getAllele()) {
++i;
}
}
return (i < 1) ? 1 : i;
}
use of binnie.genetics.api.IItemSerum in project Binnie by ForestryMC.
the class SplicerLogic method onFinishTask.
@Override
protected void onFinishTask() {
super.onFinishTask();
final ItemStack serum = this.getUtil().getStack(Splicer.SLOT_SERUM_VIAL);
Preconditions.checkState(!serum.isEmpty());
final ItemStack target = this.getUtil().getStack(Splicer.SLOT_TARGET);
Preconditions.checkState(!target.isEmpty());
final IGene[] genes = ((IItemSerum) serum.getItem()).getGenes(serum);
for (final IGene gene : genes) {
Splicer.setGene(gene, target, true, true);
}
this.getUtil().damageItem(serum, Splicer.SLOT_SERUM_VIAL, 1);
}
use of binnie.genetics.api.IItemSerum in project Binnie by ForestryMC.
the class InoculatorLogic method applySerum.
public static ItemStack applySerum(ItemStack target, ItemStack serum) {
ItemStack applied = target.copy();
final IGene[] genes = ((IItemSerum) serum.getItem()).getGenes(serum);
for (final IGene gene : genes) {
Splicer.setGene(gene, applied, true, true);
}
return applied;
}
Aggregations