From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Telesphoreo Date: Wed, 8 May 2024 12:46:29 -0500 Subject: [PATCH] Fixes creative-killing potion effects and certain potion effect overflows diff --git a/src/main/java/net/minecraft/world/effect/HealOrHarmMobEffect.java b/src/main/java/net/minecraft/world/effect/HealOrHarmMobEffect.java index b95afa9f6b7cf6c522ff5ec278adec7a9a851e9a..3f65f24936cdf3379e39bab3cd8bd46aacd95518 100644 --- a/src/main/java/net/minecraft/world/effect/HealOrHarmMobEffect.java +++ b/src/main/java/net/minecraft/world/effect/HealOrHarmMobEffect.java @@ -15,6 +15,10 @@ class HealOrHarmMobEffect extends InstantenousMobEffect { @Override public boolean applyEffectTick(LivingEntity entity, int amplifier) { + // Scissors start - Don't apply any healing/harming effects for Creative/Invulnerable players and cap the amplifier for those who aren't. + if (entity instanceof net.minecraft.world.entity.player.Player player && (player.isCreative() || player.isInvulnerable())) return false; + amplifier = Math.min(Math.abs(amplifier), 124); + // Scissors end if (this.isHarm == entity.isInvertedHealAndHarm()) { entity.heal((float) Math.max(4 << amplifier, 0), org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.MAGIC); // CraftBukkit } else { @@ -28,6 +32,11 @@ class HealOrHarmMobEffect extends InstantenousMobEffect { public void applyInstantenousEffect(@Nullable Entity source, @Nullable Entity attacker, LivingEntity target, int amplifier, double proximity) { int j; + // Scissors start - Don't apply any healing/harming effects for Creative/Invulnerable players and cap the amplifier for those who aren't. + if (target instanceof net.minecraft.world.entity.player.Player player && (player.isCreative() || player.isInvulnerable())) return; + amplifier = Math.min(Math.abs(amplifier), 124); + // Scissors end + if (this.isHarm == target.isInvertedHealAndHarm()) { j = (int) (proximity * (double) (4 << amplifier) + 0.5D); target.heal((float) j, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.MAGIC); // CraftBukkit