Пример #1
0
  public void setLeveledArmor() {
    EntityEquipment equipment = this.getEquipment();
    int count = level;
    equipment.setChestplate(new ItemStack(Armor.getBestChestplate(count / 2).mat));
    count -= Armor.getBestChestplate(count).points;
    equipment.setLeggings(new ItemStack(Armor.getBestLeggings(count / 2).mat));
    count -= Armor.getBestLeggings(count).points;
    equipment.setHelmet(new ItemStack(Armor.getBestHelmet(count).mat));
    count -= Armor.getBestHelmet(count).points;
    equipment.setBoots(new ItemStack(Armor.getBestBoots(count).mat));
    count -= Armor.getBestBoots(count).points;

    equipment.setChestplateDropChance(0F);
    equipment.setLeggingsDropChance(0F);
    equipment.setHelmetDropChance(0F);
    equipment.setBootsDropChance(0F);
  }
  @SuppressWarnings("deprecation")
  public void setDefaultInventory(LivingEntity e) {
    EntityEquipment ee = e.getEquipment();

    if (ee == null) {
      return;
    }

    switch (e.getType()) {
      case SKELETON:
        Skeleton sk = ((Skeleton) e);
        if (sk.getSkeletonType().getId() == SkeletonType.WITHER.getId()) {
          ee.setItemInHand(new ItemStack(Material.STONE_SWORD));
        } else {
          ee.setItemInHand(new ItemStack(Material.BOW));
        }
        break;
      case PIG_ZOMBIE:
        ee.setItemInHand(new ItemStack(Material.GOLD_SWORD));
        break;
      default:
        break;
    }
  }
  public void setInventory(LivingEntity entity, ISInventory data) {

    EntityEquipment ee = entity.getEquipment();

    if (ee == null) {
      return;
    }

    if (!data.hasHand()) {
      setDefaultInventory(entity);
    } else {
      ee.setItemInHand(data.getHand());
    }

    ee.setArmorContents(data.getArmor());

    List<ISItemStack> array = data.getMainInventoryISItemStacks();
    ee.setItemInHandDropChance(array.get(0).getDropChance() / 100.0f);
    ee.setBootsDropChance(array.get(1).getDropChance() / 100.0f);
    ee.setLeggingsDropChance(array.get(2).getDropChance() / 100.0f);
    ee.setChestplateDropChance(array.get(3).getDropChance() / 100.0f);
    ee.setHelmetDropChance(array.get(4).getDropChance() / 100.0f);
  }
Пример #4
0
 public static void RemoveHelmet(LivingEntity paramLivingEntity) {
   EntityEquipment localEntityEquipment = paramLivingEntity.getEquipment();
   localEntityEquipment.setHelmet(null);
 }
Пример #5
0
 public static void setItemInHand(
     LivingEntity paramLivingEntity, org.bukkit.inventory.ItemStack paramItemStack) {
   EntityEquipment localEntityEquipment = paramLivingEntity.getEquipment();
   localEntityEquipment.setItemInHand(paramItemStack);
 }
