@SubscribeEvent(priority = EventPriority.LOWEST, receiveCanceled = true) public void onDirtTilled(UseHoeEvent event) { if (!event.getWorld().isRemote && !event.isCanceled()) { if (CropHelper.isRainingAt(event.getWorld(), event.getPos().up(2))) { MinecraftForge.EVENT_BUS.register(new RainingSoil(event.getEntityPlayer(), event.getWorld(), event.getPos())); } HFApi.tickable.addTickable(event.getWorld(), event.getPos(), this); } }
@SubscribeEvent(priority = EventPriority.LOW) public void onHoe(UseHoeEvent event){ if(ConfigBoolValues.WORMS.isEnabled() && event.getResult() != Result.DENY){ World world = event.getWorld(); if(!world.isRemote){ BlockPos pos = event.getPos(); if(world.isAirBlock(pos.up())){ IBlockState state = world.getBlockState(pos); if(state.getBlock() instanceof BlockGrass && world.rand.nextFloat() >= 0.95F){ ItemStack stack = new ItemStack(InitItems.itemWorm, world.rand.nextInt(2)+1); EntityItem item = new EntityItem(event.getWorld(), pos.getX()+0.5, pos.getY()+1, pos.getZ()+0.5, stack); world.spawnEntity(item); } } } } }