Пример #1
0
  public boolean m(Entity entity) {
    float f = (float) this.getAttributeInstance(GenericAttributes.e).getValue();
    int i = 0;

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

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

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

      int j = EnchantmentManager.getFireAspectEnchantmentLevel(this);

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

      if (entity instanceof EntityLiving) {
        EnchantmentManager.a((EntityLiving) entity, (Entity) this);
      }

      EnchantmentManager.b(this, entity);
    }

    return flag;
  }
Пример #2
0
  /**
   * WASD Control.
   *
   * @param sideMot
   * @param forMot
   */
  @Override
  public void g(float sideMot, float forMot) {
    if (!CustomEntities.customEntities.contains(this)) {
      super.g(sideMot, forMot);
      return;
    }
    if (getSize() != 3) setSize(3);
    if (this.passenger != null
        && this.passenger instanceof EntityHuman
        && CustomEntities.customEntities.contains(this)) {
      this.lastYaw = this.yaw = this.passenger.yaw;
      this.pitch = this.passenger.pitch * 0.5F;
      this.setYawPitch(this.yaw, this.pitch); // Update the pitch and yaw
      this.aI = this.aG = this.yaw;
      sideMot = ((EntityLiving) this.passenger).aZ * 0.5F;
      forMot = ((EntityLiving) this.passenger).ba;

      Field jump = null; // Jumping
      try {
        jump = EntityLiving.class.getDeclaredField("aY");
      } catch (NoSuchFieldException | SecurityException e1) {
        e1.printStackTrace();
      }
      jump.setAccessible(true);

      if (jump != null && BlockUtils.isOnGround(this.getBukkitEntity())) {
        try {
          if (jump.getBoolean(this.passenger)) {
            double jumpHeight = 0.3D;
            this.motY = jumpHeight;
          }
        } catch (IllegalAccessException e) {
          e.printStackTrace();
        }
      }

      this.S = 1.0F;
      this.aK = this.yaw;
      if (!this.world.isClientSide) {
        this.k(0.2f);

        if (bM()) {
          if (V()) {
            double d0 = locY;
            float f3 = 0.8F;
            float f4 = 0.02F;
            float f2 = EnchantmentManager.b(this);
            if (f2 > 3.0F) {
              f2 = 3.0F;
            }

            if (f2 > 0.0F) {
              f3 += (0.5460001F - f3) * f2 / 3.0F;
              f4 += (bI() * 1.0F - f4) * f2 / 3.0F;
            }

            a(sideMot, forMot, f4);
            move(motX, motY, motZ);
            motX *= f3;
            motY *= 0.800000011920929D;
            motZ *= f3;
            motY -= 0.02D;
            if ((positionChanged) && (c(motX, motY + 0.6000000238418579D - locY + d0, motZ)))
              motY = 0.300000011920929D;
          } else if (ab()) {
            double d0 = locY;
            a(sideMot, forMot, 0.02F);
            move(motX, motY, motZ);
            motX *= 0.5D;
            motY *= 0.5D;
            motZ *= 0.5D;
            motY -= 0.02D;
            if ((positionChanged) && (c(motX, motY + 0.6000000238418579D - locY + d0, motZ)))
              motY = 0.300000011920929D;
          } else {
            float f5 =
                world
                        .getType(
                            new BlockPosition(
                                MathHelper.floor(locX),
                                MathHelper.floor(getBoundingBox().b) - 1,
                                MathHelper.floor(locZ)))
                        .getBlock()
                        .frictionFactor
                    * 0.91F;

            float f6 = 0.1627714F / (f5 * f5 * f5);
            float f3 = bI() * f6;

            a(sideMot, forMot, f3);
            f5 =
                world
                        .getType(
                            new BlockPosition(
                                MathHelper.floor(locX),
                                MathHelper.floor(getBoundingBox().b) - 1,
                                MathHelper.floor(locZ)))
                        .getBlock()
                        .frictionFactor
                    * 0.91F;

            if (k_()) {
              float f4 = 0.15F;
              motX = MathHelper.a(motX, -f4, f4);
              motZ = MathHelper.a(motZ, -f4, f4);
              fallDistance = 0.0F;
              if (motY < -0.15D) {
                motY = -0.15D;
              }

              if (motY < 0.0D) {
                motY = 0.0D;
              }
            }

            move(motX, motY, motZ);
            if ((positionChanged) && (k_())) {
              motY = 0.2D;
            }

            if ((world.isClientSide)
                && ((!world.isLoaded(new BlockPosition((int) locX, 0, (int) locZ)))
                    || (!world
                        .getChunkAtWorldCoords(new BlockPosition((int) locX, 0, (int) locZ))
                        .o()))) {
              if (locY > 0.0D) motY = -0.1D;
              else motY = 0.0D;
            } else {
              motY += 0D;
            }

            motY *= 0.9800000190734863D;
            motX *= f5;
            motZ *= f5;
          }
        }

        ay = az;
        double d0 = locX - lastX;
        double d1 = locZ - lastZ;

        float f2 = MathHelper.sqrt(d0 * d0 + d1 * d1) * 4.0F;
        if (f2 > 1.0F) {
          f2 = 1.0F;
        }

        az += (f2 - az) * 0.4F;
        aA += az;

        super.g(sideMot, forMot);
      }

      this.ay = this.az;
      double d0 = this.locX - this.lastX;
      double d1 = this.locZ - this.lastZ;
      float f4 = MathHelper.sqrt(d0 * d0 + d1 * d1) * 4.0F;
      if (f4 > 1.0F) {
        f4 = 1.0F;
      }

      this.az += (f4 - this.az) * 0.4F;
      this.aA += this.az;
    } else {
      this.S = 0.5F;
      this.aK = 0.02F;
      super.g(sideMot, forMot);
    }
  }
  private void t(int k) {
    if (bu != null) bA = MathHelper.c(bu.size()) * 0.2F;
    else bA = 0.0F;
    MerchantRecipeList merchantrecipelist = new MerchantRecipeList();
    switch (getProfession()) {
      case 0: // '\0'
        a(merchantrecipelist, Items.WHEAT, random, p(0.9F));
        a(merchantrecipelist, Item.getItemOf(Blocks.WOOL), random, p(0.5F));
        a(merchantrecipelist, Items.RAW_CHICKEN, random, p(0.5F));
        a(merchantrecipelist, Items.COOKED_FISH, random, p(0.4F));
        b(merchantrecipelist, Items.BREAD, random, p(0.9F));
        b(merchantrecipelist, Items.MELON, random, p(0.3F));
        b(merchantrecipelist, Items.APPLE, random, p(0.3F));
        b(merchantrecipelist, Items.COOKIE, random, p(0.3F));
        b(merchantrecipelist, Items.SHEARS, random, p(0.3F));
        b(merchantrecipelist, Items.FLINT_AND_STEEL, random, p(0.3F));
        b(merchantrecipelist, Items.COOKED_CHICKEN, random, p(0.3F));
        b(merchantrecipelist, Items.ARROW, random, p(0.5F));
        if (random.nextFloat() < p(0.5F))
          merchantrecipelist.add(
              new MerchantRecipe(
                  new ItemStack(Blocks.GRAVEL, 10),
                  new ItemStack(Items.EMERALD),
                  new ItemStack(Items.FLINT, 4 + random.nextInt(2), 0)));
        break;

      case 4: // '\004'
        a(merchantrecipelist, Items.COAL, random, p(0.7F));
        a(merchantrecipelist, Items.PORK, random, p(0.5F));
        a(merchantrecipelist, Items.RAW_BEEF, random, p(0.5F));
        b(merchantrecipelist, Items.SADDLE, random, p(0.1F));
        b(merchantrecipelist, Items.LEATHER_CHESTPLATE, random, p(0.3F));
        b(merchantrecipelist, Items.LEATHER_BOOTS, random, p(0.3F));
        b(merchantrecipelist, Items.LEATHER_HELMET, random, p(0.3F));
        b(merchantrecipelist, Items.LEATHER_LEGGINGS, random, p(0.3F));
        b(merchantrecipelist, Items.GRILLED_PORK, random, p(0.3F));
        b(merchantrecipelist, Items.COOKED_BEEF, random, p(0.3F));
        break;

      case 3: // '\003'
        a(merchantrecipelist, Items.COAL, random, p(0.7F));
        a(merchantrecipelist, Items.IRON_INGOT, random, p(0.5F));
        a(merchantrecipelist, Items.GOLD_INGOT, random, p(0.5F));
        a(merchantrecipelist, Items.DIAMOND, random, p(0.5F));
        b(merchantrecipelist, Items.IRON_SWORD, random, p(0.5F));
        b(merchantrecipelist, Items.DIAMOND_SWORD, random, p(0.5F));
        b(merchantrecipelist, Items.IRON_AXE, random, p(0.3F));
        b(merchantrecipelist, Items.DIAMOND_AXE, random, p(0.3F));
        b(merchantrecipelist, Items.IRON_PICKAXE, random, p(0.5F));
        b(merchantrecipelist, Items.DIAMOND_PICKAXE, random, p(0.5F));
        b(merchantrecipelist, Items.IRON_SPADE, random, p(0.2F));
        b(merchantrecipelist, Items.DIAMOND_SPADE, random, p(0.2F));
        b(merchantrecipelist, Items.IRON_HOE, random, p(0.2F));
        b(merchantrecipelist, Items.DIAMOND_HOE, random, p(0.2F));
        b(merchantrecipelist, Items.IRON_BOOTS, random, p(0.2F));
        b(merchantrecipelist, Items.DIAMOND_BOOTS, random, p(0.2F));
        b(merchantrecipelist, Items.IRON_HELMET, random, p(0.2F));
        b(merchantrecipelist, Items.DIAMOND_HELMET, random, p(0.2F));
        b(merchantrecipelist, Items.IRON_CHESTPLATE, random, p(0.2F));
        b(merchantrecipelist, Items.DIAMOND_CHESTPLATE, random, p(0.2F));
        b(merchantrecipelist, Items.IRON_LEGGINGS, random, p(0.2F));
        b(merchantrecipelist, Items.DIAMOND_LEGGINGS, random, p(0.2F));
        b(merchantrecipelist, Items.CHAINMAIL_BOOTS, random, p(0.1F));
        b(merchantrecipelist, Items.CHAINMAIL_HELMET, random, p(0.1F));
        b(merchantrecipelist, Items.CHAINMAIL_CHESTPLATE, random, p(0.1F));
        b(merchantrecipelist, Items.CHAINMAIL_LEGGINGS, random, p(0.1F));
        break;

      case 1: // '\001'
        a(merchantrecipelist, Items.PAPER, random, p(0.8F));
        a(merchantrecipelist, Items.BOOK, random, p(0.8F));
        a(merchantrecipelist, Items.WRITTEN_BOOK, random, p(0.3F));
        b(merchantrecipelist, Item.getItemOf(Blocks.BOOKSHELF), random, p(0.8F));
        b(merchantrecipelist, Item.getItemOf(Blocks.GLASS), random, p(0.2F));
        b(merchantrecipelist, Items.COMPASS, random, p(0.2F));
        b(merchantrecipelist, Items.WATCH, random, p(0.2F));
        if (random.nextFloat() < p(0.07F)) {
          Enchantment enchantment = Enchantment.c[random.nextInt(Enchantment.c.length)];
          int i1 =
              MathHelper.nextInt(random, enchantment.getStartLevel(), enchantment.getMaxLevel());
          ItemStack itemstack = Items.ENCHANTED_BOOK.a(new EnchantmentInstance(enchantment, i1));
          int k1 = 2 + random.nextInt(5 + i1 * 10) + 3 * i1;
          merchantrecipelist.add(
              new MerchantRecipe(
                  new ItemStack(Items.BOOK), new ItemStack(Items.EMERALD, k1), itemstack));
        }
        break;

      case 2: // '\002'
        b(merchantrecipelist, Items.EYE_OF_ENDER, random, p(0.3F));
        b(merchantrecipelist, Items.EXP_BOTTLE, random, p(0.2F));
        b(merchantrecipelist, Items.REDSTONE, random, p(0.4F));
        b(merchantrecipelist, Item.getItemOf(Blocks.GLOWSTONE), random, p(0.3F));
        Item aitem[] = {
          Items.IRON_SWORD,
          Items.DIAMOND_SWORD,
          Items.IRON_CHESTPLATE,
          Items.DIAMOND_CHESTPLATE,
          Items.IRON_AXE,
          Items.DIAMOND_AXE,
          Items.IRON_PICKAXE,
          Items.DIAMOND_PICKAXE
        };
        Item aitem1[] = aitem;
        int j1 = aitem1.length;
        for (int l1 = 0; l1 < j1; l1++) {
          Item item = aitem1[l1];
          if (random.nextFloat() < p(0.05F))
            merchantrecipelist.add(
                new MerchantRecipe(
                    new ItemStack(item, 1, 0),
                    new ItemStack(Items.EMERALD, 2 + random.nextInt(3), 0),
                    EnchantmentManager.a(
                        random, new ItemStack(item, 1, 0), 5 + random.nextInt(15))));
        }

        break;
    }
    if (merchantrecipelist.isEmpty()) a(merchantrecipelist, Items.GOLD_INGOT, random, 1.0F);
    Collections.shuffle(merchantrecipelist);
    if (bu == null) bu = new MerchantRecipeList();
    for (int l = 0; l < k && l < merchantrecipelist.size(); l++)
      bu.a((MerchantRecipe) merchantrecipelist.get(l));
  }
