mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
Add "max before merge is disabled"
This commit is contained in:
parent
a915d5ad80
commit
e60cd25776
3 changed files with 50 additions and 1 deletions
|
|
@ -41,6 +41,8 @@ object ConfigOptions {
|
||||||
const val ENCHANT_LIMIT_ROOT = "enchant_limits"
|
const val ENCHANT_LIMIT_ROOT = "enchant_limits"
|
||||||
const val ENCHANT_VALUES_ROOT = "enchant_values"
|
const val ENCHANT_VALUES_ROOT = "enchant_values"
|
||||||
|
|
||||||
|
const val DISABLE_MERGE_OVER_ROOT = "disable-merge-over"
|
||||||
|
|
||||||
// Keys for specific enchantment values
|
// Keys for specific enchantment values
|
||||||
private const val KEY_BOOK = "book"
|
private const val KEY_BOOK = "book"
|
||||||
private const val KEY_ITEM = "item"
|
private const val KEY_ITEM = "item"
|
||||||
|
|
@ -110,6 +112,9 @@ object ConfigOptions {
|
||||||
// Default value for an enchantment multiplier
|
// Default value for an enchantment multiplier
|
||||||
private const val DEFAULT_ENCHANT_VALUE = 0
|
private const val DEFAULT_ENCHANT_VALUE = 0
|
||||||
|
|
||||||
|
// Default max before merge disabled (negative mean enabled)
|
||||||
|
const val DEFAULT_MAX_BEFORE_MERGE_DISABLED = -1;
|
||||||
|
|
||||||
// -------------
|
// -------------
|
||||||
// Get methods
|
// Get methods
|
||||||
// -------------
|
// -------------
|
||||||
|
|
@ -374,4 +379,33 @@ object ConfigOptions {
|
||||||
return DEFAULT_ENCHANT_VALUE
|
return DEFAULT_ENCHANT_VALUE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the given [enchantmentName]'s level before merge is disabled
|
||||||
|
* a negative value would mean never disabled
|
||||||
|
*/
|
||||||
|
fun maxBeforeMergeDisabled(enchantment: CAEnchantment): Int {
|
||||||
|
return maxBeforeMergeDisabled(enchantment.enchantmentName)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the given [enchantmentName]'s level before merge is disabled
|
||||||
|
* a negative value would mean never disabled
|
||||||
|
*/
|
||||||
|
private fun maxBeforeMergeDisabled(enchantmentName: String) : Int {
|
||||||
|
// find if set
|
||||||
|
val path = "${DISABLE_MERGE_OVER_ROOT}.$enchantmentName"
|
||||||
|
|
||||||
|
val value = CustomAnvil.instance
|
||||||
|
.config
|
||||||
|
.getInt(path, DEFAULT_MAX_BEFORE_MERGE_DISABLED)
|
||||||
|
.takeIf { it in ENCHANT_LIMIT_RANGE }
|
||||||
|
?: DEFAULT_MAX_BEFORE_MERGE_DISABLED;
|
||||||
|
|
||||||
|
if((value == DEFAULT_MAX_BEFORE_MERGE_DISABLED) && (enchantmentName == "sweeping_edge")){
|
||||||
|
return maxBeforeMergeDisabled("sweeping")
|
||||||
|
}
|
||||||
|
|
||||||
|
return DEFAULT_MAX_BEFORE_MERGE_DISABLED
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,11 @@ object EnchantmentUtil {
|
||||||
}
|
}
|
||||||
// ... and they're the same level
|
// ... and they're the same level
|
||||||
else {
|
else {
|
||||||
// try to increase the enchantment level by 1
|
// We test if it is allowed to merge at this level
|
||||||
|
val maxBeforeDisabled = ConfigOptions.maxBeforeMergeDisabled(enchantment)
|
||||||
|
if((maxBeforeDisabled != -1) && (oldLevel >= maxBeforeDisabled)) return@forEach
|
||||||
|
|
||||||
|
// Now we increase the enchantment level by 1
|
||||||
var newLevel = oldLevel + 1
|
var newLevel = oldLevel + 1
|
||||||
newLevel = max(min(newLevel, maxLevel), oldLevel)
|
newLevel = max(min(newLevel, maxLevel), oldLevel)
|
||||||
this[enchantment] = newLevel
|
this[enchantment] = newLevel
|
||||||
|
|
|
||||||
|
|
@ -271,6 +271,17 @@ enchant_values:
|
||||||
item: 8
|
item: 8
|
||||||
book: 4
|
book: 4
|
||||||
|
|
||||||
|
# Disable enchantment merging for level above the set value
|
||||||
|
# Enchantment merging is when, for example, 2 unbreaking II book combine to give sharpness III
|
||||||
|
# But Enchantment above this value can still be applied. following the previous example, we could still apply a unbreaking III book to a sword
|
||||||
|
# Even if disable-merge-over of unbreaking is set to 2
|
||||||
|
# -1 mean enchantment merge for this enchantment is not disabled. default to -1 if absent.
|
||||||
|
disable-merge-over:
|
||||||
|
# Sharpness is set to -1. it equivalent to it not being set to anything (and work as vanilla)
|
||||||
|
sharpness: -1
|
||||||
|
# If uncommented. 2 unbreaking II book would not give an unbreaking III book. but unbreaking III book can still be applied
|
||||||
|
#unbreaking: 2
|
||||||
|
|
||||||
# Whether to show debug logging
|
# Whether to show debug logging
|
||||||
debug_log: false
|
debug_log: false
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue