Search in sources :

Example 31 with IAgriPlant

use of com.infinityraider.agricraft.api.v1.plant.IAgriPlant in project AgriCraft by AgriCraft.

the class AgriWailaCropBlockInfoProvider method getStack.

@Override
public ItemStack getStack(IDataAccessor accessor, IPluginConfig config) {
    if (accessor.getBlock() instanceof BlockCropPlant) {
        TileEntity tile = accessor.getTileEntity();
        if (tile instanceof TileEntityCropPlant) {
            TileEntityCropPlant crop = (TileEntityCropPlant) tile;
            IAgriPlant plant = crop.getPlant();
            if (plant.isPlant()) {
                return plant.toItemStack();
            }
        }
    }
    return ItemStack.EMPTY;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IAgriPlant(com.infinityraider.agricraft.api.v1.plant.IAgriPlant) BlockCropPlant(com.infinityraider.agricraft.content.core.BlockCropPlant) TileEntityCropPlant(com.infinityraider.agricraft.content.core.TileEntityCropPlant)

Example 32 with IAgriPlant

use of com.infinityraider.agricraft.api.v1.plant.IAgriPlant 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 33 with IAgriPlant

use of com.infinityraider.agricraft.api.v1.plant.IAgriPlant in project AgriCraft by AgriCraft.

the class TileEntitySeedAnalyzer method addDebugInfo.

protected void addDebugInfo(Consumer<String> consumer) {
    ItemStack journalStack = this.getJournal();
    if (journalStack.isEmpty() || !(journalStack.getItem() instanceof IAgriJournalItem)) {
        consumer.accept("No journal present");
    } else {
        IAgriJournalItem journalItem = (IAgriJournalItem) journalStack.getItem();
        consumer.accept("Journal (" + journalItem.getDiscoveredSeeds(journalStack).size() + " plants):");
        for (IAgriPlant plant : journalItem.getDiscoveredSeeds(journalStack)) {
            consumer.accept(" - " + plant.getId());
        }
    }
}
Also used : IAgriPlant(com.infinityraider.agricraft.api.v1.plant.IAgriPlant) ItemStack(net.minecraft.item.ItemStack) IAgriJournalItem(com.infinityraider.agricraft.api.v1.content.items.IAgriJournalItem)

Example 34 with IAgriPlant

use of com.infinityraider.agricraft.api.v1.plant.IAgriPlant in project AgriCraft by AgriCraft.

the class TileEntityCropBase method addServerDebugInfo.

@Override
public void addServerDebugInfo(@Nonnull Consumer<String> consumer) {
    Preconditions.checkNotNull(consumer);
    consumer.accept("CROP:");
    if (this.hasCropSticks()) {
        consumer.accept(" - Crop Sticks Present");
    }
    if (this.isCrossCrop()) {
        consumer.accept(" - This is a cross crop");
    } else {
        final IAgriPlant plant = this.getPlant();
        final IAgriWeed weed = this.getWeeds();
        final IAgriStatsMap stats = this.getStats();
        if (plant.isPlant()) {
            consumer.accept(" - This crop has a plant");
        }
        if (weed.isWeed()) {
            consumer.accept(" - This crop has weeds");
        }
        consumer.accept(" - Plant Id: " + plant.getId());
        consumer.accept(" - Plant Stage: " + this.getGrowthStage());
        consumer.accept(" - Plant Stages: " + plant.getGrowthStages());
        consumer.accept(" - Weed Id: " + weed.getId());
        consumer.accept(" - Weed Stage: " + this.getWeedGrowthStage());
        consumer.accept(" - Weed Stages: " + weed.getGrowthStages());
        consumer.accept(" - stats: " + stats);
        consumer.accept(" - Fertile: " + this.isFertile());
        consumer.accept(" - Mature: " + this.isMature());
        consumer.accept(" - Fully Grown: " + this.isFullyGrown());
        consumer.accept(" - AgriSoil: " + this.getSoil());
    }
}
Also used : IAgriPlant(com.infinityraider.agricraft.api.v1.plant.IAgriPlant) IAgriStatsMap(com.infinityraider.agricraft.api.v1.stat.IAgriStatsMap) IAgriWeed(com.infinityraider.agricraft.api.v1.plant.IAgriWeed)

Aggregations

IAgriPlant (com.infinityraider.agricraft.api.v1.plant.IAgriPlant)32 ItemStack (net.minecraft.item.ItemStack)8 AgriSeed (com.infinityraider.agricraft.api.v1.seed.AgriSeed)7 Nonnull (javax.annotation.Nonnull)6 IAgriStat (com.infinityraider.agricraft.api.v1.stat.IAgriStat)5 PlantStats (com.infinityraider.agricraft.farming.PlantStats)5 IAgriCrop (com.infinityraider.agricraft.api.v1.crop.IAgriCrop)4 AgriApi (com.infinityraider.agricraft.api.v1.AgriApi)3 IAgriMutation (com.infinityraider.agricraft.api.v1.mutation.IAgriMutation)3 IAgriGrowthRequirement (com.infinityraider.agricraft.api.v1.requirement.IAgriGrowthRequirement)3 AgriMutation (com.agricraft.agricore.plant.AgriMutation)2 ImmutableList (com.google.common.collect.ImmutableList)2 IAgriJournalItem (com.infinityraider.agricraft.api.v1.content.items.IAgriJournalItem)2 IAgriGrowthStage (com.infinityraider.agricraft.api.v1.crop.IAgriGrowthStage)2 IAgriMutation (com.infinityraider.agricraft.api.v1.genetics.IAgriMutation)2 AgriPlantIngredient (com.infinityraider.agricraft.api.v1.plant.AgriPlantIngredient)2 IAgriWeed (com.infinityraider.agricraft.api.v1.plant.IAgriWeed)2 IAgriSoil (com.infinityraider.agricraft.api.v1.requirement.IAgriSoil)2 IAgriStatsMap (com.infinityraider.agricraft.api.v1.stat.IAgriStatsMap)2 BlockCropPlant (com.infinityraider.agricraft.content.core.BlockCropPlant)2