Skip to content

Commit

Permalink
fix damage reduce stacking with damage in
Browse files Browse the repository at this point in the history
  • Loading branch information
Caltinor committed Dec 10, 2024
1 parent 7accc55 commit 879cd12
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/main/java/harmonised/pmmo/core/perks/FeaturePerks.java
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 879cd12

Please sign in to comment.