From ebbb87a0b87155b13828383db901ad8e3f16cf50 Mon Sep 17 00:00:00 2001 From: Sollace Date: Mon, 24 Jun 2024 02:01:28 +0100 Subject: [PATCH] Fix spell recipes (1.20.2) --- .../unicopia/ability/magic/spell/trait/Trait.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/trait/Trait.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/trait/Trait.java index d0abb545..6a7b2f34 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/trait/Trait.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/trait/Trait.java @@ -60,7 +60,8 @@ public enum Trait implements CommandArgumentEnum { BLOOD(TraitGroup.DARKNESS); private static final Map IDS = Arrays.stream(values()).collect(Collectors.toMap(Trait::getId, Function.identity())); - public static final EnumCodec CODEC = StringIdentifiable.createCodec(Trait::values, n -> n.toLowerCase(Locale.ROOT)); + private static final EnumCodec NAME_CODEC = StringIdentifiable.createCodec(Trait::values, n -> n.toLowerCase(Locale.ROOT)); + public static final Codec CODEC = Identifier.CODEC.xmap(id -> IDS.get(id), Trait::getId); public static final Codec> SET_CODEC = CODEC.listOf().xmap( l -> l.stream().distinct().collect(Collectors.toSet()), s -> s.stream().toList() @@ -165,7 +166,7 @@ public enum Trait implements CommandArgumentEnum { @Deprecated public static Optional fromName(String name) { - Trait trait = CODEC.byId(name); + Trait trait = NAME_CODEC.byId(name); if (trait == null) { Unicopia.LOGGER.error("Unknown trait: " + name); } @@ -178,7 +179,7 @@ public enum Trait implements CommandArgumentEnum { public static class ArgumentType extends EnumArgumentType { protected ArgumentType() { - super(CODEC, Trait::values); + super(NAME_CODEC, Trait::values); } } }