mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 08:14:00 +02:00
1.6.12 (#41)
Fix an important bug related to XP cost: - sometimes XP cost limit is not respected.
This commit is contained in:
parent
8f12d79cb9
commit
fa042411ae
3 changed files with 13 additions and 2 deletions
|
|
@ -16,7 +16,7 @@ plugins {
|
|||
}
|
||||
|
||||
group = "xyz.alexcrea"
|
||||
version = "1.6.11"
|
||||
version = "1.6.12"
|
||||
|
||||
repositories {
|
||||
// EcoEnchants
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ object EnchantmentUtil {
|
|||
// Get max level or 255 if player can bypass
|
||||
val maxLevel = if (bypassLevel) { 255 }
|
||||
else { ConfigOptions.enchantLimit(enchantment) }
|
||||
CustomAnvil.verboseLog("Max level of ${enchantment.key} is $maxLevel (bypassLevel is $bypassLevel)")
|
||||
|
||||
val cappedLevel = min(level, maxLevel)
|
||||
|
||||
|
|
@ -89,7 +90,11 @@ object EnchantmentUtil {
|
|||
// We test if it is allowed to merge at this level
|
||||
if(!bypassLevel){
|
||||
val maxBeforeDisabled = ConfigOptions.maxBeforeMergeDisabled(enchantment)
|
||||
if((maxBeforeDisabled > 0) && (oldLevel >= maxBeforeDisabled)) return@forEach
|
||||
if((maxBeforeDisabled > 0) && (oldLevel >= maxBeforeDisabled)) {
|
||||
CustomAnvil.verboseLog(
|
||||
"Reached max merge before disable for ${enchantment.key}: $oldLevel/$maxBeforeDisabled)")
|
||||
return@forEach
|
||||
}
|
||||
}
|
||||
|
||||
// Now we increase the enchantment level by 1
|
||||
|
|
|
|||
|
|
@ -52,6 +52,11 @@ class AnvilResultListener: Listener {
|
|||
val leftItem = inventory.getItem(ANVIL_INPUT_LEFT) ?: return
|
||||
val rightItem = inventory.getItem(ANVIL_INPUT_RIGHT)
|
||||
|
||||
if(!GameMode.CREATIVE.equals(player.gameMode) && inventory.repairCost >= inventory.maximumRepairCost) {
|
||||
event.result = Event.Result.DENY
|
||||
return
|
||||
}
|
||||
|
||||
// Test custom recipe
|
||||
val recipe = CustomRecipeUtil.getCustomRecipe(leftItem, rightItem)
|
||||
if(recipe != null){
|
||||
|
|
@ -107,6 +112,7 @@ class AnvilResultListener: Listener {
|
|||
val amount = CustomRecipeUtil.getCustomRecipeAmount(recipe, leftItem, rightItem)
|
||||
val xpCost = amount * recipe.xpCostPerCraft
|
||||
|
||||
CustomAnvil.log("gamemode: ${player.gameMode != GameMode.CREATIVE}, cost: $xpCost, level: ${player.level}, result: ${player.level < xpCost}")
|
||||
if ((player.gameMode != GameMode.CREATIVE) && (player.level < xpCost)) return
|
||||
|
||||
// We give the item manually
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue