Fix spell recipes (1.20.2)

This commit is contained in:
Sollace 2024-06-24 02:01:28 +01:00
parent cc8bc28432
commit ebbb87a0b8
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB

View file

@ -60,7 +60,8 @@ public enum Trait implements CommandArgumentEnum<Trait> {
BLOOD(TraitGroup.DARKNESS); BLOOD(TraitGroup.DARKNESS);
private static final Map<Identifier, Trait> IDS = Arrays.stream(values()).collect(Collectors.toMap(Trait::getId, Function.identity())); private static final Map<Identifier, Trait> IDS = Arrays.stream(values()).collect(Collectors.toMap(Trait::getId, Function.identity()));
public static final EnumCodec<Trait> CODEC = StringIdentifiable.createCodec(Trait::values, n -> n.toLowerCase(Locale.ROOT)); private static final EnumCodec<Trait> NAME_CODEC = StringIdentifiable.createCodec(Trait::values, n -> n.toLowerCase(Locale.ROOT));
public static final Codec<Trait> CODEC = Identifier.CODEC.xmap(id -> IDS.get(id), Trait::getId);
public static final Codec<Set<Trait>> SET_CODEC = CODEC.listOf().xmap( public static final Codec<Set<Trait>> SET_CODEC = CODEC.listOf().xmap(
l -> l.stream().distinct().collect(Collectors.toSet()), l -> l.stream().distinct().collect(Collectors.toSet()),
s -> s.stream().toList() s -> s.stream().toList()
@ -165,7 +166,7 @@ public enum Trait implements CommandArgumentEnum<Trait> {
@Deprecated @Deprecated
public static Optional<Trait> fromName(String name) { public static Optional<Trait> fromName(String name) {
Trait trait = CODEC.byId(name); Trait trait = NAME_CODEC.byId(name);
if (trait == null) { if (trait == null) {
Unicopia.LOGGER.error("Unknown trait: " + name); Unicopia.LOGGER.error("Unknown trait: " + name);
} }
@ -178,7 +179,7 @@ public enum Trait implements CommandArgumentEnum<Trait> {
public static class ArgumentType extends EnumArgumentType<Trait> { public static class ArgumentType extends EnumArgumentType<Trait> {
protected ArgumentType() { protected ArgumentType() {
super(CODEC, Trait::values); super(NAME_CODEC, Trait::values);
} }
} }
} }