use of forestry.api.genetics.IIndividual in project ForestryMC by ForestryMC.
the class GeneticsUtil method convertToGeneticEquivalent.
public static ItemStack convertToGeneticEquivalent(ItemStack foreign) {
if (AlleleManager.alleleRegistry.getSpeciesRoot(foreign) == null) {
IIndividual individual = getGeneticEquivalent(foreign);
if (individual != null) {
ItemStack equivalent = TreeManager.treeRoot.getMemberStack(individual, EnumGermlingType.SAPLING);
equivalent.setCount(foreign.getCount());
return equivalent;
}
}
return foreign;
}
use of forestry.api.genetics.IIndividual 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.IIndividual 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.IIndividual 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);
}
}
use of forestry.api.genetics.IIndividual in project ForestryMC by ForestryMC.
the class ItemButterflyGE method addCreativeItems.
public void addCreativeItems(NonNullList<ItemStack> subItems, boolean hideSecrets) {
if (type == EnumFlutterType.COCOON) {
for (int age = 0; age < 3; age++) {
for (IIndividual individual : ButterflyManager.butterflyRoot.getIndividualTemplates()) {
// Don't show secret butterflies unless ordered to.
if (hideSecrets && individual.isSecret() && !Config.isDebug) {
continue;
}
ItemStack butterfly = ButterflyManager.butterflyRoot.getMemberStack(individual, type);
ItemButterflyGE.setAge(butterfly, age);
subItems.add(butterfly);
}
}
} else {
for (IIndividual individual : ButterflyManager.butterflyRoot.getIndividualTemplates()) {
// Don't show secret butterflies unless ordered to.
if (hideSecrets && individual.isSecret() && !Config.isDebug) {
continue;
}
subItems.add(ButterflyManager.butterflyRoot.getMemberStack(individual, type));
}
}
}
Aggregations