/** This gets called when a dinosaur grows naturally or through Chicken Essence. */
  @Override
  public void updateSize() {
    double healthStep;
    double attackStep;
    double speedStep;
    healthStep = (this.maxHealth - this.baseHealth) / (this.adultAge + 1);
    attackStep = (this.maxDamage - this.baseDamage) / (this.adultAge + 1);
    speedStep = (this.maxSpeed - this.baseSpeed) / (this.adultAge + 1);

    if (this.getDinoAge() <= this.adultAge) {
      this.getEntityAttribute(SharedMonsterAttributes.maxHealth)
          .setBaseValue(Math.round(this.baseHealth + (healthStep * this.getDinoAge())));
      this.getEntityAttribute(SharedMonsterAttributes.attackDamage)
          .setBaseValue(Math.round(this.baseDamage + (attackStep * this.getDinoAge())));
      this.getEntityAttribute(SharedMonsterAttributes.movementSpeed)
          .setBaseValue(this.baseSpeed + (speedStep * this.getDinoAge()));

      if (this.isTeen()) {
        this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(0.5D);
      } else if (this.isAdult()) {
        this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(2.0D);
      } else {
        this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(0.0D);
      }
    }
  }
예제 #2
0
  public void m() {
    if (this.o.w() && !this.o.D && !this.i_()) {
      float f0 = this.c(1.0F);
      BlockPos blockpos = new BlockPos(this.s, (double) Math.round(this.t), this.u);

      if (f0 > 0.5F && this.V.nextFloat() * 30.0F < (f0 - 0.4F) * 2.0F && this.o.i(blockpos)) {
        boolean flag0 = true;
        ItemStack itemstack = this.p(4);

        if (itemstack != null) {
          if (itemstack.e()) {
            itemstack.b(itemstack.h() + this.V.nextInt(2));
            if (itemstack.h() >= itemstack.j()) {
              this.b(itemstack);
              this.c(4, (ItemStack) null);
            }
          }

          flag0 = false;
        }

        if (flag0) {
          this.e(8);
        }
      }
    }

    if (this.av() && this.u() != null && this.m instanceof EntityChicken) {
      ((EntityLiving) this.m).s().a(this.s().j(), 1.5D);
    }

    super.m();
  }
예제 #3
0
  @SubscribeEvent
  public void onAttackEntity(AttackEntityEvent event) {
    if (event.entityLiving.worldObj.isRemote) return;

    EntityLivingBase attacker = event.entityLiving;
    EntityPlayer player = event.entityPlayer;
    Entity target = event.target;
    ItemStack stack = attacker.getEquipmentInSlot(0);
    if (stack != null && stack.getItem().onLeftClickEntity(stack, player, target)) return;

    if (target.canAttackWithItem()) {
      if (!target.hitByEntity(target)) {
        float damageAmount = TFC_MobData.STEVE_DAMAGE;
        if (stack != null) {
          damageAmount =
              (float)
                  player
                      .getEntityAttribute(SharedMonsterAttributes.attackDamage)
                      .getAttributeValue();
          // player.addChatMessage("Damage: " + i);
          if (damageAmount == 1.0f) {
            damageAmount = TFC_MobData.STEVE_DAMAGE;
            // i = player.inventory.getCurrentItem().getItem().getDamageVsEntity(target,
            // player.inventory.getCurrentItem());
          }
        }

        if (player.isPotionActive(Potion.damageBoost))
          damageAmount += 3 << player.getActivePotionEffect(Potion.damageBoost).getAmplifier();

        if (player.isPotionActive(Potion.weakness))
          damageAmount -= 2 << player.getActivePotionEffect(Potion.weakness).getAmplifier();

        int knockback = 0;
        float enchantmentDamage = 0;

        if (target instanceof EntityLiving) {
          enchantmentDamage =
              EnchantmentHelper.getEnchantmentModifierLiving(player, (EntityLiving) target);
          knockback += EnchantmentHelper.getKnockbackModifier(player, (EntityLiving) target);
        }

        if (player.isSprinting()) ++knockback;

        if (damageAmount > 0 || enchantmentDamage > 0) {
          boolean criticalHit =
              player.fallDistance > 0.0F
                  && !player.onGround
                  && !player.isOnLadder()
                  && !player.isInWater()
                  && !player.isPotionActive(Potion.blindness)
                  && player.ridingEntity == null
                  && target instanceof EntityLiving;

          if (criticalHit && damageAmount > 0)
            damageAmount += event.entity.worldObj.rand.nextInt((int) (damageAmount / 2 + 2));

          damageAmount += enchantmentDamage;
          boolean onFire = false;
          int fireAspect = EnchantmentHelper.getFireAspectModifier(player);

          if (target instanceof EntityLiving && fireAspect > 0 && !target.isBurning()) {
            onFire = true;
            target.setFire(1);
          }

          boolean entityAttacked =
              target.attackEntityFrom(DamageSource.causePlayerDamage(player), damageAmount);

          if (entityAttacked) {
            if (knockback > 0) {
              target.addVelocity(
                  -MathHelper.sin(player.rotationYaw * (float) Math.PI / 180.0F) * knockback * 0.5F,
                  0.1D,
                  MathHelper.cos(player.rotationYaw * (float) Math.PI / 180.0F) * knockback * 0.5F);
              player.motionX *= 0.6D;
              player.motionZ *= 0.6D;
              player.setSprinting(false);
            }

            if (criticalHit) player.onCriticalHit(target);

            if (enchantmentDamage > 0) player.onEnchantmentCritical(target);

            if (damageAmount >= 18) player.triggerAchievement(AchievementList.overkill);

            player.setLastAttacker(target);

            if (target instanceof EntityLiving)
              target.attackEntityFrom(DamageSource.causeThornsDamage(attacker), damageAmount);
          }

          ItemStack itemstack = player.getCurrentEquippedItem();
          Object object = target;

          if (target instanceof EntityDragonPart) {
            IEntityMultiPart ientitymultipart = ((EntityDragonPart) target).entityDragonObj;
            if (ientitymultipart instanceof EntityLiving) object = ientitymultipart;
          }

          if (itemstack != null && object instanceof EntityLiving) {
            itemstack.hitEntity((EntityLiving) object, player);
            if (itemstack.stackSize <= 0) player.destroyCurrentEquippedItem();
          }

          if (target instanceof EntityLivingBase) {
            player.addStat(StatList.damageDealtStat, Math.round(damageAmount * 10.0f));
            if (fireAspect > 0 && entityAttacked) target.setFire(fireAspect * 4);
            else if (onFire) target.extinguish();
          }

          player.addExhaustion(0.3F);
        }
      }
    }
    event.setCanceled(true);
  }