Пример #4
0
 public void #FIELD_CONTAINERANVIL_4#()
 {
     ItemStack itemstack = VAnvil.#FIELD_CONTAINERANVIL_1#(this).getItem(0);
     #FIELD_CONTAINERANVIL_5# = 0;
     int i = 0;
     byte b0 = 0;
     int j = 0;
     if(itemstack == null)
     {
         getInv("#FIELD_CONTAINERANVIL_2#").setItem(0, null);
         #FIELD_CONTAINERANVIL_5# = 0;
     }
     else
     {
         ItemStack itemstack1 = itemstack.cloneItemStack();
         ItemStack itemstack2 = VAnvil.#FIELD_CONTAINERANVIL_1#(this).getItem(1);
         Map map = EnchantmentManager.#FIELD_ENCHANTMENTMANAGER_3#(itemstack1);
         boolean flag = false;
         int k = b0 + itemstack.getRepairCost() + (itemstack2 == null ? 0 : itemstack2.getRepairCost());
         _exp = 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.#FIELD_ITEMENCHANTEDBOOK_2#(itemstack2).size() > 0;
             if(itemstack1.#FIELD_ITEM_6#() && Item.byId[itemstack1.id].a(itemstack, itemstack2))
             {
                 l = Math.min(itemstack1.#FIELD_ITEMSTACK_5#(), itemstack1.#FIELD_ITEMSTACK_6#() / 4);
                 if(l <= 0)
                 {
                     getInv("#FIELD_CONTAINERANVIL_2#").setItem(0, null);
                     #FIELD_CONTAINERANVIL_5# = 0;
                     return;
                 }
                 for(i1 = 0; l > 0 && i1 < itemstack2.count; ++i1)
                 {
                     j1 = itemstack1.#FIELD_ITEMSTACK_5#() - l;
                     itemstack1.setData(j1);
                     i += Math.max(1, l / 100) + map.size();
                     l = Math.min(itemstack1.#FIELD_ITEMSTACK_5#(), itemstack1.#FIELD_ITEMSTACK_6#() / 4);
                 }
                 _exp = i1;
             }
             else
             {
                 if(!flag && (itemstack1.id != itemstack2.id || !itemstack1.#FIELD_ITEM_6#()))
                 {
                     getInv("#FIELD_CONTAINERANVIL_2#").setItem(0, null);
                     #FIELD_CONTAINERANVIL_5# = 0;
                     return;
                 }
                 if(itemstack1.#FIELD_ITEM_6#() && !flag)
                 {
                     l = itemstack.#FIELD_ITEMSTACK_6#() - itemstack.#FIELD_ITEMSTACK_5#();
                     i1 = itemstack2.#FIELD_ITEMSTACK_6#() - itemstack2.#FIELD_ITEMSTACK_5#();
                     j1 = i1 + itemstack1.#FIELD_ITEMSTACK_6#() * 12 / 100;
                     int i2 = l + j1;
                     k1 = itemstack1.#FIELD_ITEMSTACK_6#() - i2;
                     if(k1 < 0)
                     {
                         k1 = 0;
                     }
                     if(k1 < itemstack1.getData())
                     {
                         itemstack1.setData(k1);
                         i += Math.max(1, j1 / 100);
                     }
                 }
                 Map map1 = EnchantmentManager.#FIELD_ENCHANTMENTMANAGER_3#(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(playerFree(_player))
                     {
                         flag1 = true;
                     }
                     Iterator iterator1 = map.keySet().iterator();
                     while(iterator1.hasNext())
                     {
                         int l2 = ((Integer)iterator1.next()).intValue();
                         if(l2 != j1 && !enchantment.#FIELD_ENCHANTMENT_1#(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;
                         }
                         i += i3 * k2;
                     }
                 }
             }
         }
         if(_itemName != null && !_itemName.equalsIgnoreCase(itemstack.#FIELD_ITEMSTACK_7#()) && _itemName.length() > 0)
         {
             j = itemstack.#FIELD_ITEM_6#() ? 7 : itemstack.count * 5;
             i += j;
             if(itemstack.#FIELD_ITEMSTACK_8#())
             {
                 k += j / 2;
             }
             itemstack1.#FIELD_ITEMSTACK_9#(_itemName);
         }
         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);
         }
         #FIELD_CONTAINERANVIL_5# = k + i;
         if(i <= 0)
         {
             itemstack1 = null;
         }
         if(j == i && j > 0 && #FIELD_CONTAINERANVIL_5# >= 40)
         {
             #FIELD_CONTAINERANVIL_5# = 39;
         }
         if(#FIELD_CONTAINERANVIL_5# >= 40 && !playerFree(_player))
         {
             itemstack1 = null;
         }
         if(itemstack1 != null)
         {
             i1 = itemstack1.getRepairCost();
             if(itemstack2 != null && i1 < itemstack2.getRepairCost())
             {
                 i1 = itemstack2.getRepairCost();
             }
             if(itemstack1.#FIELD_ITEMSTACK_8#())
             {
                 i1 -= 9;
             }
             if(i1 < 0)
             {
                 i1 = 0;
             }
             i1 += 2;
             itemstack1.setRepairCost(i1);
             EnchantmentManager.#FIELD_ENCHANTMENTMANAGER_4#(map, itemstack1);
         }
         getInv("#FIELD_CONTAINERANVIL_2#").setItem(0, itemstack1);
         #FIELD_CONTAINER_9#();
     }
 }