/** Applies permanent buffs / debuffs to vanilla mobs */
 private void initBuffs(EntityLivingBase entity) {
   if (!ZSSEntityInfo.get(entity).getActiveBuffsMap().isEmpty()) {
     return;
   }
   // double damage from cold effects, highly resistant to fire damage
   if (entity.isImmuneToFire()) {
     ZSSEntityInfo.get(entity).applyBuff(Buff.RESIST_FIRE, Integer.MAX_VALUE, 75);
     ZSSEntityInfo.get(entity).applyBuff(Buff.WEAKNESS_COLD, Integer.MAX_VALUE, 100);
   }
   if (entity.getCreatureAttribute() == EnumCreatureAttribute.UNDEAD) {
     if (!entity.isImmuneToFire()) {
       ZSSEntityInfo.get(entity).applyBuff(Buff.WEAKNESS_FIRE, Integer.MAX_VALUE, 50);
     }
     ZSSEntityInfo.get(entity).applyBuff(Buff.WEAKNESS_HOLY, Integer.MAX_VALUE, 300);
     ZSSEntityInfo.get(entity).applyBuff(Buff.RESIST_COLD, Integer.MAX_VALUE, 50);
     ZSSEntityInfo.get(entity).applyBuff(Buff.RESIST_STUN, Integer.MAX_VALUE, 50);
   }
   if (entity instanceof EntityGolem) {
     ZSSEntityInfo.get(entity).applyBuff(Buff.RESIST_COLD, Integer.MAX_VALUE, 100);
     ZSSEntityInfo.get(entity).applyBuff(Buff.RESIST_STUN, Integer.MAX_VALUE, 100);
   }
   if (entity instanceof EntityWitch) {
     ZSSEntityInfo.get(entity).applyBuff(Buff.RESIST_MAGIC, Integer.MAX_VALUE, 75);
   }
   if (entity instanceof EntityWither) {
     ZSSEntityInfo.get(entity).removeBuff(Buff.WEAKNESS_COLD);
   }
 }
  @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.º 3
0
 /** Return the (magic) extra damage of the enchantments on player equipped item. */
 public static float getEnchantmentModifierLiving(
     EntityLivingBase p_77512_0_, EntityLivingBase p_77512_1_) {
   return func_152377_a(p_77512_0_.getHeldItem(), p_77512_1_.getCreatureAttribute());
 }