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); } } }