2
2
3
3
import com .llamalad7 .mixinextras .sugar .Local ;
4
4
import com .mojang .serialization .JavaOps ;
5
+ import org .spongepowered .asm .mixin .Final ;
5
6
import org .spongepowered .asm .mixin .Mixin ;
7
+ import org .spongepowered .asm .mixin .Overwrite ;
8
+ import org .spongepowered .asm .mixin .Shadow ;
6
9
import org .spongepowered .asm .mixin .injection .At ;
7
10
import org .spongepowered .asm .mixin .injection .ModifyArg ;
8
11
12
+ import java .util .Map ;
9
13
import java .util .function .Supplier ;
10
14
11
15
@ Mixin (value = JavaOps .class , remap = false )
@@ -15,8 +19,7 @@ public class JavaOpsExtender {
15
19
at = @ At (
16
20
value = "INVOKE" ,
17
21
target = "Lcom/mojang/serialization/DataResult;error(Ljava/util/function/Supplier;)Lcom/mojang/serialization/DataResult;"
18
- ),
19
- remap = false
22
+ )
20
23
)
21
24
private Supplier <String > notANumberUseBetterErrorMessage (Supplier <String > message , @ Local (argsOnly = true ) final Object input ) {
22
25
return () -> "Element is not a number: " + input ;
@@ -27,8 +30,7 @@ private Supplier<String> notANumberUseBetterErrorMessage(Supplier<String> messag
27
30
at = @ At (
28
31
value = "INVOKE" ,
29
32
target = "Lcom/mojang/serialization/DataResult;error(Ljava/util/function/Supplier;)Lcom/mojang/serialization/DataResult;"
30
- ),
31
- remap = false
33
+ )
32
34
)
33
35
private Supplier <String > notABooleanUseBetterErrorMessage (Supplier <String > message , @ Local (argsOnly = true ) final Object input ) {
34
36
return () -> "Element is not a boolean: " + input ;
@@ -39,8 +41,7 @@ private Supplier<String> notABooleanUseBetterErrorMessage(Supplier<String> messa
39
41
at = @ At (
40
42
value = "INVOKE" ,
41
43
target = "Lcom/mojang/serialization/DataResult;error(Ljava/util/function/Supplier;)Lcom/mojang/serialization/DataResult;"
42
- ),
43
- remap = false
44
+ )
44
45
)
45
46
private Supplier <String > notAStringUseBetterErrorMessage (Supplier <String > message , @ Local (argsOnly = true ) final Object input ) {
46
47
return () -> "Element is not a string: " + input ;
@@ -51,8 +52,7 @@ private Supplier<String> notAStringUseBetterErrorMessage(Supplier<String> messag
51
52
at = @ At (
52
53
value = "INVOKE" ,
53
54
target = "Lcom/mojang/serialization/DataResult;error(Ljava/util/function/Supplier;)Lcom/mojang/serialization/DataResult;"
54
- ),
55
- remap = false
55
+ )
56
56
)
57
57
private Supplier <String > notAMapUseBetterErrorMessage (Supplier <String > message , @ Local (argsOnly = true , ordinal = 0 ) final Object input ) {
58
58
return () -> "Element is not a map: " + input ;
@@ -68,4 +68,20 @@ private Supplier<String> notAMapUseBetterErrorMessage(Supplier<String> message,
68
68
private Supplier <String > notAListUseBetterErrorMessage (Supplier <String > message , @ Local (argsOnly = true , ordinal = 0 ) final Object input ) {
69
69
return () -> "Element is not a list: " + input ;
70
70
}
71
+
72
+ @ Mixin (targets = "com/mojang/serialization/JavaOps$1" )
73
+ public static class MapLikeExtender <T > {
74
+ @ Shadow
75
+ @ Final
76
+ Map <T , T > val$map ;
77
+
78
+ /**
79
+ * @author ErrorCraft
80
+ * @reason Uses the element itself instead of a wrapped element.
81
+ */
82
+ @ Overwrite
83
+ public String toString () {
84
+ return this .val$map .toString ();
85
+ }
86
+ }
71
87
}
0 commit comments