|
11 | 11 | @Mixin(value = JavaOps.class, remap = false) |
12 | 12 | public class JavaOpsExtender { |
13 | 13 | @ModifyArg( |
14 | | - method = { "getStream", "getList", "getByteBuffer", "getIntStream", "getLongStream" }, |
| 14 | + method = "getNumberValue", |
| 15 | + at = @At( |
| 16 | + value = "INVOKE", |
| 17 | + target = "Lcom/mojang/serialization/DataResult;error(Ljava/util/function/Supplier;)Lcom/mojang/serialization/DataResult;" |
| 18 | + ), |
| 19 | + remap = false |
| 20 | + ) |
| 21 | + private Supplier<String> notANumberUseBetterErrorMessage(Supplier<String> message, @Local(argsOnly = true) final Object input) { |
| 22 | + return () -> "Element is not a number: " + input; |
| 23 | + } |
| 24 | + |
| 25 | + @ModifyArg( |
| 26 | + method = "getBooleanValue", |
| 27 | + at = @At( |
| 28 | + value = "INVOKE", |
| 29 | + target = "Lcom/mojang/serialization/DataResult;error(Ljava/util/function/Supplier;)Lcom/mojang/serialization/DataResult;" |
| 30 | + ), |
| 31 | + remap = false |
| 32 | + ) |
| 33 | + private Supplier<String> notABooleanUseBetterErrorMessage(Supplier<String> message, @Local(argsOnly = true) final Object input) { |
| 34 | + return () -> "Element is not a boolean: " + input; |
| 35 | + } |
| 36 | + |
| 37 | + @ModifyArg( |
| 38 | + method = "getStringValue", |
| 39 | + at = @At( |
| 40 | + value = "INVOKE", |
| 41 | + target = "Lcom/mojang/serialization/DataResult;error(Ljava/util/function/Supplier;)Lcom/mojang/serialization/DataResult;" |
| 42 | + ), |
| 43 | + remap = false |
| 44 | + ) |
| 45 | + private Supplier<String> notAStringUseBetterErrorMessage(Supplier<String> message, @Local(argsOnly = true) final Object input) { |
| 46 | + return () -> "Element is not a string: " + input; |
| 47 | + } |
| 48 | + |
| 49 | + @ModifyArg( |
| 50 | + method = { "mergeToMap(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Lcom/mojang/serialization/DataResult;", "mergeToMap(Ljava/lang/Object;Ljava/util/Map;)Lcom/mojang/serialization/DataResult;", "mergeToMap(Ljava/lang/Object;Lcom/mojang/serialization/MapLike;)Lcom/mojang/serialization/DataResult;", "getMapValues", "getMapEntries(Ljava/lang/Object;)Lcom/mojang/serialization/DataResult;", "getMap" }, |
| 51 | + at = @At( |
| 52 | + value = "INVOKE", |
| 53 | + target = "Lcom/mojang/serialization/DataResult;error(Ljava/util/function/Supplier;)Lcom/mojang/serialization/DataResult;" |
| 54 | + ), |
| 55 | + remap = false |
| 56 | + ) |
| 57 | + private Supplier<String> notAMapUseBetterErrorMessage(Supplier<String> message, @Local(argsOnly = true, ordinal = 0) final Object input) { |
| 58 | + return () -> "Element is not a map: " + input; |
| 59 | + } |
| 60 | + |
| 61 | + @ModifyArg( |
| 62 | + method = { "mergeToList(Ljava/lang/Object;Ljava/lang/Object;)Lcom/mojang/serialization/DataResult;", "mergeToList(Ljava/lang/Object;Ljava/util/List;)Lcom/mojang/serialization/DataResult;", "getStream", "getList", "getByteBuffer", "getIntStream", "getLongStream" }, |
15 | 63 | at = @At( |
16 | 64 | value = "INVOKE", |
17 | 65 | target = "Lcom/mojang/serialization/DataResult;error(Ljava/util/function/Supplier;)Lcom/mojang/serialization/DataResult;" |
18 | 66 | ) |
19 | 67 | ) |
20 | | - private Supplier<String> notAListUseBetterErrorMessage(Supplier<String> message, @Local(argsOnly = true) final Object input) { |
21 | | - return () -> "Not a list: " + input; |
| 68 | + private Supplier<String> notAListUseBetterErrorMessage(Supplier<String> message, @Local(argsOnly = true, ordinal = 0) final Object input) { |
| 69 | + return () -> "Element is not a list: " + input; |
22 | 70 | } |
23 | 71 | } |
0 commit comments