Exemplo n.º 1
0
 public static void a(EntityLiving entityliving, Entity entity) {
   d.b = entity;
   d.a = entityliving;
   a((EnchantmentModifier) d, entityliving.getEquipment());
   if (entity instanceof EntityHuman) {
     a((EnchantmentModifier) d, entityliving.be());
   }
 }
Exemplo n.º 2
0
 public static void b(EntityLiving entityliving, Entity entity) {
   e.a = entityliving;
   e.b = entity;
   a((EnchantmentModifier) e, entityliving.getEquipment());
   if (entityliving instanceof EntityHuman) {
     a((EnchantmentModifier) e, entityliving.be());
   }
 }
Exemplo n.º 3
0
  protected float c(DamageSource damagesource, float f) {
    if (this instanceof EntityZombie) {
      f = f;
    }

    int i;
    int j;
    float f1;

    if (this.hasEffect(MobEffectList.RESISTANCE) && damagesource != DamageSource.OUT_OF_WORLD) {
      i = (this.getEffect(MobEffectList.RESISTANCE).getAmplifier() + 1) * 5;
      j = 25 - i;
      f1 = f * (float) j;
      f = f1 / 25.0F;
    }

    if (f <= 0.0F) {
      return 0.0F;
    } else {
      i = EnchantmentManager.a(this.getEquipment(), damagesource);
      if (i > 20) {
        i = 20;
      }

      if (i > 0 && i <= 20) {
        j = 25 - i;
        f1 = f * (float) j;
        f = f1 / 25.0F;
      }

      return f;
    }
  }
Exemplo n.º 4
0
  protected void a(EntityLiving entityliving, Entity entity) {
    if (entity instanceof EntityLiving) {
      EnchantmentManager.a((EntityLiving) entity, (Entity) entityliving);
    }

    EnchantmentManager.b(entityliving, entity);
  }
Exemplo n.º 5
0
  public static int a(ItemStack[] aitemstack, DamageSource damagesource) {
    b.a = 0;
    b.b = damagesource;
    a((EnchantmentModifier) b, aitemstack);
    if (b.a > 25) {
      b.a = 25;
    }

    return (b.a + 1 >> 1) + random.nextInt((b.a >> 1) + 1);
  }
Exemplo n.º 6
0
  private static void a(EnchantmentModifier enchantmentmodifier, ItemStack[] aitemstack) {
    ItemStack[] aitemstack1 = aitemstack;
    int i = aitemstack.length;

    for (int j = 0; j < i; ++j) {
      ItemStack itemstack = aitemstack1[j];

      a(enchantmentmodifier, itemstack);
    }
  }
Exemplo n.º 7
0
  protected ItemStack l(int i) {
    if (i > 0) {
      ItemStack itemstack = new ItemStack(Item.GOLD_SWORD);

      EnchantmentManager.a(this.random, itemstack, 5);
      return itemstack;
    }
    int j = this.random.nextInt(3);

    if (j == 0) return new ItemStack(Item.GOLD_INGOT.id, 1, 0);
    if (j == 1) return new ItemStack(Item.GOLD_SWORD.id, 1, 0);
    if (j == 2) {
      return new ItemStack(Item.GOLD_HELMET.id, 1, 0);
    }
    return null;
  }
Exemplo n.º 8
0
  public boolean m(Entity entity) {
    int i = this.c(entity);

    if (this.hasEffect(MobEffectList.INCREASE_DAMAGE)) {
      i += 3 << this.getEffect(MobEffectList.INCREASE_DAMAGE).getAmplifier();
    }

    if (this.hasEffect(MobEffectList.WEAKNESS)) {
      i -= 2 << this.getEffect(MobEffectList.WEAKNESS).getAmplifier();
    }

    int j = 0;

    if (entity instanceof EntityLiving) {
      i += EnchantmentManager.a((EntityLiving) this, (EntityLiving) entity);
      j += EnchantmentManager.getKnockbackEnchantmentLevel(this, (EntityLiving) entity);
    }

    boolean flag = entity.damageEntity(DamageSource.mobAttack(this), i);

    if (flag) {
      if (j > 0) {
        entity.g(
            (double) (-MathHelper.sin(this.yaw * 3.1415927F / 180.0F) * (float) j * 0.5F),
            0.1D,
            (double) (MathHelper.cos(this.yaw * 3.1415927F / 180.0F) * (float) j * 0.5F));
        this.motX *= 0.6D;
        this.motZ *= 0.6D;
      }

      int k = EnchantmentManager.getFireAspectEnchantmentLevel(this);

      if (k > 0) {
        entity.setOnFire(k * 4);
      }
    }

    return flag;
  }
