protected void updateAITasks() {
    IAttributeInstance iattributeinstance =
        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed);

    if (this.isAngry()) {
      if (!this.isChild() && !iattributeinstance.hasModifier(ATTACK_SPEED_BOOST_MODIFIER)) {
        iattributeinstance.applyModifier(ATTACK_SPEED_BOOST_MODIFIER);
      }

      --this.angerLevel;
    } else if (iattributeinstance.hasModifier(ATTACK_SPEED_BOOST_MODIFIER)) {
      iattributeinstance.removeModifier(ATTACK_SPEED_BOOST_MODIFIER);
    }

    if (this.randomSoundDelay > 0 && --this.randomSoundDelay == 0) {
      this.playSound(
          "mob.zombiepig.zpigangry",
          this.getSoundVolume() * 2.0F,
          ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F) * 1.8F);
    }

    if (this.angerLevel > 0 && this.angerTargetUUID != null && this.getAITarget() == null) {
      EntityPlayer entityplayer = this.worldObj.getPlayerEntityByUUID(this.angerTargetUUID);
      this.setRevengeTarget(entityplayer);
      this.attackingPlayer = entityplayer;
      this.recentlyHit = this.getRevengeTimer();
    }

    super.updateAITasks();
  }
 @Override
 /**
  * Resets the task
  */
 public void resetTask()
 {
     this.field_179448_g = null;
     this.field_179449_j.setScreaming(false);
     IAttributeInstance iattributeinstance = this.field_179449_j.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
     iattributeinstance.removeModifier(EntityChaoticEnderman.attackingSpeedBoostModifier);
     super.resetTask();
 }
  public void recalculateHealth(EntityPlayer player, TPlayerStats stats) {
    Side side = FMLCommonHandler.instance().getEffectiveSide();

    if (inventory[4] != null || inventory[5] != null || inventory[6] != null) {
      int bonusHP = 0;
      for (int i = 4; i < 7; i++) {
        ItemStack stack = inventory[i];
        if (stack != null && stack.getItem() instanceof IHealthAccessory) {
          bonusHP += ((IHealthAccessory) stack.getItem()).getHealthBoost(stack);
        }
      }
      int prevHealth = stats.bonusHealth;
      stats.bonusHealth = bonusHP;

      int healthChange = bonusHP - prevHealth;
      if (healthChange != 0) {
        IAttributeInstance attributeinstance =
            player.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.maxHealth);
        try {
          attributeinstance.removeModifier(attributeinstance.getModifier(globalID));
        } catch (Exception e) {
        }
        attributeinstance.applyModifier(
            new AttributeModifier(globalID, "tconstruct.heartCanister", bonusHP, 0));
      }
    } else if (parent != null && parent.get() != null) {
      int prevHealth = stats.bonusHealth;
      int bonusHP = 0;
      stats.bonusHealth = bonusHP;
      int healthChange = bonusHP - prevHealth;
      if (healthChange != 0) {
        IAttributeInstance attributeinstance =
            player.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.maxHealth);
        try {
          attributeinstance.removeModifier(attributeinstance.getModifier(globalID));
        } catch (Exception e) {
        }
      }
    }
  }
Beispiel #4
0
  public void removeAttributesModifiersFromEntity(
      EntityLivingBase p_111187_1_, BaseAttributeMap p_111187_2_, int p_111187_3_) {
    Iterator var4 = this.attributeModifierMap.entrySet().iterator();

    while (var4.hasNext()) {
      Entry var5 = (Entry) var4.next();
      IAttributeInstance var6 = p_111187_2_.getAttributeInstance((IAttribute) var5.getKey());

      if (var6 != null) {
        var6.removeModifier((AttributeModifier) var5.getValue());
      }
    }
  }
  /** Set whether this zombie is a child. */
  public void setChild(boolean par1) {
    this.getDataWatcher().updateObject(12, Byte.valueOf((byte) (par1 ? 1 : 0)));

    if (this.worldObj != null && !this.worldObj.isRemote) {
      IAttributeInstance iattributeinstance =
          this.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
      iattributeinstance.removeModifier(babySpeedBoostModifier);

      if (par1) {
        iattributeinstance.applyModifier(babySpeedBoostModifier);
      }
    }

    this.func_146071_k(par1);
  }
Beispiel #6
0
  public void applyAttributesModifiersToEntity(
      EntityLivingBase p_111185_1_, BaseAttributeMap p_111185_2_, int p_111185_3_) {
    Iterator var4 = this.attributeModifierMap.entrySet().iterator();

    while (var4.hasNext()) {
      Entry var5 = (Entry) var4.next();
      IAttributeInstance var6 = p_111185_2_.getAttributeInstance((IAttribute) var5.getKey());

      if (var6 != null) {
        AttributeModifier var7 = (AttributeModifier) var5.getValue();
        var6.removeModifier(var7);
        var6.applyModifier(
            new AttributeModifier(
                var7.getID(),
                this.getName() + " " + p_111185_3_,
                this.func_111183_a(p_111185_3_, var7),
                var7.getOperation()));
      }
    }
  }
  public void onLivingUpdate() {
    if (!this.onGround && this.motionY < 0.0D) {
      this.motionY *= 0.8D;
    }

    for (int var5 = 0; var5 < 2; ++var5) {
      // "witchMagic"
      this.worldObj.spawnParticle(
          EnumParticleTypes.SPELL_WITCH,
          this.posX + (this.rand.nextDouble() - 0.5D) * (double) this.width,
          this.posY + this.rand.nextDouble() * (double) this.height,
          this.posZ + (this.rand.nextDouble() - 0.5D) * (double) this.width,
          0.0D,
          0.0D,
          0.0D);
    }

    EntitySpider mob;
    if (this.getHealth() < EntityAttributes.maxHealth2 * 0.75F
        && this.getHealth() > 0.0F
        && this.spawn == 0
        && !this.worldObj.isRemote) {
      mob = new EntitySpider(this.worldObj);
      mob.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
      // mob.onSpawnWithEgg((IEntityLivingData)null);
      mob.onInitialSpawn(
          this.worldObj.getDifficultyForLocation(new BlockPos(mob)), (IEntityLivingData) null);
      this.worldObj.spawnEntityInWorld(mob);
      this.spawn = 1;
    }

    if (this.getHealth() < EntityAttributes.maxHealth2 * 0.25F
        && this.getHealth() > 0.0F
        && this.spawn == 1
        && !this.worldObj.isRemote) {
      mob = new EntitySpider(this.worldObj);
      mob.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
      // mob.onSpawnWithEgg((IEntityLivingData)null);
      mob.onInitialSpawn(
          this.worldObj.getDifficultyForLocation(new BlockPos(mob)), (IEntityLivingData) null);
      this.worldObj.spawnEntityInWorld(mob);
      this.spawn = 2;
    }

    if (!this.worldObj.isRemote) {
      if (this.getAggressive()) {
        if (this.witchAttackTimer-- <= 0) {
          this.setAggressive(false);
          ItemStack var6 = this.getHeldItem();
          this.setCurrentItemOrArmor(0, (ItemStack) null);
          if (var6 != null && var6.getItem() == Items.potionitem) {
            List var2 = Items.potionitem.getEffects(var6);
            if (var2 != null) {
              Iterator var3 = var2.iterator();

              while (var3.hasNext()) {
                PotionEffect var4 = (PotionEffect) var3.next();
                this.addPotionEffect(new PotionEffect(var4));
              }
            }
          }

          this.getEntityAttribute(SharedMonsterAttributes.movementSpeed)
              .removeModifier(field_110185_bq);
        }
      } else {
        short var7 = -1;
        if (this.rand.nextFloat() < 0.15F
            && this.isInsideOfMaterial(Material.water)
            && !this.isPotionActive(Potion.waterBreathing)) {
          var7 = 8237;
        } else if (this.rand.nextFloat() < 0.15F
            && this.isBurning()
            && !this.isPotionActive(Potion.fireResistance)) {
          var7 = 16307;
        } else if (this.rand.nextFloat() < 0.05F && this.getHealth() < this.getMaxHealth()) {
          var7 = 16341;
        } else if (this.rand.nextFloat() < 0.25F
            && this.getAttackTarget() != null
            && !this.isPotionActive(Potion.moveSpeed)
            && this.getAttackTarget().getDistanceSqToEntity(this) > 121.0D) {
          var7 = 16274;
        } else if (this.rand.nextFloat() < 0.25F
            && this.getAttackTarget() != null
            && !this.isPotionActive(Potion.moveSpeed)
            && this.getAttackTarget().getDistanceSqToEntity(this) > 121.0D) {
          var7 = 16274;
        }

        if (var7 > -1) {
          this.setCurrentItemOrArmor(0, new ItemStack(Items.potionitem, 1, var7));
          this.witchAttackTimer = this.getHeldItem().getMaxItemUseDuration();
          this.setAggressive(true);
          IAttributeInstance iattributeinstance =
              this.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
          iattributeinstance.removeModifier(field_110185_bq);
          iattributeinstance.applyModifier(field_110185_bq);
        }
      }

      if (this.rand.nextFloat() < 7.5E-4F) {
        this.worldObj.setEntityState(this, (byte) 15);
      }
    }

    super.onLivingUpdate();
  }