Exemplo n.º 1
0
  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();
  }
Exemplo n.º 2
0
 protected void applyEntityAttributes() {
   super.applyEntityAttributes();
   getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(40.0D);
   getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.23000000417232513D);
   getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(20.0D);
   getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(300.0D);
   if ((this.worldObj != null) && (!this.worldObj.isRemote)) {
     IAttributeInstance iattributeinstance =
         getEntityAttribute(SharedMonsterAttributes.movementSpeed);
     iattributeinstance.applyModifier(babySpeedBoostModifier);
   }
 }
  /** 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);
  }
        @Override
        /**
         * Updates the task
         */
        public void updateTask()
        {
            if (this.field_179448_g != null)
            {
                if (--this.field_179450_h <= 0)
                {
                    this.targetEntity = this.field_179448_g;
                    this.field_179448_g = null;
                    super.startExecuting();
                    this.field_179449_j.playSound("mob.endermen.stare", 1.0F, 1.0F);
                    this.field_179449_j.setScreaming(true);
                    IAttributeInstance iattributeinstance = this.field_179449_j.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
                    iattributeinstance.applyModifier(EntityChaoticEnderman.attackingSpeedBoostModifier);
                }
            }
            else
            {
                if (this.targetEntity != null)
                {
                	this.targetEntity.addPotionEffect(new PotionEffect(9, 10, 1));
                    if (this.targetEntity instanceof EntityPlayer && this.field_179449_j.shouldAttackPlayer((EntityPlayer)this.targetEntity))
                    {
                        if (this.targetEntity.getDistanceSqToEntity(this.field_179449_j) < 16.0D)
                        {
                            this.field_179449_j.teleportRandomly();
                        }

                        this.field_179451_i = 0;
                    }
                    else if (this.targetEntity.getDistanceSqToEntity(this.field_179449_j) > 256.0D && this.field_179451_i++ >= 30 && this.field_179449_j.teleportToEntity(this.targetEntity))
                    {
                        this.field_179451_i = 0;
                    }
                }

                super.updateTask();
            }
        }
Exemplo n.º 5
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()));
      }
    }
  }
Exemplo n.º 6
0
  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) {
        }
      }
    }
  }
Exemplo n.º 7
0
  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();
  }