AuraDevelopmentTeam / InvSync

This plugin synchronizes the player inventory with a database
GNU General Public License v3.0
12 stars 10 forks source link

Armor enchantments can flip between servers #41

Open bluelightning32 opened 5 years ago

bluelightning32 commented 5 years ago

Issue Description:

I added another minecraft instance running the same modpack. Players complained that when the logged into the new instance, the enchantments changed on their armor.

They gave a specific example of obsidian boots that originally had a multijump IV enchantment, but it synced as beheading IV on the new server.

I was able to reproduce it. This is the json for the boots:

{"stack":{"ContentVersion":1,"ItemType":"mekanismtools:obsidianboots","UnsafeDamage":0,"Count":1,"UnsafeData":{"ench":[{"lvl":4,"id":105}],"RepairCost":1,"ForgeCaps":{"astralsorcery:cap_item_amulet_holder":{"AS_Amulet_HolderLeast":-6587230391593753591,"AS_Amulet_HolderMost":3320807983800733515}}}}

I discovered that the enchantment ids are mapped to enchantments in the level.dat file, under FML/Registries/minecraft:enchantments/ids. Enchantment id 105 was mapped to different things on the two servers. The original server has been through many modpack upgrades, and I suspect that's why it had a different enchantment id mapping.

I worked around this by copying the enchantment id mapping from level.dat on the source server to the target server. This will fix it for player inventory, but now the enchantments will be wrong on loot they get from dungeons (because I already pregenned the world).

Ideally invsync would serialize the enchantment ids as enchantment names.

Affected Versions (Do not use "latest"):

BrainStone commented 5 years ago

Hi there.
First of all I’m glad you managed to fix it in your server. What you did is what I would have suggested. And your analysis of the issue seems correct.

Now the thing is I don’t serialize items by hand. Sponge does that. Even if I did, I’d run into the issue that the way enchantments are serialized currently is the way Minecraft stores them itself. So if I serialize the NBT Data of an item I’d need to convert the enchantment data before storing it (and converting it back).

Don’t get me wrong. I do understand your issue. And I do understand why you are requesting it. Though the issue doesn’t lie within my plugin, but rather with Minecraft itself.

If the enchantment format stays the same in 1.13 and 1.14 I’ll consider trying to add a workaround for it. Since if MC itself changes it in the versions already out, I don’t see a point in adding a complex workaround that’s technically speaking already obsolete.