NBT Data Kick Event when Moving Armored Elytra
EclipseofLife opened this issue ยท 7 comments
In 1.18.2
Spigot Server
Running vanilla-tweaks armored elytra.
Happens when only this mod is installed.
Clicking on the armored elytra can instantly kick me from the server.
Gives error code:
I also have the same issue when just pressing "E" while in creative mode, but that seems harder to reproduce.
The bug is caused by a previous fix made to chestplate enchantment glint. Seen below, the mixin adds a "ghost" mending enchantment to the chestplate stack to ensure that it has a glint if the Armoured Elytra is enchanted. I say "ghost" enchantment because in both single and multiplayer, the enchantment doesn't ever actually get applied to the chestplate - i.e you don't get free mending.
This is called very often to make sure that the chestplate render stays accurate to the elytra's data. The "ghost" enchantment is never removed, and there's no check to not add it if the chestplate stack already has enchantments. This leads to the enchantment being added every time this mixin runs, stacking until the NBT limit of the elytra is exceeded. Then when the player attempts to interact with the chestplate/elytra, the client/server attempts to read the NBT data which has ballooned in size causing either singleplayer to crash or a kick from a multiplayer server.
I made the following change in PR #12, listed above. I added a single if statement that checks if the chestplate stack is already enchanted before applying the Mending. This limits the enchantment to only be added a single time, if the chestplate wasn't already enchanted before combining with an elytra. The enchantment no longer stacks infinitely, meaning the player no longer crashes/gets kicked.
Tested and confirmed to work in 1.18.2
Fixed by 1c3734c
Sorry for the delay, here is the log. There appears to be nothing super detailed.
latest.log
I noticed that sometimes the issue would take a bit to occur, while other times it would happen immediately. Regardless, I would try to unequip the armored elytra, either by shift-clicking or by normal clicking, and it would crash my game. Upon relogging, the armor would remain equipped.
Due to further discussion witha member of my discord server. I have found a potential issue which could cause said problem. I am just going to rewrite the rendering code before I release the 1.19 version and will backport to 1.18.2 as well.
There is some very hacky code which I would rather rewrite as it's been a long time stewing up inside this mod lol.