Exemplo n.º 9
0
  protected int b(DamageSource damagesource, int i) {
    int j = super.b(damagesource, i);

    if (j <= 0) {
      return 0;
    } else {
      int k = EnchantmentManager.a(this.inventory, damagesource);

      if (k > 20) {
        k = 20;
      }

      if (k > 0 && k <= 20) {
        int l = 25 - k;
        int i1 = j * l + this.ar;

        j = i1 / 25;
        this.ar = i1 % 25;
      }

      return j;
    }
  }
Exemplo n.º 10
0
 public static float a(EntityLiving entityliving, EntityLiving entityliving1) {
   c.a = 0.0F;
   c.b = entityliving1;
   a((EnchantmentModifier) c, entityliving.be());
   return c.a;
 }
Exemplo n.º 11
0
  public void h() {
    super.h();
    if (this.lastPitch == 0.0F && this.lastYaw == 0.0F) {
      float f = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ);

      this.lastYaw =
          this.yaw = (float) (Math.atan2(this.motX, this.motZ) * 180.0D / 3.1415927410125732D);
      this.lastPitch =
          this.pitch = (float) (Math.atan2(this.motY, (double) f) * 180.0D / 3.1415927410125732D);
    }

    Block block = this.world.getType(this.d, this.e, this.f);

    if (block.getMaterial() != Material.AIR) {
      block.updateShape(this.world, this.d, this.e, this.f);
      AxisAlignedBB axisalignedbb = block.a(this.world, this.d, this.e, this.f);

      if (axisalignedbb != null && axisalignedbb.a(Vec3D.a(this.locX, this.locY, this.locZ))) {
        this.inGround = true;
      }
    }

    if (this.shake > 0) {
      --this.shake;
    }

    if (this.inGround) {
      int i = this.world.getData(this.d, this.e, this.f);

      if (block == this.g && i == this.h) {
        ++this.at;
        if (this.at == 1200) {
          this.die();
        }
      } else {
        this.inGround = false;
        this.motX *= (double) (this.random.nextFloat() * 0.2F);
        this.motY *= (double) (this.random.nextFloat() * 0.2F);
        this.motZ *= (double) (this.random.nextFloat() * 0.2F);
        this.at = 0;
        this.au = 0;
      }
    } else {
      ++this.au;
      Vec3D vec3d = Vec3D.a(this.locX, this.locY, this.locZ);
      Vec3D vec3d1 = Vec3D.a(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
      MovingObjectPosition movingobjectposition =
          this.world.rayTrace(vec3d, vec3d1, false, true, false);

      vec3d = Vec3D.a(this.locX, this.locY, this.locZ);
      vec3d1 = Vec3D.a(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
      if (movingobjectposition != null) {
        vec3d1 =
            Vec3D.a(
                movingobjectposition.pos.a, movingobjectposition.pos.b, movingobjectposition.pos.c);
      }

      Entity entity = null;
      List list =
          this.world.getEntities(
              this, this.boundingBox.a(this.motX, this.motY, this.motZ).grow(1.0D, 1.0D, 1.0D));
      double d0 = 0.0D;

      int j;
      float f1;

      for (j = 0; j < list.size(); ++j) {
        Entity entity1 = (Entity) list.get(j);

        if (entity1.Q() && (entity1 != this.shooter || this.au >= 5)) {
          f1 = 0.3F;
          AxisAlignedBB axisalignedbb1 =
              entity1.boundingBox.grow((double) f1, (double) f1, (double) f1);
          MovingObjectPosition movingobjectposition1 = axisalignedbb1.a(vec3d, vec3d1);

          if (movingobjectposition1 != null) {
            double d1 =
                vec3d.distanceSquared(
                    movingobjectposition1.pos); // CraftBukkit - distance efficiency

            if (d1 < d0 || d0 == 0.0D) {
              entity = entity1;
              d0 = d1;
            }
          }
        }
      }

      if (entity != null) {
        movingobjectposition = new MovingObjectPosition(entity);
      }

      if (movingobjectposition != null
          && movingobjectposition.entity != null
          && movingobjectposition.entity instanceof EntityHuman) {
        EntityHuman entityhuman = (EntityHuman) movingobjectposition.entity;

        if (entityhuman.abilities.isInvulnerable
            || this.shooter instanceof EntityHuman
                && !((EntityHuman) this.shooter).a(entityhuman)) {
          movingobjectposition = null;
        }
      }

      float f2;
      float f3;

      if (movingobjectposition != null) {
        org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(
            this); // CraftBukkit - Call event

        if (movingobjectposition.entity != null) {
          f2 =
              MathHelper.sqrt(
                  this.motX * this.motX + this.motY * this.motY + this.motZ * this.motZ);
          int k = MathHelper.f((double) f2 * this.damage);

          if (this.isCritical()) {
            k += this.random.nextInt(k / 2 + 2);
          }

          DamageSource damagesource = null;

          if (this.shooter == null) {
            damagesource = DamageSource.arrow(this, this);
          } else {
            damagesource = DamageSource.arrow(this, this.shooter);
          }

          // CraftBukkit start - Moved damage call
          if (movingobjectposition.entity.damageEntity(damagesource, k)) {
            if (this.isBurning()
                && !(movingobjectposition.entity instanceof EntityEnderman)
                && (!(movingobjectposition.entity instanceof EntityPlayer)
                    || !(this.shooter instanceof EntityPlayer)
                    || this.world
                        .pvpMode)) { // CraftBukkit - abide by pvp setting if destination is a
                                     // player
              EntityCombustByEntityEvent combustEvent =
                  new EntityCombustByEntityEvent(
                      this.getBukkitEntity(), entity.getBukkitEntity(), 5);
              org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent);

              if (!combustEvent.isCancelled()) {
                movingobjectposition.entity.setOnFire(combustEvent.getDuration());
              }
              // CraftBukkit end
            }

            // if (movingobjectposition.entity.damageEntity(damagesource, (float) k)) { //
            // CraftBukkit - moved up
            if (movingobjectposition.entity instanceof EntityLiving) {
              EntityLiving entityliving = (EntityLiving) movingobjectposition.entity;

              if (!this.world.isStatic) {
                entityliving.p(entityliving.aY() + 1);
              }

              if (this.knockbackStrength > 0) {
                f3 = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ);
                if (f3 > 0.0F) {
                  movingobjectposition.entity.g(
                      this.motX
                          * (double) this.knockbackStrength
                          * 0.6000000238418579D
                          / (double) f3,
                      0.1D,
                      this.motZ
                          * (double) this.knockbackStrength
                          * 0.6000000238418579D
                          / (double) f3);
                }
              }

              if (this.shooter != null && this.shooter instanceof EntityLiving) {
                EnchantmentManager.a(entityliving, this.shooter);
                EnchantmentManager.b((EntityLiving) this.shooter, entityliving);
              }

              if (this.shooter != null
                  && movingobjectposition.entity != this.shooter
                  && movingobjectposition.entity instanceof EntityHuman
                  && this.shooter instanceof EntityPlayer) {
                ((EntityPlayer) this.shooter)
                    .playerConnection.sendPacket(new PacketPlayOutGameStateChange(6, 0.0F));
              }
            }

            this.makeSound("random.bowhit", 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F));
            if (!(movingobjectposition.entity instanceof EntityEnderman)) {
              this.die();
            }
          } else {
            this.motX *= -0.10000000149011612D;
            this.motY *= -0.10000000149011612D;
            this.motZ *= -0.10000000149011612D;
            this.yaw += 180.0F;
            this.lastYaw += 180.0F;
            this.au = 0;
          }
        } else {
          this.d = movingobjectposition.b;
          this.e = movingobjectposition.c;
          this.f = movingobjectposition.d;
          this.g = this.world.getType(d, e, f); // CraftBukkit - Get correct block for storage
          this.h = this.world.getData(this.d, this.e, this.f);
          this.motX = (double) ((float) (movingobjectposition.pos.a - this.locX));
          this.motY = (double) ((float) (movingobjectposition.pos.b - this.locY));
          this.motZ = (double) ((float) (movingobjectposition.pos.c - this.locZ));
          f2 =
              MathHelper.sqrt(
                  this.motX * this.motX + this.motY * this.motY + this.motZ * this.motZ);
          this.locX -= this.motX / (double) f2 * 0.05000000074505806D;
          this.locY -= this.motY / (double) f2 * 0.05000000074505806D;
          this.locZ -= this.motZ / (double) f2 * 0.05000000074505806D;
          this.makeSound("random.bowhit", 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F));
          this.inGround = true;
          this.shake = 7;
          this.setCritical(false);
          if (this.g.getMaterial() != Material.AIR) {
            this.g.a(this.world, this.d, this.e, this.f, (Entity) this);
          }
        }
      }

      if (this.isCritical()) {
        for (j = 0; j < 4; ++j) {
          this.world.addParticle(
              "crit",
              this.locX + this.motX * (double) j / 4.0D,
              this.locY + this.motY * (double) j / 4.0D,
              this.locZ + this.motZ * (double) j / 4.0D,
              -this.motX,
              -this.motY + 0.2D,
              -this.motZ);
        }
      }

      this.locX += this.motX;
      this.locY += this.motY;
      this.locZ += this.motZ;
      f2 = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ);
      this.yaw = (float) (Math.atan2(this.motX, this.motZ) * 180.0D / 3.1415927410125732D);

      for (this.pitch = (float) (Math.atan2(this.motY, (double) f2) * 180.0D / 3.1415927410125732D);
          this.pitch - this.lastPitch < -180.0F;
          this.lastPitch -= 360.0F) {;
      }

      while (this.pitch - this.lastPitch >= 180.0F) {
        this.lastPitch += 360.0F;
      }

      while (this.yaw - this.lastYaw < -180.0F) {
        this.lastYaw -= 360.0F;
      }

      while (this.yaw - this.lastYaw >= 180.0F) {
        this.lastYaw += 360.0F;
      }

      this.pitch = this.lastPitch + (this.pitch - this.lastPitch) * 0.2F;
      this.yaw = this.lastYaw + (this.yaw - this.lastYaw) * 0.2F;
      float f4 = 0.99F;

      f1 = 0.05F;
      if (this.L()) {
        for (int l = 0; l < 4; ++l) {
          f3 = 0.25F;
          this.world.addParticle(
              "bubble",
              this.locX - this.motX * (double) f3,
              this.locY - this.motY * (double) f3,
              this.locZ - this.motZ * (double) f3,
              this.motX,
              this.motY,
              this.motZ);
        }

        f4 = 0.8F;
      }

      if (this.K()) {
        this.extinguish();
      }

      this.motX *= (double) f4;
      this.motY *= (double) f4;
      this.motZ *= (double) f4;
      this.motY -= (double) f1;
      this.setPosition(this.locX, this.locY, this.locZ);
      this.H();
    }
  }
