Exemplo n.º 1
0
  public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLiving, float par2) {
    if (!this.getAggressive()) {
      EntityPotion var2 = new EntityPotion(this.worldObj, this, 32732);
      var2.rotationPitch -= -20.0F;
      double var3 = par1EntityLiving.posX + par1EntityLiving.motionX - this.posX;
      double var5 =
          par1EntityLiving.posY
              + (double) par1EntityLiving.getEyeHeight()
              - 1.100000023841858D
              - this.posY;
      double var7 = par1EntityLiving.posZ + par1EntityLiving.motionZ - this.posZ;
      float var9 = MathHelper.sqrt_double(var3 * var3 + var7 * var7);
      if (var9 >= 8.0F && !par1EntityLiving.isPotionActive(Potion.moveSlowdown)) {
        var2.setPotionDamage(32698);
      } else if (par1EntityLiving.getHealth() >= 8.0F
          && !par1EntityLiving.isPotionActive(Potion.poison)) {
        var2.setPotionDamage(32660);
      } else if (var9 <= 3.0F
          && !par1EntityLiving.isPotionActive(Potion.weakness)
          && this.rand.nextFloat() < 0.25F) {
        var2.setPotionDamage(32696);
      }

      var2.setThrowableHeading(var3, var5 + (double) (var9 * 0.2F), var7, 0.75F, 8.0F);
      this.worldObj.spawnEntityInWorld(var2);
    }
  }
 public static void addOrMergePotionEffect(EntityLivingBase player, PotionEffect newp) {
   if (player.isPotionActive(newp.getPotion())) {
     // do not use built in 'combine' function, just add up duration myself
     PotionEffect p = player.getActivePotionEffect(newp.getPotion());
     int ampMax = Math.max(p.getAmplifier(), newp.getAmplifier());
     player.addPotionEffect(
         new PotionEffect(newp.getPotion(), newp.getDuration() + p.getDuration(), ampMax));
   } else {
     player.addPotionEffect(newp);
   }
 }
Exemplo n.º 3
0
 public static Optional<Tuple<DamageModifier, Function<? super Double, Double>>>
     createResistanceModifier(EntityLivingBase entityLivingBase, DamageSource damageSource) {
   if (!damageSource.isDamageAbsolute()
       && entityLivingBase.isPotionActive(Potion.resistance)
       && damageSource != DamageSource.outOfWorld) {
     PotionEffect effect =
         ((PotionEffect) entityLivingBase.getActivePotionEffect(Potion.resistance));
     return Optional.of(
         new Tuple<>(
             DamageModifier.builder()
                 .cause(Cause.of(NamedCause.of(DamageEntityEvent.RESISTANCE, effect)))
                 .type(DamageModifierTypes.DEFENSIVE_POTION_EFFECT)
                 .build(),
             createResistanceFunction(effect.getAmplifier())));
   }
   return Optional.empty();
 }
Exemplo n.º 4
0
 public static Optional<Tuple<DamageModifier, Function<? super Double, Double>>>
     createAbsorptionModifier(EntityLivingBase entityLivingBase, DamageSource damageSource) {
   if (entityLivingBase.isPotionActive(Potion.absorption)) {
     Function<? super Double, Double> function =
         damage ->
             -(Math.max(
                 damage - Math.max(damage - entityLivingBase.getAbsorptionAmount(), 0.0F), 0.0F));
     DamageModifier modifier =
         DamageModifier.builder()
             .cause(
                 Cause.of(
                     NamedCause.of(
                         DamageEntityEvent.ABSORPTION,
                         entityLivingBase.getActivePotionEffect(Potion.absorption)),
                     NamedCause.of(DamageEntityEvent.CREATOR, entityLivingBase)))
             .type(DamageModifierTypes.ABSORPTION)
             .build();
     return Optional.of(new Tuple<>(modifier, function));
   }
   return Optional.empty();
 }
  @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));
        }
      }
    }
  }
