Fix possible NPE in 32k enchantment fix

This commit is contained in:
FlorianMichael 2024-04-27 00:43:08 +02:00
parent 6e21d8d946
commit 5ef8d1bae4
1 changed files with 4 additions and 1 deletions

View File

@ -60,7 +60,10 @@ public abstract class MixinItemStack {
if (ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_14_4)) {
return;
}
// Via 1.20.5->.3 will always put the original item data into CUSTOM_DATA, so we can assume its present.
// Item has no nbt and can't have enchantments.
if (!this.getComponents().contains(DataComponentTypes.CUSTOM_DATA)) return;
// Via 1.20.5->.3 will always put the original item data into CUSTOM_DATA if it's not empty.
final NbtCompound customData = this.getComponents().get(DataComponentTypes.CUSTOM_DATA).getNbt();
if (componentType == DataComponentTypes.ENCHANTMENTS) {