Exemplo n.º 12
0
  public void e() {
    ItemStack itemstack = this.g.getItem(0);

    this.a = 0;
    int i = 0;
    byte b0 = 0;
    int j = 0;

    if (itemstack == null) {
      this.f.setItem(0, (ItemStack) null);
      this.a = 0;
    } else {
      ItemStack itemstack1 = itemstack.cloneItemStack();
      ItemStack itemstack2 = this.g.getItem(1);
      Map map = EnchantmentManager.a(itemstack1);
      boolean flag = false;
      int k =
          b0 + itemstack.getRepairCost() + (itemstack2 == null ? 0 : itemstack2.getRepairCost());

      this.l = 0;
      int l;
      int i1;
      int j1;
      int k1;
      int l1;
      Iterator iterator;
      Enchantment enchantment;

      if (itemstack2 != null) {
        flag =
            itemstack2.id == Item.ENCHANTED_BOOK.id && Item.ENCHANTED_BOOK.g(itemstack2).size() > 0;
        if (itemstack1.g() && Item.byId[itemstack1.id].a(itemstack, itemstack2)) {
          l = Math.min(itemstack1.j(), itemstack1.l() / 4);
          if (l <= 0) {
            this.f.setItem(0, (ItemStack) null);
            this.a = 0;
            return;
          }

          for (i1 = 0; l > 0 && i1 < itemstack2.count; ++i1) {
            j1 = itemstack1.j() - l;
            itemstack1.setData(j1);
            i += Math.max(1, l / 100) + map.size();
            l = Math.min(itemstack1.j(), itemstack1.l() / 4);
          }

          this.l = i1;
        } else {
          if (!flag && (itemstack1.id != itemstack2.id || !itemstack1.g())) {
            this.f.setItem(0, (ItemStack) null);
            this.a = 0;
            return;
          }

          if (itemstack1.g() && !flag) {
            l = itemstack.l() - itemstack.j();
            i1 = itemstack2.l() - itemstack2.j();
            j1 = i1 + itemstack1.l() * 12 / 100;
            int i2 = l + j1;

            k1 = itemstack1.l() - i2;
            if (k1 < 0) {
              k1 = 0;
            }

            if (k1 < itemstack1.getData()) {
              itemstack1.setData(k1);
              i += Math.max(1, j1 / 100);
            }
          }

          Map map1 = EnchantmentManager.a(itemstack2);

          iterator = map1.keySet().iterator();

          while (iterator.hasNext()) {
            j1 = ((Integer) iterator.next()).intValue();
            enchantment = Enchantment.byId[j1];
            k1 =
                map.containsKey(Integer.valueOf(j1))
                    ? ((Integer) map.get(Integer.valueOf(j1))).intValue()
                    : 0;
            l1 = ((Integer) map1.get(Integer.valueOf(j1))).intValue();
            int j2;

            if (k1 == l1) {
              ++l1;
              j2 = l1;
            } else {
              j2 = Math.max(l1, k1);
            }

            l1 = j2;
            int k2 = l1 - k1;
            boolean flag1 = enchantment.canEnchant(itemstack);

            if (this.n.abilities.canInstantlyBuild
                || itemstack.id == ItemEnchantedBook.ENCHANTED_BOOK.id) {
              flag1 = true;
            }

            Iterator iterator1 = map.keySet().iterator();

            while (iterator1.hasNext()) {
              int l2 = ((Integer) iterator1.next()).intValue();

              if (l2 != j1 && !enchantment.a(Enchantment.byId[l2])) {
                flag1 = false;
                i += k2;
              }
            }

            if (flag1) {
              if (l1 > enchantment.getMaxLevel()) {
                l1 = enchantment.getMaxLevel();
              }

              map.put(Integer.valueOf(j1), Integer.valueOf(l1));
              int i3 = 0;

              switch (enchantment.getRandomWeight()) {
                case 1:
                  i3 = 8;
                  break;

                case 2:
                  i3 = 4;

                case 3:
                case 4:
                case 6:
                case 7:
                case 8:
                case 9:
                default:
                  break;

                case 5:
                  i3 = 2;
                  break;

                case 10:
                  i3 = 1;
              }

              if (flag) {
                i3 = Math.max(1, i3 / 2);
              }

              i += i3 * k2;
            }
          }
        }
      }

      if (this.m != null
          && this.m.length() > 0
          && !this.m.equalsIgnoreCase(this.n.getLocale().c(itemstack.a()))
          && !this.m.equals(itemstack.getName())) {
        j = itemstack.g() ? 7 : itemstack.count * 5;
        i += j;
        if (itemstack.hasName()) {
          k += j / 2;
        }

        itemstack1.c(this.m);
      }

      l = 0;

      for (iterator = map.keySet().iterator(); iterator.hasNext(); k += l + k1 * l1) {
        j1 = ((Integer) iterator.next()).intValue();
        enchantment = Enchantment.byId[j1];
        k1 = ((Integer) map.get(Integer.valueOf(j1))).intValue();
        l1 = 0;
        ++l;
        switch (enchantment.getRandomWeight()) {
          case 1:
            l1 = 8;
            break;

          case 2:
            l1 = 4;

          case 3:
          case 4:
          case 6:
          case 7:
          case 8:
          case 9:
          default:
            break;

          case 5:
            l1 = 2;
            break;

          case 10:
            l1 = 1;
        }

        if (flag) {
          l1 = Math.max(1, l1 / 2);
        }
      }

      if (flag) {
        k = Math.max(1, k / 2);
      }

      this.a = k + i;
      if (i <= 0) {
        itemstack1 = null;
      }

      if (j == i && j > 0 && this.a >= 40) {
        this.h
            .getLogger()
            .info("Naming an item only, cost too high; giving discount to cap cost to 39 levels");
        this.a = 39;
      }

      if (this.a >= 40 && !this.n.abilities.canInstantlyBuild) {
        itemstack1 = null;
      }

      if (itemstack1 != null) {
        i1 = itemstack1.getRepairCost();
        if (itemstack2 != null && i1 < itemstack2.getRepairCost()) {
          i1 = itemstack2.getRepairCost();
        }

        if (itemstack1.hasName()) {
          i1 -= 9;
        }

        if (i1 < 0) {
          i1 = 0;
        }

        i1 += 2;
        itemstack1.setRepairCost(i1);
        EnchantmentManager.a(map, itemstack1);
      }

      this.f.setItem(0, itemstack1);
      this.b();
    }
  }
