cum pot utiliza itemStack în rețetă (Programare, Java, Bukkit)

zaze a intrebat.
a intrebat.

hi I’m making a plugin using 1.16 spigot api and I’m stuck trying to get an itemStack in the recipe. I was using 1.8 spigot api but when i’m relised that I was ether in need of an therd party api or making my own crafting system i chose to change from 1.8 to 1.16

Rețetă

NamespacedKey key = new NamespacedKey(this, "emerald_sword");
ShapedRecipe recipe = new ShapedRecipe(key, sword);
recipe.shape(" E ", " E ", " S ");
recipe.setIngredient('E', RecipeChoice.ExactChoice(enchantedEmerald));// part not working
recipe.setIngredient('S', Material.STICK);
Bukkit.addRecipe(recipe);

Sabie de smarald

ItemStack sword = new ItemStack( Material.DIAMOND_SWORD );
ItemMeta IM = sword.getItemMeta();
IM.setDisplayName(ChatColor.GREEN + "Emerald Sword" );
sword.setItemMeta( IM );
sword.addEnchantment( Enchantment.DAMAGE_ALL, 5 );

Smarald fermecat

ItemStack enchantedEmerald = new ItemStack( Material.EMERALD );
ItemMeta EEM = enchantedEmerald.getItemMeta();
EEM.setDisplayName("enchanted Emerald");
ArrayList<String> lore = new ArrayList<String>();
lore.add("enchanted Emeralds is an rare material");
EEM.setLore(lore);
enchantedEmerald.setItemMeta(EEM);

Ordinea este sabia de smarald, smaraldul fermecat și rețeta.

cum pot folosi itemStack într-o rețetă

1 răspunsuri
BigPouley

Puteți folosi acest lucru : https://gist.github.com/MrMaurice211/6b2f8d0909900efe3f4383030ea781e6și acest lucru ar trebui să funcționeze:

ShapedRegister recipe = new ShapedRegister(ItemStack);
recipe.shape(" E ", " E ", " S ");
recipe.setIngredient("E", RecipeChoice.ExactChoice(enchantedEmerald));
recipe.setIngredient("S", Material.STICK);
recipe.register();

Sursa : https://www.spigotmc.org/threads/spigot-recipe-with-itemstack.284800/

Tags:,