diff options
author | Jake Potrebic <[email protected]> | 2024-04-26 18:06:35 -0700 |
---|---|---|
committer | Jake Potrebic <[email protected]> | 2024-04-26 18:06:41 -0700 |
commit | 2f19f0fb7b1db54dde18c1a53837d2ab77a4d07e (patch) | |
tree | e2d69a5192676f3c085abca5cc9c4c0a959898a8 | |
parent | 548504381fd3494d7ef91670a33eaae61127eb0b (diff) | |
download | Paper-2f19f0fb7b1db54dde18c1a53837d2ab77a4d07e.tar.gz Paper-2f19f0fb7b1db54dde18c1a53837d2ab77a4d07e.zip |
fix enchantment order issue
-rw-r--r-- | patches/server/0077-Handle-Item-Meta-Inconsistencies.patch | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/patches/server/0077-Handle-Item-Meta-Inconsistencies.patch b/patches/server/0077-Handle-Item-Meta-Inconsistencies.patch index 50ab2f09d7..ef76b801d9 100644 --- a/patches/server/0077-Handle-Item-Meta-Inconsistencies.patch +++ b/patches/server/0077-Handle-Item-Meta-Inconsistencies.patch @@ -18,10 +18,10 @@ For consistency, the old API methods now forward to use the ItemMeta API equivalents, and should deprecate the old API's. diff --git a/src/main/java/net/minecraft/world/item/enchantment/ItemEnchantments.java b/src/main/java/net/minecraft/world/item/enchantment/ItemEnchantments.java -index b49eb019cce58049c2b3a0e80e3d08998b16f7ea..dd6bf199f22476ef1d0f704883b748be97b0065e 100644 +index b49eb019cce58049c2b3a0e80e3d08998b16f7ea..af18de11dd55938b6091f5ab183bd3fe4e8df152 100644 --- a/src/main/java/net/minecraft/world/item/enchantment/ItemEnchantments.java +++ b/src/main/java/net/minecraft/world/item/enchantment/ItemEnchantments.java -@@ -27,15 +27,21 @@ import net.minecraft.tags.TagKey; +@@ -27,15 +27,27 @@ import net.minecraft.tags.TagKey; import net.minecraft.world.item.Item; import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.item.component.TooltipProvider; @@ -42,11 +42,17 @@ index b49eb019cce58049c2b3a0e80e3d08998b16f7ea..dd6bf199f22476ef1d0f704883b748be BuiltInRegistries.ENCHANTMENT.holderByNameCodec(), LEVEL_CODEC ) - .xmap(Object2IntOpenHashMap::new, Function.identity()); -+ .xmap(Object2IntAVLTreeMap::new, Function.identity()); // Paper ++ // Paper start - sort enchantments ++ .xmap(m -> { ++ final Object2IntAVLTreeMap<Holder<Enchantment>> map = new Object2IntAVLTreeMap<>(ENCHANTMENT_ORDER); ++ map.putAll(m); ++ return map; ++ }, Function.identity()); ++ // Paper end - sort enchantments private static final Codec<ItemEnchantments> FULL_CODEC = RecordCodecBuilder.create( instance -> instance.group( LEVELS_CODEC.fieldOf("levels").forGetter(component -> component.enchantments), -@@ -45,16 +51,16 @@ public class ItemEnchantments implements TooltipProvider { +@@ -45,16 +57,16 @@ public class ItemEnchantments implements TooltipProvider { ); public static final Codec<ItemEnchantments> CODEC = Codec.withAlternative(FULL_CODEC, LEVELS_CODEC, map -> new ItemEnchantments(map, true)); public static final StreamCodec<RegistryFriendlyByteBuf, ItemEnchantments> STREAM_CODEC = StreamCodec.composite( @@ -66,7 +72,7 @@ index b49eb019cce58049c2b3a0e80e3d08998b16f7ea..dd6bf199f22476ef1d0f704883b748be this.enchantments = enchantments; this.showInTooltip = showInTooltip; -@@ -145,7 +151,7 @@ public class ItemEnchantments implements TooltipProvider { +@@ -145,7 +157,7 @@ public class ItemEnchantments implements TooltipProvider { } public static class Mutable { |