Search in sources :

Example 6 with IIndividual

use of forestry.api.genetics.IIndividual in project ForestryMC by ForestryMC.

the class PickupHandlerCore method onItemPickup.

@Override
public boolean onItemPickup(EntityPlayer entityPlayer, EntityItem entityitem) {
    ItemStack itemstack = entityitem.getItem();
    if (itemstack.isEmpty()) {
        return false;
    }
    ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(itemstack);
    if (root != null) {
        IIndividual individual = root.getMember(itemstack);
        if (individual != null) {
            IBreedingTracker tracker = root.getBreedingTracker(entityitem.world, entityPlayer.getGameProfile());
            tracker.registerPickup(individual);
        }
    }
    return false;
}
Also used : ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IIndividual(forestry.api.genetics.IIndividual) IBreedingTracker(forestry.api.genetics.IBreedingTracker) ItemStack(net.minecraft.item.ItemStack)

Example 7 with IIndividual

use of forestry.api.genetics.IIndividual in project ForestryMC by ForestryMC.

the class ItemInventoryAlyzer method canSlotAccept.

@Override
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
    if (slotIndex == SLOT_ENERGY) {
        return isAlyzingFuel(itemStack);
    }
    // only allow one slot to be used at a time
    if (hasSpecimen() && getStackInSlot(slotIndex).isEmpty()) {
        return false;
    }
    itemStack = GeneticsUtil.convertToGeneticEquivalent(itemStack);
    ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(itemStack);
    if (speciesRoot == null) {
        return false;
    }
    if (slotIndex == SLOT_SPECIMEN) {
        return true;
    }
    IIndividual individual = speciesRoot.getMember(itemStack);
    return individual != null && individual.isAnalyzed();
}
Also used : ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IIndividual(forestry.api.genetics.IIndividual)

Example 8 with IIndividual

use of forestry.api.genetics.IIndividual in project ForestryMC by ForestryMC.

the class TileGeneticFilter method getValidDirections.

public Collection<EnumFacing> getValidDirections(ItemStack itemStack, EnumFacing from) {
    ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(itemStack);
    IIndividual individual = null;
    ISpeciesType type = null;
    if (root != null) {
        individual = root.getMember(itemStack);
        type = root.getType(itemStack);
    }
    IFilterData filterData = new FilterData(root, individual, type);
    List<EnumFacing> validFacings = new LinkedList<>();
    for (EnumFacing facing : EnumFacing.VALUES) {
        if (facing == from) {
            continue;
        }
        if (isValidFacing(facing, itemStack, filterData)) {
            validFacings.add(facing);
        }
    }
    return validFacings;
}
Also used : ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IIndividual(forestry.api.genetics.IIndividual) IFilterData(forestry.api.genetics.IFilterData) ISpeciesType(forestry.api.genetics.ISpeciesType) EnumFacing(net.minecraft.util.EnumFacing) IFilterData(forestry.api.genetics.IFilterData) FilterData(forestry.sorting.FilterData) LinkedList(java.util.LinkedList)

Example 9 with IIndividual

use of forestry.api.genetics.IIndividual in project ForestryMC by ForestryMC.

the class SpeciesWidget method createEntries.

private static ImmutableMap<IAlleleSpecies, ItemStack> createEntries() {
    ImmutableMap.Builder<IAlleleSpecies, ItemStack> entries = ImmutableMap.builder();
    for (ISpeciesRoot root : AlleleManager.alleleRegistry.getSpeciesRoot().values()) {
        for (IIndividual individual : root.getIndividualTemplates()) {
            IAlleleSpecies species = individual.getGenome().getPrimary();
            ItemStack itemStack = root.getMemberStack(root.templateAsIndividual(root.getTemplate(species)), root.getIconType());
            entries.put(species, itemStack);
        }
    }
    return entries.build();
}
Also used : ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IIndividual(forestry.api.genetics.IIndividual) IAlleleSpecies(forestry.api.genetics.IAlleleSpecies) ItemStack(net.minecraft.item.ItemStack) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 10 with IIndividual

use of forestry.api.genetics.IIndividual in project ForestryMC by ForestryMC.

the class FilterLogic method isValid.

@Override
public boolean isValid(ItemStack itemStack, EnumFacing facing) {
    ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(itemStack);
    IIndividual individual = null;
    ISpeciesType type = null;
    if (root != null) {
        individual = root.getMember(itemStack);
        type = root.getType(itemStack);
    }
    return isValid(facing, itemStack, new FilterData(root, individual, type));
}
Also used : ISpeciesRoot(forestry.api.genetics.ISpeciesRoot) IIndividual(forestry.api.genetics.IIndividual) ISpeciesType(forestry.api.genetics.ISpeciesType) IFilterData(forestry.api.genetics.IFilterData)

Aggregations

IIndividual (forestry.api.genetics.IIndividual)49 ISpeciesRoot (forestry.api.genetics.ISpeciesRoot)30 ItemStack (net.minecraft.item.ItemStack)29 IAllele (forestry.api.genetics.IAllele)14 IGenome (forestry.api.genetics.IGenome)10 ISpeciesType (forestry.api.genetics.ISpeciesType)8 Nullable (javax.annotation.Nullable)7 Gene (binnie.core.genetics.Gene)6 IChromosomeType (forestry.api.genetics.IChromosomeType)6 ArrayList (java.util.ArrayList)6 IBreedingSystem (binnie.core.api.genetics.IBreedingSystem)5 Random (java.util.Random)5 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)5 IGene (binnie.core.api.genetics.IGene)4 IAlleleSpecies (forestry.api.genetics.IAlleleSpecies)4 IBreedingTracker (forestry.api.genetics.IBreedingTracker)3 IFilterData (forestry.api.genetics.IFilterData)3 Tolerance (binnie.core.genetics.Tolerance)2 Point (binnie.core.gui.geometry.Point)2 ControlItemDisplay (binnie.core.gui.minecraft.control.ControlItemDisplay)2