Hey, I want to create a Villager custom trade for Potion of jump boost level 2 for 2 emeralds but when i'm creating the potion it has too many tags and is not ok with the "normal" jump boost potion level 2 Code: ItemStack potion = new ItemStack(Material.POTION); PotionMeta meta = (PotionMeta) potion.getItemMeta(); PotionEffect pe = new PotionEffect(PotionEffectType.JUMP, 1800, 1); meta.addCustomEffect(pe, true); meta.setColor(Color.LIME); meta.setDisplayName("§r§fPotion of Leaping"); potion.setItemMeta(meta); the normal potion has 1 NBT tags and the one i create has 4
no it's not working, i need to create an itemstack of jump boost potion level 2 but with only 1 tag (i think)
@Xhork I'm pretty sure the amount of tags doesn't matter, as long as it has the tags you want. What is not working?
when i want to trade a jump boost potion level 2 it's not working, the villager don't recognize the potion https://gyazo.com/8eb98e60aec9c1c0842972fa30bfad23 (picture)
Here it is : Code: ItemStack potion = new ItemStack(Material.POTION); PotionMeta meta = (PotionMeta) potion.getItemMeta(); PotionEffect pe = new PotionEffect(PotionEffectType.JUMP, 1800, 1); meta.addCustomEffect(pe, true); meta.setColor(Color.LIME); meta.setDisplayName("§r§fPotion of Leaping"); potion.setItemMeta(meta);
I don't have to create 2 potions, I put this itemStack into a Merchant code, and try to sell a basic level 2 potion of jump boost into the villager but this is not working, the sell is not working
@Xhork Are you creating a new ItemStack everytime? If so try saving the ItemStack in a variable and access it later.
@Xhork Are you doing something like this? Code:Java //Main classpublic class MainClass extends JavaPlugin { public void onEnable() { new PotionToTrade(); }} //Some class (this is an example, i don't know your code)public class PotionToTrade { private final ItemStack potion; public PotionToTrade() { potion = new ItemStack(Material.POTION); PotionMeta meta = (PotionMeta) potion.getItemMeta(); PotionEffect pe = new PotionEffect(PotionEffectType.JUMP, 1800, 1); meta.addCustomEffect(pe, true); meta.setColor(Color.LIME); meta.setDisplayName("§r§fPotion of Leaping"); potion.setItemMeta(meta); } public ItemStack getPotion() {return potion;}}
@KarimAKL Here is my full code for the trade system : Code: Merchant Potion = Bukkit.createMerchant("Potions"); List<MerchantRecipe> merchantRecipes = new ArrayList<MerchantRecipe>(); MerchantRecipe jump_boost = new MerchantRecipe(new ItemStack(Material.EMERALD, 2), 10000); ItemStack potion = new ItemStack(Material.POTION); PotionMeta meta = (PotionMeta) potion.getItemMeta(); PotionEffect pe = new PotionEffect(PotionEffectType.JUMP, 1800, 1); meta.addCustomEffect(pe, true); meta.setColor(Color.LIME); meta.setDisplayName("§r§fPotion of Leaping"); potion.setItemMeta(meta); jump_boost.setExperienceReward(false); jump_boost.addIngredient(potion); merchantRecipes.add(jump_boost); Potion.setRecipes(merchantRecipes); p.openMerchant(Potion, true);
@Xhork I would guess that it's because of the line "ItemStack potion = new ItemStack(Material.POTION);" Try making a variable like i made in the post above that contains the ItemStack named 'potion' and then set the ingredient to that instead of the new potion you made. (give the player the ItemStack from the same variable) Remember to set the meta etc. for the variable before giving the potion to the player and before setting it as the ingredient.
@KarimAKL thank's but i don't give that potion to the player, i think you don't understand. I want to trade a simple level 2 potion of jump boost with a villager, but i need an itemstack JUST for the trade menu, not for the player, the player has to craft it ^^
@Xhork I see, i thought you meant you wanted to be able to trade a custom potion. :7 I'm sorry but i don't know if it's possible to do what you want. If it is i don't know how. :/