Armored Elytra

Armored Elytra

36k Downloads

NBT Data Kick Event when Moving Armored Elytra

EclipseofLife opened this issue ยท 7 comments

commented

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:
image

I also have the same issue when just pressing "E" while in creative mode, but that seems harder to reproduce.

commented

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.

https://github.com/MrMelon54/armored-elytra-fabric/blob/ccd49dec099e14d4db2c77537315d824e66c130a/src/main/java/xyz/mrmelon54/ArmoredElytra/mixin/MixinLivingEntityChildren.java#L34

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.

https://github.com/MrMelon54/armored-elytra-fabric/blob/89bf7117f84dcbc46e92531e5c5a1eee0d9b9bd7/src/main/java/xyz/mrmelon54/ArmoredElytra/mixin/MixinLivingEntityChildren.java#L33-L36

Tested and confirmed to work in 1.18.2

commented

I would still prefer to rewrite the rendering instead of just bodging a fix

commented

Fixed by 1c3734c

commented

Can you send the server log as it hopefully has some more detailed information?

commented

Sorry for the delay, here is the log. There appears to be nothing super detailed.
latest.log

commented

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.

commented

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.