Search in sources :

Example 1 with ItemJournal

use of com.infinityraider.agricraft.items.ItemJournal in project AgriCraft by AgriCraft.

the class TileEntitySeedAnalyzer method analyze.

/**
     * Analyzes the current SEED.
     *
     * Marked for cleanup.
     */
public void analyze() {
    //analyze the SEED
    final Optional<AgriSeed> wrapper = AgriApi.getSeedRegistry().valueOf(specimen);
    if (wrapper.isPresent()) {
        AgriSeed seed = wrapper.get();
        seed = seed.withStat(seed.getStat().withAnalyzed(true));
        seed.getStat().writeToNBT(StackHelper.getTag(specimen));
        if (this.hasJournal()) {
            ((ItemJournal) journal.getItem()).addEntry(journal, seed.getPlant());
        }
    }
}
Also used : AgriSeed(com.infinityraider.agricraft.api.v1.seed.AgriSeed) ItemJournal(com.infinityraider.agricraft.items.ItemJournal)

Example 2 with ItemJournal

use of com.infinityraider.agricraft.items.ItemJournal in project AgriCraft by AgriCraft.

the class RecipeCopyJournal method matches.

@Override
public boolean matches(InventoryCrafting invCrafting, World world) {
    boolean foundJournal = false;
    boolean foundBook = false;
    for (int i = 0; i < invCrafting.getSizeInventory(); i++) {
        ItemStack stackAtIndex = invCrafting.getStackInSlot(i);
        if (stackAtIndex != null && stackAtIndex.getItem() != null) {
            if (stackAtIndex.getItem() instanceof ItemJournal) {
                if (!foundJournal) {
                    foundJournal = true;
                } else {
                    // Scandalous!
                    return false;
                }
            } else if (stackAtIndex.getItem() == Items.WRITABLE_BOOK) {
                if (!foundBook) {
                    foundBook = true;
                } else {
                    // There can only be one true king!
                    return false;
                }
            }
        }
    }
    return foundJournal && foundBook;
}
Also used : ItemStack(net.minecraft.item.ItemStack) ItemJournal(com.infinityraider.agricraft.items.ItemJournal)

Aggregations

ItemJournal (com.infinityraider.agricraft.items.ItemJournal)2 AgriSeed (com.infinityraider.agricraft.api.v1.seed.AgriSeed)1 ItemStack (net.minecraft.item.ItemStack)1