@@ -1008,8 +1008,12 @@ public String docs() {
1008
1008
+ " | result: the result of the recipe."
1009
1009
+ " | max_repair_cost: the maximum possible cost of this repair."
1010
1010
+ " | level_repair_cost: how many levels are needed to perform this repair."
1011
- + " | item_repair_cost: how many items are needed to perform this repair. }"
1012
- + " { result: the result of the anvil }"
1011
+ + " | item_repair_cost: how many items are needed to perform this repair (MC 1.18.1+). }"
1012
+ + " { result: the result of the recipe."
1013
+ + " | level_repair_cost: how many levels are needed to perform this repair."
1014
+ + " | item_repair_cost: how many items are needed to perform this repair (MC 1.18.1+)."
1015
+ + " | max_repair_cost: the maximum possible cost of this repair. Values exceeding 40 will be"
1016
+ + " respected, but may still show as too expensive on the client. }"
1013
1017
+ " {}" ;
1014
1018
}
1015
1019
@@ -1036,9 +1040,11 @@ public Map<String, Mixed> evaluate(BindableEvent event) throws EventException {
1036
1040
ret .put ("first_item" , ObjectGenerator .GetGenerator ().item (anvil .getFirstItem (), Target .UNKNOWN ));
1037
1041
ret .put ("second_item" , ObjectGenerator .GetGenerator ().item (anvil .getSecondItem (), Target .UNKNOWN ));
1038
1042
ret .put ("result" , ObjectGenerator .GetGenerator ().item (anvil .getResult (), Target .UNKNOWN ));
1039
- ret .put ("max_repair_cost" , new CInt (anvil .getMaximumRepairCost (), Target .UNKNOWN ));
1040
1043
ret .put ("level_repair_cost" , new CInt (anvil .getRepairCost (), Target .UNKNOWN ));
1041
- ret .put ("item_repair_cost" , new CInt (anvil .getRepairCostAmount (), Target .UNKNOWN ));
1044
+ if (Static .getServer ().getMinecraftVersion ().gte (MCVersion .MC1_18_1 )) {
1045
+ ret .put ("item_repair_cost" , new CInt (anvil .getRepairCostAmount (), Target .UNKNOWN ));
1046
+ }
1047
+ ret .put ("max_repair_cost" , new CInt (anvil .getMaximumRepairCost (), Target .UNKNOWN ));
1042
1048
1043
1049
return ret ;
1044
1050
} else {
@@ -1067,7 +1073,16 @@ public boolean modifyEvent(String key, Mixed value, BindableEvent event) {
1067
1073
}
1068
1074
1069
1075
if (key .equalsIgnoreCase ("item_repair_cost" )) {
1070
- anvil .setRepairCostAmount (ArgumentValidation .getInt32 (value , t ));
1076
+ if (Static .getServer ().getMinecraftVersion ().gte (MCVersion .MC1_18_1 )) {
1077
+ anvil .setRepairCostAmount (ArgumentValidation .getInt32 (value , t ));
1078
+ return true ;
1079
+ } else {
1080
+ return false ;
1081
+ }
1082
+ }
1083
+
1084
+ if (key .equalsIgnoreCase ("max_repair_cost" )) {
1085
+ anvil .setMaximumRepairCost (ArgumentValidation .getInt32 (value , t ));
1071
1086
return true ;
1072
1087
}
1073
1088
}
0 commit comments