From 1ae5949775be87e5606f75bf7552b7ccca59e3a8 Mon Sep 17 00:00:00 2001 From: HellionGames Date: Thu, 29 Jun 2023 10:32:56 -0400 Subject: [PATCH] Fix Freezing being infinitely stackable Fixes #51 --- .../infernalstudios/miningmaster/mixin/MixinAbstractArrow.java | 2 +- .../org/infernalstudios/miningmaster/mixin/MixinPlayer.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/infernalstudios/miningmaster/mixin/MixinAbstractArrow.java b/src/main/java/org/infernalstudios/miningmaster/mixin/MixinAbstractArrow.java index 4a3bf6e..2a4238e 100644 --- a/src/main/java/org/infernalstudios/miningmaster/mixin/MixinAbstractArrow.java +++ b/src/main/java/org/infernalstudios/miningmaster/mixin/MixinAbstractArrow.java @@ -53,7 +53,7 @@ private void MM_setEnchantsOnCreation(EntityType entityType, LivingEntity shoote private void MM_dealArrowEnchants(EntityHitResult hitResult, CallbackInfo ci) { if (this.freezingLevel > 0) { if (hitResult.getEntity() instanceof LivingEntity livingEntity && !livingEntity.level.isClientSide()) { - livingEntity.setTicksFrozen(livingEntity.getTicksFrozen() + livingEntity.getTicksRequiredToFreeze() + 120 * this.freezingLevel); + livingEntity.setTicksFrozen(Math.max(livingEntity.getTicksFrozen(), livingEntity.getTicksRequiredToFreeze() + 120 * this.freezingLevel)); } } diff --git a/src/main/java/org/infernalstudios/miningmaster/mixin/MixinPlayer.java b/src/main/java/org/infernalstudios/miningmaster/mixin/MixinPlayer.java index 03da2e1..dc56fc3 100644 --- a/src/main/java/org/infernalstudios/miningmaster/mixin/MixinPlayer.java +++ b/src/main/java/org/infernalstudios/miningmaster/mixin/MixinPlayer.java @@ -56,7 +56,7 @@ private void MM_calculateEnchantEffects(Entity targetEntity, CallbackInfo ci, fl private void applyFreezingEffects(Entity targetEntity, int level) { if (targetEntity instanceof LivingEntity livingTarget && !livingTarget.level.isClientSide()) { - livingTarget.setTicksFrozen(livingTarget.getTicksFrozen() + livingTarget.getTicksRequiredToFreeze() + 120 * level); + livingTarget.setTicksFrozen(Math.max(livingTarget.getTicksFrozen(), livingTarget.getTicksRequiredToFreeze() + 120 * level)); } }