File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed
java/net/errorcraft/codecium/mixin/mojang/serialization/codecs Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change 1+ package net .errorcraft .codecium .mixin .mojang .serialization .codecs ;
2+
3+ import com .llamalad7 .mixinextras .sugar .Local ;
4+ import com .mojang .serialization .MapLike ;
5+ import com .mojang .serialization .codecs .KeyDispatchCodec ;
6+ import org .spongepowered .asm .mixin .Final ;
7+ import org .spongepowered .asm .mixin .Mixin ;
8+ import org .spongepowered .asm .mixin .Shadow ;
9+ import org .spongepowered .asm .mixin .injection .At ;
10+ import org .spongepowered .asm .mixin .injection .ModifyArg ;
11+
12+ import java .util .function .Supplier ;
13+
14+ @ Mixin (value = KeyDispatchCodec .class , remap = false )
15+ public class KeyDispatchCodecExtender {
16+ @ Shadow
17+ @ Final
18+ private static String COMPRESSED_VALUE_KEY ;
19+
20+ @ Shadow
21+ @ Final
22+ private String typeKey ;
23+
24+ @ ModifyArg (
25+ method = "decode" ,
26+ at = @ At (
27+ value = "INVOKE" ,
28+ target = "Lcom/mojang/serialization/DataResult;error(Ljava/util/function/Supplier;)Lcom/mojang/serialization/DataResult;"
29+ )
30+ )
31+ private <T > Supplier <String > noTypeKeyUseBetterErrorMessage (Supplier <String > message , @ Local (argsOnly = true ) final MapLike <T > input ) {
32+ return () -> "Key '" + this .typeKey + "' must be present in map: " + input ;
33+ }
34+
35+ @ ModifyArg (
36+ method = "lambda$decode$3" ,
37+ at = @ At (
38+ value = "INVOKE" ,
39+ target = "Lcom/mojang/serialization/DataResult;error(Ljava/util/function/Supplier;)Lcom/mojang/serialization/DataResult;"
40+ )
41+ )
42+ private static <T > Supplier <String > noValueKeyUseBetterErrorMessage (Supplier <String > message , @ Local (argsOnly = true ) final MapLike <T > input ) {
43+ return () -> "Key '" + COMPRESSED_VALUE_KEY + "' must be present in map: " + input ;
44+ }
45+ }
Original file line number Diff line number Diff line change 1616 " mojang.serialization.codecs.BaseMapCodecExtender" ,
1717 " mojang.serialization.codecs.EitherCodecExtender" ,
1818 " mojang.serialization.codecs.FieldDecoderExtender" ,
19+ " mojang.serialization.codecs.KeyDispatchCodecExtender" ,
1920 " mojang.serialization.codecs.ListCodecExtender" ,
2021 " mojang.serialization.codecs.OptionalFieldCodecExtender" ,
2122 " mojang.serialization.codecs.RecordCodecBuilderExtender$RecordMapCodecExtender"
You can’t perform that action at this time.
0 commit comments