use of com.infinityraider.agricraft.api.v1.genetics.IAgriGeneCarrierItem in project AgriCraft by AgriCraft.
the class TileEntitySeedAnalyzer method addSeedToJournal.
public static Optional<ItemStack> addSeedToJournal(ItemStack seed, ItemStack journal) {
// Check if the items are a seed and a journal respectively
if (!seed.isEmpty() && !journal.isEmpty() && seed.getItem() instanceof IAgriGeneCarrierItem && journal.getItem() instanceof IAgriJournalItem) {
// Fetch plant from seed
IAgriJournalItem journalItem = (IAgriJournalItem) journal.getItem();
IAgriPlant plant = ((IAgriGeneCarrierItem) seed.getItem()).getPlant(seed);
// If the plant is not yet discovered, add it to the journal
if (!journalItem.isPlantDiscovered(journal, plant)) {
ItemStack newJournal = journal.copy();
journalItem.addEntry(newJournal, plant);
return Optional.of(newJournal);
}
}
return Optional.empty();
}
use of com.infinityraider.agricraft.api.v1.genetics.IAgriGeneCarrierItem in project AgriCraft by AgriCraft.
the class MagnifyingGlassGenomeInspector method onInspectionStart.
@Override
public void onInspectionStart(World world, Entity entity, PlayerEntity player) {
ItemEntity item = (ItemEntity) entity;
IAgriGeneCarrierItem seed = (IAgriGeneCarrierItem) item.getItem().getItem();
this.genomeCache = seed.getGenome(item.getItem()).map(IAgriGenome::getGeneList).orElse(ImmutableList.of());
}
Aggregations