public void performEffect(EntityLivingBase p_76394_1_, int p_76394_2_) {
   boolean remove = false;
   IInventory b = BaublesApi.getBaubles((EntityPlayer) p_76394_1_);
   if (b != null) {
     for (int i = 0; i < b.getSizeInventory(); ++i) {
       ItemStack is = b.getStackInSlot(i);
       if (is != null
           && is.getItem() != null
           && is.getItem() instanceof BaublesModifier
           && is.getItemDamage() == 31) remove = true;
     }
   }
   if (remove) p_76394_1_.removePotionEffect(this.id);
 }
  @SubscribeEvent
  public void onEntityUpdate(LivingUpdateEvent event) {
    final EntityLivingBase ent = event.entityLiving;

    if (ent.isPotionActive(GrowthCraftCellar.potionTipsy)) {
      if (ent.getActivePotionEffect(GrowthCraftCellar.potionTipsy).getDuration() == 0) {
        ent.removePotionEffect(GrowthCraftCellar.potionTipsy.id);
        return;
      }

      final int lvl = ent.getActivePotionEffect(GrowthCraftCellar.potionTipsy).getAmplifier();

      if (lvl >= 3) {
        ent.addPotionEffect(new PotionEffect(Potion.confusion.id, 200, 0));

        if (lvl >= 4) {
          ent.addPotionEffect(new PotionEffect(Potion.blindness.id, 100, 0));
        }
      }
    }
  }
  @Override
  public void onLivingUpdate() {
    this.rotationYaw = this.rotationPitch = this.prevRotationPitch = this.prevRotationYaw = 0;
    this.motionX = this.motionZ = 0D;
    this.motionY = -1D;
    super.onLivingUpdate();

    if (this.worldObj.isRemote) return;

    EntitySeeker seek;
    for (int i = 0; i < this.seekers.size(); i++) {
      seek = this.seekers.get(i);
      if (seek.isDead || seek.getHealth() <= 0 || this.getDistanceToEntity(seek) >= 32.0)
        this.seekers.remove(seek);
    }

    List<EntitySeeker> lst =
        this.worldObj.getEntitiesWithinAABB(
            EntitySeeker.class, this.getEntityBoundingBox().expand(32.0, 32.0, 32.0));

    for (EntitySeeker sk : lst) {
      if (sk.getOwner() == null) {
        sk.setOwner(this);
        this.seekers.add(sk);
      } else if (sk.getOwner() == this && !this.seekers.contains(sk)) {
        this.seekers.add(sk);
      }
    }

    if (this.seekers.isEmpty()
        && this.ticksExisted % 100 == 0
        && !TragicConfig.getBoolean("overlordPhases")) this.spawnSeekers();

    if (this.seekers.isEmpty()
        && this.getPhaseTicks() == 0
        && this.deathTime == 0
        && TragicConfig.getBoolean("overlordPhases")) this.setPhaseTicks(200);

    if (this.getPhaseTicks() > 0 && TragicConfig.getBoolean("overlordPhases")) {
      this.setPhaseTicks(this.getPhaseTicks() - 1);

      if (TragicConfig.getBoolean("overlordGas")) {
        List<BlockPos> lst2 =
            WorldHelper.getBlocksInSphericalRange(
                this.worldObj,
                3.5,
                this.posX + rand.nextInt(4) - rand.nextInt(4),
                this.posY,
                this.posZ + rand.nextInt(4) - rand.nextInt(4));
        for (BlockPos coords : lst2) {
          if (World.doesBlockHaveSolidTopSurface(this.worldObj, coords.down())
              && EntityOverlordCore.replaceableBlocks.contains(
                  this.worldObj.getBlockState(coords).getBlock())) {
            this.worldObj.setBlockState(coords, TragicBlocks.CorruptedGas.getDefaultState());
          }
        }
      }

      if (this.phaseChange) {
        this.phaseChange = false;
        this.setPhaseTicks(0);
        for (EntitySeeker sk : this.seekers) sk.setDead();
        this.spawnSeekers();
        this.phaseDamage = 0F;

        if (this.getHealth() > 0F) {
          float f = this.getMaxHealth() / 5;
          switch (this.getCurrentPhase()) {
            case 0:
              f *= 4;
              break;
            case 1:
              f *= 3;
              break;
            case 2:
              f *= 2;
              break;
            case 3:
              break;
            case 4:
              f = 0;
              break;
            default:
              break;
          }
          this.setHealth(f);
        }

        if (TragicConfig.getBoolean("allowDivinity")) {
          List<Entity> list =
              this.worldObj.getEntitiesWithinAABBExcludingEntity(
                  this, this.getEntityBoundingBox().expand(64.0, 64.0, 64.0));
          for (Entity e : list) {
            if (e instanceof EntityLivingBase
                && ((EntityLivingBase) e).isPotionActive(TragicPotion.Divinity))
              ((EntityLivingBase) e).removePotionEffect(TragicPotion.Divinity.id);
          }
        }
        if (TragicConfig.getBoolean("allowMobSounds"))
          this.worldObj.playSoundAtEntity(
              this, "tragicmc:boss.overlordcocoon.phasecomplete", 1.8F, 1.0F);
      } else {
        if (this.getPhaseTicks() == 199) {
          if (TragicConfig.getBoolean("allowDivinity")) {
            List<Entity> list =
                this.worldObj.getEntitiesWithinAABBExcludingEntity(
                    this, this.getEntityBoundingBox().expand(64.0, 64.0, 64.0));
            for (Entity e : list) {
              if (e instanceof EntityLivingBase
                  && !((EntityLivingBase) e).isPotionActive(TragicPotion.Divinity))
                ((EntityLivingBase) e)
                    .addPotionEffect(new PotionEffect(TragicPotion.Divinity.id, 200));
            }
          }
        }

        if (this.getPhaseTicks() == 0) {
          if (this.getHealth() > 0F) {
            float f = this.getMaxHealth() / 5;
            switch (this.getCurrentPhase()) {
              case 0:
                f *= 5;
                break;
              case 1:
                f *= 4;
                break;
              case 2:
                f *= 3;
                break;
              case 3:
                f *= 2;
                break;
              case 4:
              default:
                break;
            }
            this.setHealth(f);
          }
          this.phaseDamage = 0F;

          for (EntitySeeker sk : this.seekers) sk.setDead();
          this.spawnSeekers();

          if (TragicConfig.getBoolean("allowDivinity")) {
            List<Entity> list =
                this.worldObj.getEntitiesWithinAABBExcludingEntity(
                    this, this.getEntityBoundingBox().expand(64.0, 64.0, 64.0));
            for (Entity e : list) {
              if (e instanceof EntityLivingBase
                  && ((EntityLivingBase) e).isPotionActive(TragicPotion.Divinity))
                ((EntityLivingBase) e).removePotionEffect(TragicPotion.Divinity.id);
            }
          }

          if (TragicConfig.getBoolean("allowMobSounds"))
            this.worldObj.playSoundAtEntity(
                this, "tragicmc:boss.overlordcocoon.phasefail", 1.8F, 1.0F);
        }

        if (TragicConfig.getBoolean("allowMobSounds") && this.getPhaseTicks() % 10 == 0)
          this.worldObj.playSoundAtEntity(this, "tragicmc:boss.overlordcocoon.wah", 1.4F, 1.0F);
      }
    }
  }
