public static ItemStack createPotion(
      PotionType type, int level, boolean splash, boolean extended, int amount) {
    Potion pot = new Potion(type, level);
    pot.setSplash(splash);
    if (extended) pot.setHasExtendedDuration(true);

    return pot.toItemStack(amount);
  }
Esempio n. 2
0
  private ItemStack[] getItemss() {
    Potion pot1 = new Potion(PotionType.INSTANT_DAMAGE, 2);
    pot1.setSplash(true);
    ItemStack itempot1 = pot1.toItemStack(1);

    Potion pot2 = new Potion(PotionType.POISON, 2);
    pot2.setSplash(true);
    ItemStack itempot2 = pot2.toItemStack(1);

    Potion pot3 = new Potion(PotionType.WEAKNESS, 2);
    pot3.setSplash(true);
    pot3.setHasExtendedDuration(true);
    ItemStack itempot3 = pot3.toItemStack(1);

    ItemStack[] is = {itempot1, itempot2, itempot3};
    return is;
  }
Esempio n. 3
0
 public Potion splash() {
   setSplash(true);
   return this;
 }
Esempio n. 4
0
  public void OmplirCofre(Block blk) {
    Chest chest = (Chest) blk.getState();
    Inventory inv = chest.getInventory();
    inv.clear();
    // inv.clear();
    int maxN = Utils.NombreEntre(4, 9);
    int n = 0;

    while (n < maxN) {
      if (Utils.Possibilitat(4)) {
        inv.addItem(new ItemStack(Material.DIAMOND, 1));
      }
      if (Utils.Possibilitat(8)) {
        inv.addItem(new ItemStack(Material.GOLDEN_APPLE, 1));
      }
      if (Utils.Possibilitat(2)) {
        inv.addItem(new ItemStack(Material.GOLDEN_APPLE, 1, (short) 1));
      }
      if (Utils.Possibilitat(12)) {
        inv.addItem(new ItemStack(Material.IRON_INGOT, 1));
      }
      if (Utils.Possibilitat(5)) {
        inv.addItem(new ItemStack(Material.GOLD_INGOT, 1));
      }
      if (Utils.Possibilitat(3)) {
        inv.addItem(new ItemStack(Material.ENDER_PEARL, 1));
      }
      if (Utils.Possibilitat(4)) {
        Material hoe = Material.WOOD_HOE;
        if (Utils.Possibilitat(35)) {
          hoe = Material.GOLD_HOE;
        }
        if (Utils.Possibilitat(15)) {
          hoe = Material.STONE_HOE;
        }
        if (Utils.Possibilitat(10)) {
          hoe = Material.IRON_HOE;
        }
        if (Utils.Possibilitat(8)) {
          hoe = Material.DIAMOND_HOE;
        }

        inv.addItem(
            Utils.setItemNameAndLore(
                new ItemStack(hoe, 1),
                getBridgeToolName(),
                "Col·loca automàticament els blocs formant un passadís"));
      }
      //			if(Utils.Possibilitat(2)){
      //				inv.addItem(new ItemStack(Material.TNT, 1));
      //			}
      if (Utils.Possibilitat(3)) {
        ItemStack item = new ItemStack(Material.GOLD_LEGGINGS, 1);
        item.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, Utils.NombreEntre(1, 5));
        inv.addItem(item);
      }
      if (Utils.Possibilitat(3)) {
        ItemStack item = new ItemStack(Material.GOLD_CHESTPLATE, 1);
        item.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, Utils.NombreEntre(1, 5));
        item.addUnsafeEnchantment(Enchantment.THORNS, Utils.NombreEntre(1, 3));
        inv.addItem(item);
      }
      if (Utils.Possibilitat(3)) {
        ItemStack item = new ItemStack(Material.GOLD_BOOTS, 1);
        item.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, Utils.NombreEntre(1, 5));
        item.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, Utils.NombreEntre(1, 8));
        inv.addItem(item);
      }
      if (Utils.Possibilitat(3)) {
        ItemStack item = new ItemStack(Material.IRON_HELMET, 1);
        item.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, Utils.NombreEntre(1, 7));
        inv.addItem(item);
      }
      // Pocions
      if (Utils.Possibilitat(5)) {
        ItemStack item = new ItemStack(Material.POTION, Utils.NombreEntre(1, 4));
        Potion pot =
            new Potion(
                1); // The constructor calls for an (int name), but I'm not sure what that is... I
                    // tried 1 and it works fine.
        pot.setType(PotionType.INSTANT_HEAL);
        pot.setLevel(Utils.NombreEntre(1, 2));
        pot.setSplash(true);
        pot.apply(item);
        inv.addItem(item);
      }
      if (Utils.Possibilitat(4)) {
        ItemStack item = new ItemStack(Material.POTION, 1);
        Potion pot =
            new Potion(
                1); // The constructor calls for an (int name), but I'm not sure what that is... I
                    // tried 1 and it works fine.
        pot.setType(PotionType.POISON);
        pot.setLevel(Utils.NombreEntre(1, 2));
        pot.setSplash(true);
        pot.apply(item);
        inv.addItem(item);
      }
      if (Utils.Possibilitat(3)) {
        ItemStack item = new ItemStack(Material.POTION, 1);
        Potion pot =
            new Potion(
                1); // The constructor calls for an (int name), but I'm not sure what that is... I
                    // tried 1 and it works fine.
        pot.setType(PotionType.INSTANT_DAMAGE);
        pot.setLevel(2);
        pot.setSplash(true);
        pot.apply(item);
        inv.addItem(item);
      }
      if (Utils.Possibilitat(3)) {
        ItemStack item = new ItemStack(Material.POTION, 1);
        Potion pot =
            new Potion(
                1); // The constructor calls for an (int name), but I'm not sure what that is... I
                    // tried 1 and it works fine.
        pot.setType(PotionType.STRENGTH);
        pot.setLevel(Utils.NombreEntre(1, 2));
        pot.setSplash(true);
        pot.apply(item);
        inv.addItem(item);
      }
      n = 0;
      for (ItemStack i : inv.getContents()) {
        if (i != null) {
          n++;
        }
      }
    }
  }