Search in sources :

Example 1 with IItemAnalysable

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

the class ManagerGenetics method analyse.

public static ItemStack analyse(ItemStack stack, World world, GameProfile username) {
    if (!stack.isEmpty()) {
        ItemStack conv = Binnie.GENETICS.getConversionStack(stack).copy();
        if (!conv.isEmpty()) {
            conv.setCount(stack.getCount());
            stack = conv;
        }
        ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(stack);
        if (root != null) {
            final IIndividual ind = root.getMember(stack);
            ind.analyze();
            IBreedingTracker breedingTracker = ind.getGenome().getSpeciesRoot().getBreedingTracker(world, username);
            breedingTracker.registerBirth(ind);
            final NBTTagCompound nbttagcompound = new NBTTagCompound();
            ind.writeToNBT(nbttagcompound);
            stack.setTagCompound(nbttagcompound);
            return stack;
        }
        if (stack.getItem() instanceof IItemAnalysable) {
            return ((IItemAnalysable) stack.getItem()).analyse(stack);
        }
    }
    return stack;
}
Also used : ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IIndividual(forestry.api.genetics.IIndividual) IBreedingTracker(forestry.api.genetics.IBreedingTracker) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IItemAnalysable(binnie.core.api.genetics.IItemAnalysable) ItemStack(net.minecraft.item.ItemStack)

Aggregations

IItemAnalysable (binnie.core.api.genetics.IItemAnalysable)1 IBreedingTracker (forestry.api.genetics.IBreedingTracker)1 IIndividual (forestry.api.genetics.IIndividual)1 ISpeciesRoot (forestry.api.genetics.ISpeciesRoot)1 ItemStack (net.minecraft.item.ItemStack)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1