Fixed strange issue related to item meta.

Added more verbose debug log.
This commit is contained in:
alexcrea 2024-06-16 04:55:23 +02:00
parent 1eac81aef6
commit c7fee98d44
No known key found for this signature in database
GPG key ID: 43FD265DB0DBF91F
6 changed files with 23 additions and 21 deletions

View file

@ -452,6 +452,7 @@ class AnvilEventListener(private val packetManager: PacketManager) : Listener {
if (ConflictType.BIG_CONFLICT == conflictType) {
illegalPenalty += ConfigOptions.sacrificeIllegalCost
CustomAnvil.verboseLog("Big conflict. Adding illegal price penalty")
}
continue
}

View file

@ -29,13 +29,11 @@ object ItemUtil {
fun ItemStack.setEnchantmentsUnsafe(enchantments: Map<WrappedEnchantment, Int>) {
WrappedEnchantment.clearEnchants(this)
val meta = this.itemMeta ?: return
//TODO maybe faster methode to add vanilla enchantment. maybe move this function to wrapped enchantment
enchantments.forEach { (enchantment, level) ->
enchantment.addEnchantmentUnsafe(this, meta, level)
enchantment.addEnchantmentUnsafe(this, level)
}
this.itemMeta = meta
}
/**

View file

@ -18,6 +18,7 @@ class EnchantConflictGroup(
fun allowed(enchants: Set<WrappedEnchantment>, mat: Material): Boolean {
if (enchantments.size < minBeforeBlock) {
CustomAnvil.verboseLog("Conflicting bc of to many enchantments")
return true
}
@ -31,6 +32,7 @@ class EnchantConflictGroup(
if (enchantment !in enchantments) continue
CustomAnvil.verboseLog("Enchant ${enchantment.key} is in: ${enchantAmount + 1}/$minBeforeBlock ")
if (++enchantAmount > minBeforeBlock) {
CustomAnvil.verboseLog("it is not allowed bc of to many enchantment in conflict")
return false
}

View file

@ -160,13 +160,14 @@ class EnchantConflictManager {
var result = ConflictType.NO_CONFLICT
for (conflict in conflictList) {
CustomAnvil.verboseLog("Is against $conflict")
val conflicting = conflict.allowed(base, mat)
CustomAnvil.verboseLog("Was against $conflict and conflicting: $conflicting ")
if (!conflicting) {
val allowed = conflict.allowed(base, mat)
CustomAnvil.verboseLog("Was against $conflict and conflicting: ${!allowed} ")
if (!allowed) {
if (conflict.getEnchants().size <= 1) {
result = ConflictType.SMALL_CONFLICT
CustomAnvil.verboseLog("Small conflict, continuing")
} else {
CustomAnvil.verboseLog("Big conflict, probably stoping")
return ConflictType.BIG_CONFLICT
}
}