From 879cd12f0287ddb77e0fb0bfb076f69b02268062 Mon Sep 17 00:00:00 2001 From: Caltinor <62700786+Caltinor@users.noreply.github.com> Date: Tue, 10 Dec 2024 08:02:01 -0500 Subject: [PATCH] fix damage reduce stacking with damage in --- src/main/java/harmonised/pmmo/core/perks/FeaturePerks.java | 7 ++++--- .../harmonised/pmmo/events/impl/DamageReceivedHandler.java | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/harmonised/pmmo/core/perks/FeaturePerks.java b/src/main/java/harmonised/pmmo/core/perks/FeaturePerks.java index 59c11174..fe5b5b14 100644 --- a/src/main/java/harmonised/pmmo/core/perks/FeaturePerks.java +++ b/src/main/java/harmonised/pmmo/core/perks/FeaturePerks.java @@ -266,12 +266,13 @@ else if (perkApplicableDamageType.endsWith(":*") && perkApplicableDamageType.sub .withInt(APIUtils.MAX_BOOST, Integer.MAX_VALUE) .withString(APIUtils.DAMAGE_TYPE_IN, "omitted").build()) .setStart((player, nbt) -> { - float saved = (int)(nbt.getDouble(APIUtils.PER_LEVEL) * (double)nbt.getInt(APIUtils.SKILL_LEVEL)) + nbt.getInt(APIUtils.BASE); - saved = Math.min(nbt.getInt(APIUtils.MAX_BOOST), saved); + float saved = (nbt.getFloat(APIUtils.PER_LEVEL) * (float)nbt.getInt(APIUtils.SKILL_LEVEL)) + nbt.getFloat(APIUtils.BASE); + saved = Math.min(nbt.getFloat(APIUtils.MAX_BOOST), saved); float baseDamage = nbt.contains(APIUtils.DAMAGE_OUT) ? nbt.getFloat(APIUtils.DAMAGE_OUT) : nbt.getFloat(APIUtils.DAMAGE_IN); - return TagBuilder.start().withFloat(APIUtils.DAMAGE_OUT, Math.max(baseDamage - saved, 0)).build(); + nbt.putFloat(APIUtils.DAMAGE_OUT, Math.max(baseDamage - saved, 0)); + return nbt; }) .setDescription(LangProvider.PERK_FALL_SAVE_DESC.asComponent()) .setStatus((player, nbt) -> List.of( diff --git a/src/main/java/harmonised/pmmo/events/impl/DamageReceivedHandler.java b/src/main/java/harmonised/pmmo/events/impl/DamageReceivedHandler.java index da9fce41..a2919cbd 100644 --- a/src/main/java/harmonised/pmmo/events/impl/DamageReceivedHandler.java +++ b/src/main/java/harmonised/pmmo/events/impl/DamageReceivedHandler.java @@ -52,7 +52,6 @@ public static void handle(LivingDamageEvent.Pre event) { CompoundTag perkDataIn = eventHookOutput.copy(); perkDataIn.putString(APIUtils.DAMAGE_TYPE, damageType); perkDataIn.putFloat(APIUtils.DAMAGE_IN, container.getNewDamage()); - perkDataIn.putFloat(APIUtils.DAMAGE_OUT, container.getNewDamage()); CompoundTag perkOutput = TagUtils.mergeTags(perkDataIn, core.getPerkRegistry().executePerk(EventType.RECEIVE_DAMAGE, player, perkDataIn)); if (perkOutput.contains(APIUtils.DAMAGE_OUT)) { float damageOut = perkOutput.getFloat(APIUtils.DAMAGE_OUT);