mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
Fixed strange issue related to item meta.
Added more verbose debug log.
This commit is contained in:
parent
1eac81aef6
commit
c7fee98d44
6 changed files with 23 additions and 21 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue