Search in sources :

Example 1 with IItemSerum

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());
}
Also used : Item(net.minecraft.item.Item) IItemSerum(binnie.genetics.api.IItemSerum)

Example 2 with IItemSerum

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;
}
Also used : Item(net.minecraft.item.Item) IItemSerum(binnie.genetics.api.IItemSerum)

Example 3 with IItemSerum

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;
}
Also used : IIndividual(forestry.api.genetics.IIndividual) IGene(binnie.core.api.genetics.IGene) IItemSerum(binnie.genetics.api.IItemSerum)

Example 4 with IItemSerum

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);
}
Also used : IGene(binnie.core.api.genetics.IGene) IItemSerum(binnie.genetics.api.IItemSerum) ItemStack(net.minecraft.item.ItemStack)

Example 5 with IItemSerum

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;
}
Also used : IGene(binnie.core.api.genetics.IGene) IItemSerum(binnie.genetics.api.IItemSerum) ItemStack(net.minecraft.item.ItemStack)

Aggregations

IItemSerum (binnie.genetics.api.IItemSerum)5 IGene (binnie.core.api.genetics.IGene)3 Item (net.minecraft.item.Item)2 ItemStack (net.minecraft.item.ItemStack)2 IIndividual (forestry.api.genetics.IIndividual)1