Exemplo n.º 6
0
  @Override
  protected void attackEntity(Entity entity, float damage) {
    // Prevent attacks during death.
    if (this.getHealth() <= 0.0F) {
      return;
    }

    super.attackEntity(entity, damage);

    double distance = RadixMath.getDistanceToEntity(this, entity);

    if (distance > 3.0F) {
      setAttackPath(entity);
    } else {
      final EntityLivingBase living = (EntityLivingBase) entity;

      // The tank spider can poison its targets.
      if (spiderType == EnumSpiderType.TANK) {
        PotionEffect poison = new PotionEffect(Potion.poison.id, Time.SECOND * 5 * getLevel());
        EntityLivingBase entityLiving = (EntityLivingBase) entity;

        if (entityLiving.isPotionApplicable(poison)
            && !entityLiving.isPotionActive(Potion.poison)) {
          entityLiving.addPotionEffect(poison);
        }
      }

      entity.attackEntityFrom(DamageSource.causeMobDamage(this), getAttackDamage());
    }

    if (onGround && distance < 3.0F) {
      final double dX = entity.posX - posX;
      final double dY = entity.posZ - posZ;
      final float f2 = MathHelper.sqrt_double(dX * dX + dY * dY);
      motionX = dX / f2 * 0.5D * 0.8D + motionX * 0.2D;
      motionZ = dY / f2 * 0.5D * 0.8D + motionZ * 0.2D;
      motionY = 0.4D;
    }
  }
  @Override
  public boolean attackEntityFrom(DamageSource src, float dmg) {
    if (src.isProjectile() || this.worldObj.isRemote) return false;

    if (src.getEntity() instanceof EntityLivingBase) {
      EntityLivingBase entity = (EntityLivingBase) src.getEntity();
      boolean flag =
          TragicConfig.getBoolean("allowDivinity") && entity.isPotionActive(TragicPotion.Divinity);

      if (rand.nextInt(4) == 0
          && this.getAttackTarget() != entity
          && entity.getCreatureAttribute() != TragicEntities.Synapse) this.setAttackTarget(entity);

      if (flag && this.hurtResistantTime == 0
          || !TragicConfig.getBoolean("allowDivinity")
              && entity.getCreatureAttribute() != TragicEntities.Synapse
              && this.hurtResistantTime == 0
          || entity.getHeldItem() != null
              && entity.getHeldItem().getItem() == TragicItems.SwordOfJustice
          || src.canHarmInCreative()
          || !TragicConfig.getBoolean("overlordDivineWeakness")
          || !TragicConfig.getBoolean("overlordPhases")) {
        this.phaseDamage +=
            MathHelper.clamp_float(
                dmg - this.getTotalArmorValue(), 0F, (float) TragicConfig.getInt("bossDamageCap"));

        if (this.getCurrentPhase() < 4) {
          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;
          }

          if (this.getHealth()
                          - MathHelper.clamp_float(
                              dmg - this.getTotalArmorValue(),
                              0F,
                              (float) TragicConfig.getInt("bossDamageCap"))
                      <= f
                  && f > 0
              || this.phaseDamage >= this.getMaxHealth() / 5) {
            this.phaseChange = true;
            dmg = 0;
            this.phaseDamage = 0F;
          }
        }

        if (rand.nextBoolean()
            && this.worldObj
                    .getEntitiesWithinAABB(
                        EntityNanoSwarm.class,
                        this.getEntityBoundingBox().expand(64.0, 64.0, 64.0D))
                    .size()
                < 16
            && this.getCurrentPhase() > 1
            && TragicConfig.getBoolean("allowNanoSwarm")
            && TragicConfig.getBoolean("overlordNanoSwarms")) {
          EntityNanoSwarm swarm = new EntityNanoSwarm(this.worldObj);
          swarm.setPosition(
              this.posX + rand.nextInt(6) - rand.nextInt(6),
              this.posY,
              this.posZ + rand.nextInt(6) - rand.nextInt(6));
          this.worldObj.spawnEntityInWorld(swarm);
        }

        return super.attackEntityFrom(src, dmg);
      }
    }
    return true;
  }
Exemplo n.º 8
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)});
        }
      }
    }
  }