This behavier has been reported in MC-305161, since I don’t know how result it will cause. But now I confirm it will crash the game.
How to Reproduce
Held a Iron Sword.
Run command to apply enchant_with_levels or enchant_randomly function, like this:
/item modify entity @p weapon.mainhand {function:enchant_randomly, include_additional_cost_component :true}Open a chest.
When you in chest inventory screen, attemp to move item.
Observed Result
The game crashed.
The game crashed: mousereleased event handler
Error: java.lang.IllegalArgumentException: Failed to hash minecraft:additional_trade_cost=>12: Component of type minecraft:additional_trade_cost is not encodableExpected Result
The game should not be crashed.
Cannot reproduce this on 1.21.11