jabelar Posted March 6, 2018 Posted March 6, 2018 (edited) I have a custom villager profession "cloud enchanter" that is supposed to allow you to use emeralds to buy boots of "safe falling" which are golden boots with a custom enchantment (of "safe falling" of course). The enchantment works fine on its own -- I can print out the enchantment registry and see it listed, and I can use the /enchant command and it can enchant golden boots which begin to shimmer and also work as intended (prevent fall damage completely). The villager trade also generally works -- clicking on the villager brings up a trade GUI with a single trade that shows emeralds resulting in golden boots, and placing emeralds gets the boots. However, the problem is that the boots are not enchanted -- they don't glimmer and they don't protect the player. The weird thing is that if I print out the merchant recipe at the time it is "added" (which seems to be when the GUI is opened) the console shows that the recipe includes enchanted boots (11 is id of my custom enchantment): [com.blogspot.jabelarminecraft.examplemod.init.ModProfessions$TradeEmeraldsForEnchantedBoots:addMerchantRecipe:110]: Merchant recipe list = {Recipes:[{maxUses:7,buy:{id:"minecraft:emerald",Count:47b,Damage:0s},sell:{id:"minecraft:golden_boots",Count:1b,tag:{ench:[{lvl:2s,id:11s}]},Damage:0s},uses:0,rewardExp:1b}]} Even weirder is I tried the built-in merchant trades such as ListEnchantedItemForEmeralds and they also do not seem to work! I would get non-enchanted items in the GUI even though the merchant recipe prints out that the buy item is enchanted. I then tried to trace the call hierarchy and I'm now suspicious that the merchant recipe system may have a bug -- it creates the buying item with the ItemStack(NBTTagCompound) constructor. However, it seems to me that that constructor may not work for enchantment NBT data. If you look at the addEnchantment() method you'll see it adds a compound with key "ench". But the ItemStack(NBTTagCompound) doesn't seem to handle that at all. Am I missing something? In summary, the merchant recipe prints out (at time of GUI opening) and shows that the recipe sells an enchanted item but the GUI doesn't show the item as enchanted. Looking at how the GUI creates the item using ItemStack(NBTTagCompound) it seems to me that enchantment tags may not be applied. Here are some relevant classes: https://github.com/jabelar/ExampleMod-1.12/blob/master/src/main/java/com/blogspot/jabelarminecraft/examplemod/init/ModProfessions.java https://github.com/jabelar/ExampleMod-1.12/blob/master/src/main/java/com/blogspot/jabelarminecraft/examplemod/init/ModEnchantments.java https://github.com/jabelar/ExampleMod-1.12/blob/master/src/main/java/com/blogspot/jabelarminecraft/examplemod/enchantments/EnchantmentSafeFalling.java Edited March 6, 2018 by jabelar Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/
jabelar Posted March 6, 2018 Author Posted March 6, 2018 EDIT: Corail31 helped me solve this. I kept testing with the same saved world with the same villager. So the villagers already generated never got my updated merchant lists. I didn't realize that merchant list was associated at time of villager generation, which makes sense now that I think that it needs to remember the offers and number of uses. Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.