From e6f6a93187752540417aa5de7354430652d999bd Mon Sep 17 00:00:00 2001 From: NotAlexNoyle Date: Mon, 10 Aug 2026 07:50:07 -0400 Subject: [PATCH] Buff wardens --- src/main/kotlin/plugin/Config.kt | 13 +++++++++++++ src/main/kotlin/plugin/Listeners.kt | 25 +++++++++++++++++++++++++ src/main/resources/config.yml | 7 +++++++ 3 files changed, 45 insertions(+) diff --git a/src/main/kotlin/plugin/Config.kt b/src/main/kotlin/plugin/Config.kt index 274cc86..3ccb448 100644 --- a/src/main/kotlin/plugin/Config.kt +++ b/src/main/kotlin/plugin/Config.kt @@ -52,4 +52,17 @@ object Config { fun getWardenChance(): Double { return config.get("wardenChance") as Double } + + // Defaults are supplied here so configs written before this buff existed keep working + fun getWardenBuffEnabled(): Boolean { + return config.getBoolean("wardenBuffEnabled", true) + } + + fun getWardenHealthMultiplier(): Double { + return config.getDouble("wardenHealthMultiplier", 1.73) + } + + fun getWardenAttackDamageMultiplier(): Double { + return config.getDouble("wardenAttackDamageMultiplier", 2.8) + } } diff --git a/src/main/kotlin/plugin/Listeners.kt b/src/main/kotlin/plugin/Listeners.kt index bf293c4..eed761a 100644 --- a/src/main/kotlin/plugin/Listeners.kt +++ b/src/main/kotlin/plugin/Listeners.kt @@ -4,7 +4,10 @@ package plugin import kotlin.random.Random import org.bukkit.Material +import org.bukkit.attribute.Attribute +import org.bukkit.entity.Entity import org.bukkit.entity.EntityType +import org.bukkit.entity.LivingEntity import org.bukkit.event.EventHandler import org.bukkit.event.Listener import org.bukkit.event.entity.CreatureSpawnEvent @@ -36,6 +39,28 @@ class Listeners : Listener { if (reason == CreatureSpawnEvent.SpawnReason.RAID && raiderQuantity > 0) { repeat(raiderQuantity) { world.spawnEntity(pos, type, CreatureSpawnEvent.SpawnReason.CUSTOM) } } + + if (type == EntityType.WARDEN && Config.getWardenBuffEnabled()) { + buffWarden(event.entity) + } + } + + // 1.8 combat lets players land 2 full hits per second instead of 1.6 and 1.8 armour absorbs a flat + // 80%, so warden health and melee damage are scaled to keep the fight as hard as it is under 1.9. + // Attribute base values persist in entity NBT, so each warden is buffed once at spawn. + private fun buffWarden(entity: Entity) { + if (entity !is LivingEntity) return + + val maxHealth = entity.getAttribute(Attribute.GENERIC_MAX_HEALTH) + if (maxHealth != null) { + maxHealth.baseValue = maxHealth.baseValue * Config.getWardenHealthMultiplier() + entity.health = maxHealth.value + } + + val attackDamage = entity.getAttribute(Attribute.GENERIC_ATTACK_DAMAGE) + if (attackDamage != null) { + attackDamage.baseValue = attackDamage.baseValue * Config.getWardenAttackDamageMultiplier() + } } @EventHandler(ignoreCancelled = true) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 2e6af9d..007e918 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -19,3 +19,10 @@ zombieIron: 0.1 # chance to spawn a warden wardenChanceEnabled: false wardenChance: 0.001 + +# warden buff keeping 1.8 combat as hard as 1.9 +# health x1.73 restores time-to-kill lost to the faster 1.8 hit rate +# damage x2.8 offsets 1.8 armour absorbing a flat 80% +wardenBuffEnabled: true +wardenHealthMultiplier: 1.73 +wardenAttackDamageMultiplier: 2.8