Search in sources :

Example 1 with IAgriWeed

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

the class TileEntityCropBase method breakCrop.

@Override
public void breakCrop(@Nullable LivingEntity entity) {
    if (this.getWorld() == null) {
        return;
    }
    if (!MinecraftForge.EVENT_BUS.post(new AgriCropEvent.Break.Pre(this, entity))) {
        IAgriPlant plant = this.getPlant();
        IAgriWeed weed = this.getWeeds();
        Block.spawnDrops(this.getBlockState(), this.getWorld(), this.getPosition(), this);
        this.getWorld().setBlockState(this.getPosition(), Blocks.AIR.getDefaultState());
        plant.onBroken(this, entity);
        weed.onBroken(this, entity);
        MinecraftForge.EVENT_BUS.post(new AgriCropEvent.Break.Post(this, entity));
    }
}
Also used : IAgriPlant(com.infinityraider.agricraft.api.v1.plant.IAgriPlant) AgriCropEvent(com.infinityraider.agricraft.api.v1.event.AgriCropEvent) IAgriWeed(com.infinityraider.agricraft.api.v1.plant.IAgriWeed)

Example 2 with IAgriWeed

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

the class CoreHandler method initWeeds.

private static void initWeeds() {
    // Announce Progress
    AgriCore.getLogger("agricraft").info("Registering Weeds!");
    // See if plants are valid...
    final int raw = AgriCore.getWeeds().getAllElements().size();
    AgriCore.getWeeds().validate();
    final int count = AgriCore.getWeeds().getAllElements().size();
    // Transfer
    AgriCore.getWeeds().validate();
    AgriCore.getWeeds().getAllElements().stream().filter(AgriWeed::isEnabled).map(JsonWeed::new).forEach(AgriApi.getWeedRegistry()::add);
    // Display Plants
    AgriCore.getLogger("agricraft").info("Registered Weeds ({0}/{1}):", count, raw);
    for (IAgriWeed weed : AgriApi.getWeedRegistry().all()) {
        AgriCore.getLogger("agricraft").info(" - {0}", weed.getId());
    }
}
Also used : IAgriWeed(com.infinityraider.agricraft.api.v1.plant.IAgriWeed) IAgriWeed(com.infinityraider.agricraft.api.v1.plant.IAgriWeed)

Example 3 with IAgriWeed

use of com.infinityraider.agricraft.api.v1.plant.IAgriWeed 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)

Example 4 with IAgriWeed

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

the class TileEntityCropBase method rake.

@Override
public boolean rake(@Nonnull Consumer<ItemStack> consumer, @Nullable LivingEntity entity) {
    if (this.getWorld() == null || this.getWorld().isRemote()) {
        return false;
    }
    IAgriWeed weed = this.getWeeds();
    if (weed.isWeed()) {
        IAgriGrowthStage stage = this.getWeedGrowthStage();
        this.setWeed(NO_WEED, NO_GROWTH);
        weed.onRake(stage, consumer, this.getRandom(), entity);
        return true;
    }
    return false;
}
Also used : IAgriWeed(com.infinityraider.agricraft.api.v1.plant.IAgriWeed) IAgriGrowthStage(com.infinityraider.agricraft.api.v1.crop.IAgriGrowthStage)

Aggregations

IAgriWeed (com.infinityraider.agricraft.api.v1.plant.IAgriWeed)4 IAgriPlant (com.infinityraider.agricraft.api.v1.plant.IAgriPlant)2 IAgriGrowthStage (com.infinityraider.agricraft.api.v1.crop.IAgriGrowthStage)1 AgriCropEvent (com.infinityraider.agricraft.api.v1.event.AgriCropEvent)1 IAgriStatsMap (com.infinityraider.agricraft.api.v1.stat.IAgriStatsMap)1