Fix unit repair not being capped.

Also fix wrong range in lore.
This commit is contained in:
alexcrea 2024-05-28 23:10:37 +02:00
parent 78e77df071
commit 49d8ba304d
No known key found for this signature in database
GPG key ID: 43FD265DB0DBF91F
2 changed files with 8 additions and 3 deletions

View file

@ -110,7 +110,7 @@ public class BasicConfigGui extends ValueUpdatableGui {
ConfigOptions.MAX_ANVIL_COST, ConfigHolder.DEFAULT_CONFIG,
Arrays.asList(
"\u00A77Max cost the Anvil can get to.",
"\u00A77Valid values include \u00A7e1 \u00A77to \u00A7e255\u00A77.",
"\u00A77Valid values include \u00A7e0 \u00A77to \u00A7e1000\u00A77.",
"\u00A77Cost will be displayed as \u00A7cToo Expensive\u00A77:",
"\u00A77- If Cost is above \u00A7e39",
"\u00A77- And \u00A7eReplace Too Expensive\u00A77 is disabled"

View file

@ -99,7 +99,6 @@ class AnvilEventListener(private val packetManager: PacketManager) : Listener {
// Test for merge
if (first.canMergeWith(second)) {
val newEnchants = first.findEnchantments()
.combineWith(second.findEnchantments(), first.type, player)
val resultItem = first.clone()
@ -210,7 +209,6 @@ class AnvilEventListener(private val packetManager: PacketManager) : Listener {
if ((output == inventory.getItem(ANVIL_INPUT_LEFT))
|| !allowed
) {
event.result = Event.Result.DENY
return
}
@ -334,6 +332,13 @@ class AnvilEventListener(private val packetManager: PacketManager) : Listener {
repairCost += calculatePenalty(leftItem, null, resultCopy)
repairCost += resultAmount * ConfigOptions.unitRepairCost
if (
!ConfigOptions.doRemoveCostLimit &&
ConfigOptions.doCapCost) {
repairCost = min(repairCost, ConfigOptions.maxAnvilCost)
}
if ((inventory.maximumRepairCost < repairCost)
|| (player.level < repairCost)
) return