Search in sources :

Example 1 with IAgriGeneCarrierItem

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();
}
Also used : IAgriPlant(com.infinityraider.agricraft.api.v1.plant.IAgriPlant) IAgriJournalItem(com.infinityraider.agricraft.api.v1.content.items.IAgriJournalItem) ItemStack(net.minecraft.item.ItemStack)

Example 2 with IAgriGeneCarrierItem

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());
}
Also used : IAgriGeneCarrierItem(com.infinityraider.agricraft.api.v1.genetics.IAgriGeneCarrierItem) ItemEntity(net.minecraft.entity.item.ItemEntity) IAgriGenome(com.infinityraider.agricraft.api.v1.genetics.IAgriGenome)

Aggregations

IAgriJournalItem (com.infinityraider.agricraft.api.v1.content.items.IAgriJournalItem)1 IAgriGeneCarrierItem (com.infinityraider.agricraft.api.v1.genetics.IAgriGeneCarrierItem)1 IAgriGenome (com.infinityraider.agricraft.api.v1.genetics.IAgriGenome)1 IAgriPlant (com.infinityraider.agricraft.api.v1.plant.IAgriPlant)1 ItemEntity (net.minecraft.entity.item.ItemEntity)1 ItemStack (net.minecraft.item.ItemStack)1