Exemplo n.º 13
0
  public void attack(Entity entity) {
    if (entity.k_()) {
      int i = this.inventory.a(entity);

      if (this.hasEffect(MobEffectList.INCREASE_DAMAGE)) {
        i += 3 << this.getEffect(MobEffectList.INCREASE_DAMAGE).getAmplifier();
      }

      if (this.hasEffect(MobEffectList.WEAKNESS)) {
        i -= 2 << this.getEffect(MobEffectList.WEAKNESS).getAmplifier();
      }

      int j = 0;
      int k = 0;

      if (entity instanceof EntityLiving) {
        k = EnchantmentManager.a(this.inventory, (EntityLiving) entity);
        j += EnchantmentManager.getKnockbackEnchantmentLevel(this.inventory, (EntityLiving) entity);
      }

      if (this.isSprinting()) {
        ++j;
      }

      if (i > 0 || k > 0) {
        boolean flag =
            this.fallDistance > 0.0F
                && !this.onGround
                && !this.t()
                && !this.aU()
                && !this.hasEffect(MobEffectList.BLINDNESS)
                && this.vehicle == null
                && entity instanceof EntityLiving;

        if (flag) {
          i += this.random.nextInt(i / 2 + 2);
        }

        i += k;
        boolean flag1 = entity.damageEntity(DamageSource.playerAttack(this), i);

        if (flag1) {
          if (j > 0) {
            entity.b_(
                (double) (-MathHelper.sin(this.yaw * 3.1415927F / 180.0F) * (float) j * 0.5F),
                0.1D,
                (double) (MathHelper.cos(this.yaw * 3.1415927F / 180.0F) * (float) j * 0.5F));
            this.motX *= 0.6D;
            this.motZ *= 0.6D;
            this.setSprinting(false);
          }

          if (flag) {
            this.c(entity);
          }

          if (k > 0) {
            this.d(entity);
          }

          if (i >= 18) {
            this.a((Statistic) AchievementList.E);
          }

          this.g(entity);
        }

        ItemStack itemstack = this.U();

        if (itemstack != null && entity instanceof EntityLiving) {
          itemstack.a((EntityLiving) entity, this);
          if (itemstack.count <= 0) {
            itemstack.a(this);
            this.V();
          }
        }

        if (entity instanceof EntityLiving) {
          if (entity.isAlive()) {
            this.a((EntityLiving) entity, true);
          }

          this.a(StatisticList.w, i);
          int l =
              EnchantmentManager.getFireAspectEnchantmentLevel(
                  this.inventory, (EntityLiving) entity);

          if (l > 0) {
            entity.setOnFire(l * 4);
          }
        }

        this.c(0.3F);
      }
    }
  }