Пример #6
0
    public List<LivingEntity> spawn(Location location, Player player) {
      List<LivingEntity> entities = new ArrayList<LivingEntity>(this.num);
      World world = location.getWorld();

      for (int num = 0; num < this.num; num++) {
        if (spread > 0) {
          int minX = location.getBlockX() - spread / 2;
          int minY = location.getBlockY() - spread / 2;
          int minZ = location.getBlockZ() - spread / 2;
          int maxX = location.getBlockX() + spread / 2;
          int maxY = location.getBlockY() + spread / 2;
          int maxZ = location.getBlockZ() + spread / 2;

          int tries = spread * 10;
          boolean found = false;

          while (tries-- > 0) {
            int x = minX + RecipeManager.random.nextInt(maxX - minX);
            int z = minZ + RecipeManager.random.nextInt(maxZ - minZ);
            int y = 0;

            for (y = maxY; y >= minY; y--) {
              if (!Material.getMaterial(world.getBlockTypeIdAt(x, y, z)).isSolid()) {
                found = true;
                break;
              }
            }

            if (found) {
              location.setX(x);
              location.setY(y);
              location.setZ(z);
              break;
            }
          }

          if (!found) {
            Messages.debug(
                "Couldn't find suitable location after " + (spread * 10) + " tries, using center.");
          }

          location.add(0.5, 0, 0.5);
        }

        LivingEntity ent = (LivingEntity) world.spawnEntity(location, type);
        entities.add(ent);

        if (!noEffect) {
          world.playEffect(location, Effect.MOBSPAWNER_FLAMES, 20);
        }

        if (name != null) {
          ent.setCustomName(name);
          ent.setCustomNameVisible(noHideName);
        }

        if (onFire > 0.0f) {
          ent.setFireTicks((int) Math.ceil(onFire * 20.0));
        }

        if (pickup != null) {
          ent.setCanPickupItems(pickup);
        }

        if (pet && ent instanceof Tameable) {
          Tameable npc = (Tameable) ent;
          npc.setOwner(player);
          npc.setTamed(true);
        }

        if (ent instanceof Wolf) {
          Wolf npc = (Wolf) ent;

          if (pet) {
            if (noSit) {
              npc.setSitting(false);
            }

            if (color != null) {
              npc.setCollarColor(color);
            }
          } else if (angry) {
            npc.setAngry(true);
          }
        }

        if (ent instanceof Ocelot) {
          Ocelot npc = (Ocelot) ent;

          if (pet && noSit) {
            npc.setSitting(false);
          }

          if (cat != null) {
            npc.setCatType(cat);
          }
        }

        if (hp > 0) {
          ent.setHealth(hp);

          if (maxHp > 0) {
            ent.setMaxHealth(maxHp);
          }
        }

        if (ent instanceof Ageable) {
          Ageable npc = (Ageable) ent;

          if (baby) {
            npc.setBaby();
          }

          if (ageLock) {
            npc.setAgeLock(true);
          }

          if (noBreed) {
            npc.setBreed(false);
          }
        }

        if (saddle && ent instanceof Pig) {
          Pig npc = (Pig) ent;
          npc.setSaddle(true);

          if (mount) {
            npc.setPassenger(player);
          }
        }

        if (ent instanceof Zombie) {
          Zombie npc = (Zombie) ent;

          if (baby) {
            npc.setBaby(true);
          }

          if (zombieVillager) {
            npc.setVillager(true);
          }
        }

        if (villager != null && ent instanceof Villager) {
          Villager npc = (Villager) ent;
          npc.setProfession(villager);
        }

        if (poweredCreeper && ent instanceof Creeper) {
          Creeper npc = (Creeper) ent;
          npc.setPowered(true);
        }

        if (playerIronGolem && ent instanceof IronGolem) {
          IronGolem npc = (IronGolem) ent;
          npc.setPlayerCreated(true); // TODO what exacly does this do ?
        }

        if (shearedSheep && ent instanceof Sheep) {
          Sheep npc = (Sheep) ent;
          npc.setSheared(true);
        }

        if (color != null && ent instanceof Colorable) {
          Colorable npc = (Colorable) ent;
          npc.setColor(color);
        }

        if (skeleton != null && ent instanceof Skeleton) {
          Skeleton npc = (Skeleton) ent;
          npc.setSkeletonType(skeleton);
        }

        if (target && ent instanceof Creature) {
          Creature npc = (Creature) ent;
          npc.setTarget(player);
        }

        if (pigAnger > 0 && ent instanceof PigZombie) {
          PigZombie npc = (PigZombie) ent;
          npc.setAnger(pigAnger);
        }

        if (hit) {
          ent.damage(0, player);
          ent.setVelocity(new Vector());
        }

        if (!potions.isEmpty()) {
          for (PotionEffect effect : potions) {
            ent.addPotionEffect(effect, true);
          }
        }

        ent.setRemoveWhenFarAway(!noRemove);

        EntityEquipment eq = ent.getEquipment();

        for (int i = 0; i < equip.length; i++) {
          ItemStack item = equip[i];

          if (item == null) {
            continue;
          }

          switch (i) {
            case 0:
              eq.setHelmet(item);
              eq.setHelmetDropChance(drop[i]);
              break;

            case 1:
              eq.setChestplate(item);
              eq.setChestplateDropChance(drop[i]);
              break;

            case 2:
              eq.setLeggings(item);
              eq.setLeggingsDropChance(drop[i]);
              break;

            case 3:
              eq.setBoots(item);
              eq.setBootsDropChance(drop[i]);
              break;

            case 4:
              {
                if (ent instanceof Enderman) {
                  Enderman npc = (Enderman) ent;
                  npc.setCarriedMaterial(item.getData());
                } else {
                  eq.setItemInHand(item);
                  eq.setItemInHandDropChance(drop[i]);
                }

                break;
              }
          }
        }
      }

      return entities;
    }