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));
}
}
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());
}
}
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());
}
}
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;
}
Aggregations