mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
Hacky fix for 1.20.5.
Also: - version up - metric fix (expected as config was changed) - Prepared for long term update system
This commit is contained in:
parent
2861238f58
commit
46ff34deea
7 changed files with 43 additions and 11 deletions
|
|
@ -4,7 +4,7 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "xyz.alexcrea"
|
group = "xyz.alexcrea"
|
||||||
version = "1.4.2a"
|
version = "1.4.3a"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|
|
||||||
|
|
@ -217,7 +217,7 @@ object ConfigOptions {
|
||||||
* Get the given [enchantment]'s limit
|
* Get the given [enchantment]'s limit
|
||||||
*/
|
*/
|
||||||
fun enchantLimit(enchantment: Enchantment): Int {
|
fun enchantLimit(enchantment: Enchantment): Int {
|
||||||
val path = "${ENCHANT_LIMIT_ROOT}.${enchantment.enchantmentName}"
|
val path = "${ENCHANT_LIMIT_ROOT}.${getEnchantKey(enchantment)}"
|
||||||
return CustomAnvil.instance
|
return CustomAnvil.instance
|
||||||
.config
|
.config
|
||||||
.getInt(path, defaultEnchantLimit)
|
.getInt(path, defaultEnchantLimit)
|
||||||
|
|
@ -234,7 +234,7 @@ object ConfigOptions {
|
||||||
isFromBook: Boolean
|
isFromBook: Boolean
|
||||||
): Int {
|
): Int {
|
||||||
val typeKey = if (isFromBook) KEY_BOOK else KEY_ITEM
|
val typeKey = if (isFromBook) KEY_BOOK else KEY_ITEM
|
||||||
val path = "${ENCHANT_VALUES_ROOT}.${enchantment.enchantmentName}.$typeKey"
|
val path = "${ENCHANT_VALUES_ROOT}.${getEnchantKey(enchantment)}.$typeKey"
|
||||||
return CustomAnvil.instance
|
return CustomAnvil.instance
|
||||||
.config
|
.config
|
||||||
.getInt(path, DEFAULT_ENCHANT_VALUE)
|
.getInt(path, DEFAULT_ENCHANT_VALUE)
|
||||||
|
|
@ -242,6 +242,13 @@ object ConfigOptions {
|
||||||
?: DEFAULT_ENCHANT_VALUE
|
?: DEFAULT_ENCHANT_VALUE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getEnchantKey(enchantment: Enchantment) : String{
|
||||||
|
val enchantKey = enchantment.enchantmentName
|
||||||
|
if(enchantKey == "sweeping_edge"){ // compatibility with 1.20.5. TODO better update system
|
||||||
|
return "sweeping"
|
||||||
|
}
|
||||||
|
return enchantKey
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Get an array of key of basic config options
|
* Get an array of key of basic config options
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,12 @@ class EnchantConflictManager {
|
||||||
|
|
||||||
// Default name for a joining group
|
// Default name for a joining group
|
||||||
private const val DEFAULT_GROUP_NAME = "joinedGroup"
|
private const val DEFAULT_GROUP_NAME = "joinedGroup"
|
||||||
|
|
||||||
|
// 1.20.5 compatibility TODO better update system
|
||||||
|
private val SWEEPING_EDGE_ENCHANT =
|
||||||
|
Enchantment.getByKey(NamespacedKey.minecraft("sweeping_edge")) ?:
|
||||||
|
Enchantment.SWEEPING_EDGE
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private lateinit var conflictMap: HashMap<Enchantment, ArrayList<EnchantConflictGroup>>
|
private lateinit var conflictMap: HashMap<Enchantment, ArrayList<EnchantConflictGroup>>
|
||||||
|
|
@ -76,8 +82,7 @@ class EnchantConflictManager {
|
||||||
// Read and add enchantment to conflict
|
// Read and add enchantment to conflict
|
||||||
val enchantList = section.getStringList(ENCH_LIST_PATH)
|
val enchantList = section.getStringList(ENCH_LIST_PATH)
|
||||||
for (enchantName in enchantList) {
|
for (enchantName in enchantList) {
|
||||||
val enchantKey = NamespacedKey.minecraft(enchantName)
|
val enchant = getEnchantByName(enchantName);
|
||||||
val enchant = Enchantment.getByKey(enchantKey)
|
|
||||||
if (enchant == null) {
|
if (enchant == null) {
|
||||||
if (!futureUse) {
|
if (!futureUse) {
|
||||||
CustomAnvil.instance.logger.warning("Enchantment $enchantName do not exist but was asked for conflict $conflictName")
|
CustomAnvil.instance.logger.warning("Enchantment $enchantName do not exist but was asked for conflict $conflictName")
|
||||||
|
|
@ -95,6 +100,20 @@ class EnchantConflictManager {
|
||||||
return conflict
|
return conflict
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getEnchantByName(enchantName: String): Enchantment? {
|
||||||
|
|
||||||
|
// Teporary solution for 1.20.5
|
||||||
|
when(enchantName){
|
||||||
|
"sweeping", "sweeping_edge" -> {
|
||||||
|
return SWEEPING_EDGE_ENCHANT
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val enchantKey = NamespacedKey.minecraft(enchantName)
|
||||||
|
return Enchantment.getByKey(enchantKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun createConflictObject(
|
private fun createConflictObject(
|
||||||
section: ConfigurationSection,
|
section: ConfigurationSection,
|
||||||
itemManager: ItemGroupManager,
|
itemManager: ItemGroupManager,
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,9 @@ import xyz.alexcrea.cuanvil.config.ConfigHolder
|
||||||
object MetricsUtil {
|
object MetricsUtil {
|
||||||
|
|
||||||
private const val baseConfigHash = -1592940914
|
private const val baseConfigHash = -1592940914
|
||||||
private const val enchantLimitsConfigHash = -1014133828
|
private const val enchantLimitsConfigHash = -275034280
|
||||||
private const val enchantValuesConfigHash = 1072574774
|
private const val enchantValuesConfigHash = -17048020
|
||||||
private const val enchantConflictConfigHash = 1406650190
|
private const val enchantConflictConfigHash = 546475833
|
||||||
private const val itemGroupsConfigHash = 1406650190
|
private const val itemGroupsConfigHash = 1406650190
|
||||||
private const val unitRepairItemConfigHash = 536871958
|
private const val unitRepairItemConfigHash = 536871958
|
||||||
private const val customAnvilCraftConfigHash = 0
|
private const val customAnvilCraftConfigHash = 0
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,7 @@ enchant_limits:
|
||||||
fire_aspect: 2
|
fire_aspect: 2
|
||||||
looting: 3
|
looting: 3
|
||||||
sweeping: 3
|
sweeping: 3
|
||||||
|
sweeping_edge: 3
|
||||||
efficiency: 5
|
efficiency: 5
|
||||||
unbreaking: 3
|
unbreaking: 3
|
||||||
fortune: 3
|
fortune: 3
|
||||||
|
|
@ -208,6 +209,9 @@ enchant_values:
|
||||||
sweeping:
|
sweeping:
|
||||||
item: 4
|
item: 4
|
||||||
book: 2
|
book: 2
|
||||||
|
sweeping_edge:
|
||||||
|
item: 4
|
||||||
|
book: 2
|
||||||
thorns:
|
thorns:
|
||||||
item: 8
|
item: 8
|
||||||
book: 4
|
book: 4
|
||||||
|
|
@ -223,3 +227,5 @@ debug_log: false
|
||||||
|
|
||||||
# Whether to show verbose debug logging
|
# Whether to show verbose debug logging
|
||||||
debug_log_verbose: false
|
debug_log_verbose: false
|
||||||
|
|
||||||
|
configVersion: 1.4.3
|
||||||
|
|
|
||||||
|
|
@ -147,8 +147,8 @@ restriction_soul_speed:
|
||||||
enchantments: [ soul_speed ]
|
enchantments: [ soul_speed ]
|
||||||
notAffectedGroups: [ enchanted_book, boots ]
|
notAffectedGroups: [ enchanted_book, boots ]
|
||||||
|
|
||||||
restriction_sweeping:
|
restriction_sweeping_edge:
|
||||||
enchantments: [ sweeping ]
|
enchantments: [ sweeping, sweeping_edge ]
|
||||||
notAffectedGroups: [ enchanted_book, swords ]
|
notAffectedGroups: [ enchanted_book, swords ]
|
||||||
|
|
||||||
# Do not exist in 1.18, that mean useInFuture will be set to true
|
# Do not exist in 1.18, that mean useInFuture will be set to true
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
main: io.delilaheve.CustomAnvil
|
main: io.delilaheve.CustomAnvil
|
||||||
name: CustomAnvil
|
name: CustomAnvil
|
||||||
prefix: "Custom Anvil"
|
prefix: "Custom Anvil"
|
||||||
version: 1.4.2a
|
version: 1.4.3a
|
||||||
description: Allow to customise anvil mechanics
|
description: Allow to customise anvil mechanics
|
||||||
api-version: 1.18
|
api-version: 1.18
|
||||||
load: POSTWORLD
|
load: POSTWORLD
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue