use of forestry.api.genetics.ISpeciesRoot in project ForestryMC by ForestryMC.
the class GeneticsUtil method getOrCreatePollinatable.
/**
* Returns an IPollinatable that can be mated. This will convert vanilla leaves to Forestry leaves.
*/
@Nullable
public static IPollinatable getOrCreatePollinatable(@Nullable GameProfile owner, World world, final BlockPos pos, boolean convertVanilla) {
IPollinatable pollinatable = TileUtil.getTile(world, pos, IPollinatable.class);
if (pollinatable == null && convertVanilla) {
final IIndividual pollen = getPollen(world, pos);
if (pollen != null) {
ISpeciesRoot root = pollen.getGenome().getSpeciesRoot();
if (root instanceof ISpeciesRootPollinatable) {
ISpeciesRootPollinatable rootPollinatable = (ISpeciesRootPollinatable) root;
pollinatable = rootPollinatable.tryConvertToPollinatable(owner, world, pos, pollen);
}
}
}
return pollinatable;
}
use of forestry.api.genetics.ISpeciesRoot in project ForestryMC by ForestryMC.
the class DatabaseScreenLogic method onItemChange.
public ScreenState onItemChange(ItemStack itemStack) {
ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(itemStack);
// No individual, abort
if (speciesRoot == null) {
return ScreenState.NO_INDIVIDUAL;
}
IIndividual individual = speciesRoot.getMember(itemStack);
// Check if a individual is selected and analyzed
if (individual == null) {
this.individual = null;
this.itemStack = ItemStack.EMPTY;
return ScreenState.NO_INDIVIDUAL;
} else if (!individual.isAnalyzed()) {
this.individual = null;
this.itemStack = ItemStack.EMPTY;
return ScreenState.NOT_ANALYZED;
}
this.individual = individual;
this.itemStack = itemStack;
if (speciesRoot != this.speciesRoot) {
IDatabaseTab[] tabs = getTabs(speciesRoot);
if (tabs == null) {
this.tabs = new IDatabaseTab[4];
return ScreenState.NO_PLUGIN;
}
this.tabs = tabs;
// Select the first tab
onTabChange(tabs[0]);
} else {
// Update the gui
onTabChange(selectedTab);
}
this.speciesRoot = speciesRoot;
return ScreenState.SUCCESS;
}
use of forestry.api.genetics.ISpeciesRoot in project ForestryMC by ForestryMC.
the class Chromosome method validateAllele.
private static IAllele validateAllele(@Nullable String speciesUid, IChromosomeType chromosomeType, @Nullable IAllele allele) {
if (!chromosomeType.getAlleleClass().isInstance(allele)) {
ISpeciesRoot speciesRoot = chromosomeType.getSpeciesRoot();
IAllele[] template = null;
if (speciesUid != null) {
template = speciesRoot.getTemplate(speciesUid);
}
if (template == null) {
template = speciesRoot.getDefaultTemplate();
}
return template[chromosomeType.ordinal()];
}
return allele;
}
use of forestry.api.genetics.ISpeciesRoot in project ForestryMC by ForestryMC.
the class InventoryDatabase method canSlotAccept.
@Override
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
itemStack = GeneticsUtil.convertToGeneticEquivalent(itemStack);
ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(itemStack);
if (speciesRoot == null) {
return false;
}
return true;
}
use of forestry.api.genetics.ISpeciesRoot in project ForestryMC by ForestryMC.
the class EntityButterfly method dropFewItems.
/* LOOT */
@Override
protected void dropFewItems(boolean playerKill, int lootLevel) {
for (ItemStack stack : contained.getLootDrop(this, playerKill, lootLevel)) {
ItemStackUtil.dropItemStackAsEntity(stack, world, posX, posY, posZ);
}
// Drop pollen if any
IIndividual pollen = getPollen();
if (pollen != null) {
ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(pollen);
ItemStack pollenStack = root.getMemberStack(pollen, EnumGermlingType.POLLEN);
ItemStackUtil.dropItemStackAsEntity(pollenStack, world, posX, posY, posZ);
}
}
Aggregations