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