mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-22 22:45:31 +01:00
fix enchantment order issue
This commit is contained in:
parent
548504381f
commit
2f19f0fb7b
1 changed files with 11 additions and 5 deletions
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue