noobanidus / Variegated

MIT License
0 stars 1 forks source link

[Mod Conflict] Attempting to craft a Manabound Book yields Astral Sorcery's Night Vision book [AKA: Enchant IDs are Dumb] #3

Open DoomRater opened 4 years ago

DoomRater commented 4 years ago

I'm guessing the actual enchantment id is getting bumped by Astral Sorcery in this case because the enchantment id that the recipe adds is off by 2, yielding Astral Sorcery's Night Vision enchantment instead of Manabound. To reproduce, add Astral Sorcery along with Botania and Variegated and take a peek at JEI's recipe for the Manabound enchantment. When you check the book, it reports that it will make Night Vision enchantment. So my Botania player went ahead and crafted one anyway and... yup, night vision.

noobanidus commented 4 years ago

... yeah.

I would recommend using BotaniaTweaker or whatever Quat's mod is called to modifying the recipe yourself; unfortunately, I don't think there's anything that can be done to fix it on my end. The runic altar wasn't really designed to function like this and I think the iteamstack + id is stored at server-start, whereas in the world that itemstack's id might be equivalent to a different enchantment.

noobanidus commented 4 years ago

(I'll try to come up with a better way to create this recipe that's more impervious to this, such as, perhaps, combining a full mana tablet with a book in an anvil.)

DoomRater commented 4 years ago

I'll say it sucks. So this happens on my server, but not in singleplayer (which might be why I didn't catch it beforehand).

noobanidus commented 4 years ago

Yeah.

If you want to know the exact reason why, it's because the ordering of the enchantments in the registry is according to the "best case scenario", i.e., that all mods were added at the exact same time in a fresh new world.

You can prove this by downloading ... probably level.dat from both the server and your single player and using NBTExplore to find the registries section, and compare the ordering and numbering of the enchants in your single player versus your multiplayer server.

As the code constructs the "recipe result" item before the server is actually loaded and the enchantment registry from there is loaded, it uses the recipe IDs according to your single-player game (i.e., best-case scenario). However, when that exact same item is rewarded in multiplayer, you get a completely different enchantment.

The solution here is to have a recipe that generates the ItemStack dynamically, according to the world, rather than statically as the game is being processed.

This could be done by me with a dynamic crafting table recipe or a dynamic event handler-style recipe for the anvil, or it could be done by anyone with a CraftTweaker recipe function (and I believe there are still library-based helper functions I added which could be used in this function).

Thankfully, in 1.14, itemstacks now use the enchantment resource name (i.e., variegated:manabound) instead of an integer, so the problem just disappears in later versions.