Exemplo n.º 4
0
  public void processCommand(ICommandSender sender, String[] args) throws CommandException {
    if (args.length < 2) {
      throw new WrongUsageException("commands.effect.usage", new Object[0]);
    } else {
      EntityLivingBase var3 =
          (EntityLivingBase) func_175759_a(sender, args[0], EntityLivingBase.class);

      if (args[1].equals("clear")) {
        if (var3.getActivePotionEffects().isEmpty()) {
          throw new CommandException(
              "commands.effect.failure.notActive.all", new Object[] {var3.getName()});
        } else {
          var3.clearActivePotions();
          notifyOperators(
              sender, this, "commands.effect.success.removed.all", new Object[] {var3.getName()});
        }
      } else {
        int var4;

        try {
          var4 = parseInt(args[1], 1);
        } catch (NumberInvalidException var11) {
          Potion var6 = Potion.getPotionAtLocation(args[1]);

          if (var6 == null) {
            throw var11;
          }

          var4 = var6.id;
        }

        int var5 = 600;
        int var12 = 30;
        int var7 = 0;

        if (var4 >= 0 && var4 < Potion.potionTypes.length && Potion.potionTypes[var4] != null) {
          Potion var8 = Potion.potionTypes[var4];

          if (args.length >= 3) {
            var12 = parseInt(args[2], 0, 1000000);

            if (var8.isInstant()) {
              var5 = var12;
            } else {
              var5 = var12 * 20;
            }
          } else if (var8.isInstant()) {
            var5 = 1;
          }

          if (args.length >= 4) {
            var7 = parseInt(args[3], 0, 255);
          }

          boolean var9 = true;

          if (args.length >= 5 && "true".equalsIgnoreCase(args[4])) {
            var9 = false;
          }

          if (var12 > 0) {
            PotionEffect var10 = new PotionEffect(var4, var5, var7, false, var9);
            var3.addPotionEffect(var10);
            notifyOperators(
                sender,
                this,
                "commands.effect.success",
                new Object[] {
                  new FormattedTextTranslation(var10.getEffectName(), new Object[0]),
                  Integer.valueOf(var4),
                  Integer.valueOf(var7),
                  var3.getName(),
                  Integer.valueOf(var12)
                });
          } else if (var3.isPotionActive(var4)) {
            var3.removePotionEffect(var4);
            notifyOperators(
                sender,
                this,
                "commands.effect.success.removed",
                new Object[] {
                  new FormattedTextTranslation(var8.getName(), new Object[0]), var3.getName()
                });
          } else {
            throw new CommandException(
                "commands.effect.failure.notActive",
                new Object[] {
                  new FormattedTextTranslation(var8.getName(), new Object[0]), var3.getName()
                });
          }
        } else {
          throw new NumberInvalidException(
              "commands.effect.notFound", new Object[] {Integer.valueOf(var4)});
        }
      }
    }
  }