Advertisement
Ruslan_Isaev

nya

Jan 17th, 2022
892
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.58 KB | None | 0 0
  1. private static ItemStack generatePotion(PotionType effect, int i) {
  2.         ItemStack potion = new ItemStack(Material.POTION);
  3.         PotionMeta pm = (PotionMeta) potion.getItemMeta();
  4.  
  5.         pm.setBasePotionData(new PotionData(effect, false, i == 2));
  6.  
  7.         potion.setItemMeta(pm);
  8.         return potion;
  9.     }
  10.  
  11.     /**
  12.      *
  13.      * @param frameType - тип рамки. {@link Material}.ITEM_FRAME или
  14.      *                  {@link Material}.GLOW_ITEM_FRAME
  15.      */
  16.     @SuppressWarnings("unused")
  17.     private void addInvisibleItemFrameRecipe(Material frameType) {
  18.         ItemStack potion = generatePotion(PotionType.INVISIBILITY, 0);
  19.         @SuppressWarnings("deprecation")
  20.         MaterialData potionData = potion.getData();
  21.  
  22.         ItemStack itemFrame = new ItemStack(frameType);
  23.         ItemMeta frameMeta = itemFrame.getItemMeta();
  24.         frameMeta.setDisplayName(ChatColor.GOLD + "Невидимая рамка");
  25.  
  26.         List<String> lore = new ArrayList<>();
  27.         lore.add(ChatColor.AQUA + "Mskatau няшка");
  28.  
  29.         frameMeta.setLore(lore);
  30.         NamespacedKey IS_INVISIBLE_KEY = new NamespacedKey(this, "invisible");
  31.         frameMeta.getPersistentDataContainer().set(IS_INVISIBLE_KEY, PersistentDataType.BYTE, (byte) 1);
  32.         itemFrame.setItemMeta(frameMeta);
  33.         itemFrame.setAmount(8);
  34.  
  35.         NamespacedKey frameKey = new NamespacedKey(this,
  36.                 frameType.equals(Material.ITEM_FRAME) ? "invisibleframe" : "invisibleglowframe");
  37.         ShapedRecipe frameRecipe = new ShapedRecipe(frameKey, itemFrame);
  38.  
  39.         frameRecipe.shape("FFF", "FPF", "FFF");
  40.         frameRecipe.setIngredient('F', frameType);
  41.         frameRecipe.setIngredient('P', potionData);
  42.         Bukkit.addRecipe(frameRecipe);
  43.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement