Skip to content

Commit

Permalink
add modify for item_pre_anvil's item_repair_cost/level_repair_cost (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Lildirt authored Jul 6, 2024
1 parent ace9b67 commit f95e5af
Showing 1 changed file with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1008,8 +1008,12 @@ public String docs() {
+ " | result: the result of the recipe."
+ " | max_repair_cost: the maximum possible cost of this repair."
+ " | level_repair_cost: how many levels are needed to perform this repair."
+ " | item_repair_cost: how many items are needed to perform this repair. }"
+ " { result: the result of the anvil }"
+ " | item_repair_cost: how many items are needed to perform this repair (MC 1.18.1+). }"
+ " { result: the result of the recipe."
+ " | level_repair_cost: how many levels are needed to perform this repair."
+ " | item_repair_cost: how many items are needed to perform this repair (MC 1.18.1+)."
+ " | max_repair_cost: the maximum possible cost of this repair. Values exceeding 40 will be"
+ " respected, but may still show as too expensive on the client. }"
+ " {}";
}

Expand All @@ -1036,9 +1040,11 @@ public Map<String, Mixed> evaluate(BindableEvent event) throws EventException {
ret.put("first_item", ObjectGenerator.GetGenerator().item(anvil.getFirstItem(), Target.UNKNOWN));
ret.put("second_item", ObjectGenerator.GetGenerator().item(anvil.getSecondItem(), Target.UNKNOWN));
ret.put("result", ObjectGenerator.GetGenerator().item(anvil.getResult(), Target.UNKNOWN));
ret.put("max_repair_cost", new CInt(anvil.getMaximumRepairCost(), Target.UNKNOWN));
ret.put("level_repair_cost", new CInt(anvil.getRepairCost(), Target.UNKNOWN));
ret.put("item_repair_cost", new CInt(anvil.getRepairCostAmount(), Target.UNKNOWN));
if(Static.getServer().getMinecraftVersion().gte(MCVersion.MC1_18_1)) {
ret.put("item_repair_cost", new CInt(anvil.getRepairCostAmount(), Target.UNKNOWN));
}
ret.put("max_repair_cost", new CInt(anvil.getMaximumRepairCost(), Target.UNKNOWN));

return ret;
} else {
Expand All @@ -1059,6 +1065,26 @@ public boolean modifyEvent(String key, Mixed value, BindableEvent event) {
e.setResult(ObjectGenerator.GetGenerator().item(value, t));
return true;
}

MCAnvilInventory anvil = (MCAnvilInventory) e.getInventory();
if(key.equalsIgnoreCase("level_repair_cost")) {
anvil.setRepairCost(ArgumentValidation.getInt32(value, t));
return true;
}

if(key.equalsIgnoreCase("item_repair_cost")) {
if(Static.getServer().getMinecraftVersion().gte(MCVersion.MC1_18_1)) {
anvil.setRepairCostAmount(ArgumentValidation.getInt32(value, t));
return true;
} else {
return false;
}
}

if(key.equalsIgnoreCase("max_repair_cost")) {
anvil.setMaximumRepairCost(ArgumentValidation.getInt32(value, t));
return true;
}
}
return false;
}
Expand Down

0 comments on commit f95e5af

Please sign in to comment.