use of forestry.api.genetics.IIndividual in project Binnie by ForestryMC.
the class ItemSerumArray method getSubItems.
@Override
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) {
if (this.isInCreativeTab(tab)) {
for (ISpeciesRoot root : AlleleManager.alleleRegistry.getSpeciesRoot().values()) {
for (IIndividual template : root.getIndividualTemplates()) {
if (template.getGenome().getPrimary().isSecret()) {
continue;
}
IGeneItem geneItem = new GeneArrayItem();
for (IChromosomeType type : root.getKaryotype()) {
IChromosome chromosome = template.getGenome().getChromosomes()[type.ordinal()];
if (chromosome != null) {
IAllele active = chromosome.getActiveAllele();
geneItem.addGene(new Gene(active, type, root));
}
}
ItemStack array = new ItemStack(this);
geneItem.writeToItem(array);
items.add(array);
}
}
}
}
use of forestry.api.genetics.IIndividual in project Binnie by ForestryMC.
the class ToleranceSystem method canAlter.
public boolean canAlter(final ItemStack stack, final ItemStack acclim) {
final IIndividual member = AlleleManager.alleleRegistry.getIndividual(stack);
final IGenome genome = member.getGenome();
final IAlleleTolerance tolAllele = (IAlleleTolerance) genome.getActiveAllele(this.chromosomeType);
final Tolerance tol = Tolerance.get(tolAllele.getValue());
final float effect = this.type.getEffect(acclim);
return (effect > 0.0f && tol.getBounds()[1] < 5) || (effect < 0.0f && tol.getBounds()[0] > -5);
}
use of forestry.api.genetics.IIndividual in project EnderIO by SleepyTrousers.
the class SpeciesItemFilter method setItem.
@Nonnull
private ItemStack setItem(int slot, @Nonnull ItemStack itemStack) {
if (slot < 0 || slot >= items.size()) {
return ItemStack.EMPTY;
}
ItemStack prevStack = items.get(slot);
if (!prevStack.isEmpty()) {
this.primarySpeciesUids[slot] = null;
this.secondarySpeciesUids[slot] = null;
}
items.set(slot, itemStack);
ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(itemStack);
if (speciesRoot != null) {
IIndividual member = speciesRoot.getMember(itemStack);
if (member != null) {
IGenome genome = member.getGenome();
primarySpeciesUids[slot] = genome.getPrimary().getUID();
secondarySpeciesUids[slot] = genome.getSecondary().getUID();
}
}
return prevStack;
}
use of forestry.api.genetics.IIndividual in project ForestryMC by ForestryMC.
the class GeneticsUtil method getCheckPollinatable.
/**
* Returns an ICheckPollinatable that can be checked but not mated.
* Used to check for pollination traits without altering the world by changing vanilla leaves to forestry ones.
*/
@Nullable
public static ICheckPollinatable getCheckPollinatable(World world, final BlockPos pos) {
IPollinatable tile = TileUtil.getTile(world, pos, IPollinatable.class);
if (tile != null) {
return tile;
}
IIndividual pollen = getPollen(world, pos);
if (pollen != null) {
ISpeciesRoot root = pollen.getGenome().getSpeciesRoot();
if (root instanceof ISpeciesRootPollinatable) {
return ((ISpeciesRootPollinatable) root).createPollinatable(pollen);
}
}
return null;
}
use of forestry.api.genetics.IIndividual in project ForestryMC by ForestryMC.
the class GeneticsUtil method getPollen.
/**
* Gets pollen from a location. Does not affect the pollen source.
*/
@Nullable
public static IIndividual getPollen(World world, final BlockPos pos) {
if (!world.isBlockLoaded(pos)) {
return null;
}
ICheckPollinatable checkPollinatable = TileUtil.getTile(world, pos, ICheckPollinatable.class);
if (checkPollinatable != null) {
return checkPollinatable.getPollen();
}
IBlockState blockState = world.getBlockState(pos);
for (ISpeciesRoot root : AlleleManager.alleleRegistry.getSpeciesRoot().values()) {
IIndividual individual = root.translateMember(blockState);
if (individual != null) {
return individual;
}
}
return null;
}
Aggregations