Exemple #1
0
 @Override
 public void doEffect(
     World world, BlockPos pos, List<ItemStack> inventory, List<ItemStack> incenses) {
   inventory.clear();
   List<EntityMob> enemies =
       (List<EntityMob>)
           world.getEntitiesWithinAABB(
               EntityMob.class,
               new AxisAlignedBB(
                   pos.getX() - 22,
                   pos.getY() - 8,
                   pos.getZ() - 22,
                   pos.getX() + 23,
                   pos.getY() + 9,
                   pos.getZ() + 23));
   float drainedHealth = 0;
   if (enemies.size() > 0) {
     for (int i = 0; i < enemies.size(); i++) {
       enemies.get(i).attackEntityFrom(DamageSource.cactus, 9);
       drainedHealth += 9;
     }
   }
   List<EntityPlayer> players =
       (List<EntityPlayer>)
           world.getEntitiesWithinAABB(
               EntityPlayer.class,
               new AxisAlignedBB(
                   pos.getX() - 22,
                   pos.getY() - 8,
                   pos.getZ() - 22,
                   pos.getX() + 23,
                   pos.getY() + 9,
                   pos.getZ() + 23));
   float numPlayers = players.size();
   for (int i = 0; i < numPlayers; i++) {
     players.get(i).heal(drainedHealth / (numPlayers * 2.5f));
     if (drainedHealth / (numPlayers * 2.5f) > 20.0) {
       if (!players.get(i).hasAchievement(RegistryManager.achieveVampire)) {
         PlayerManager.addAchievement(players.get(i), RegistryManager.achieveVampire);
       }
     }
   }
 }
Exemple #2
0
 @Override
 public void doEffect(
     World world,
     UUID casterId,
     Vec3d direction,
     EnumCastType type,
     double x,
     double y,
     double z,
     double potency,
     double duration,
     double size) {
   if (type == EnumCastType.SPELL) {
     ArrayList<EntityMob> targets =
         (ArrayList<EntityMob>)
             world.getEntitiesWithinAABB(
                 EntityMob.class,
                 new AxisAlignedBB(
                     x - (3.0 + size) * 2.4,
                     y - (3.0 + size) * 2.4,
                     z - (3.0 + size) * 2.4,
                     x + (3.0 + size) * 2.4,
                     y + (3.0 + size) * 2.4,
                     z + (3.0 + size) * 2.4));
     for (int i = 0; i < targets.size(); i++) {
       targets.get(i).setAttackTarget(null);
       int j = random.nextInt(targets.size());
       if (j != i && random.nextDouble() >= 1.6 / (potency + 2.0)) {
         EntityPlayer player = world.getPlayerEntityByUUID(casterId);
         if (player != null) {
           if (!player.hasAchievement(RegistryManager.achieveSpellInsanity)) {
             PlayerManager.addAchievement(player, RegistryManager.achieveSpellInsanity);
           }
         }
         targets.get(i).setAttackTarget(targets.get(j));
       }
     }
   }
 }