From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Video Date: Mon, 11 Apr 2022 13:33:52 -0600 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 1c7794de5f0a7238b944c9473e2cc9d011ef2306..9c594c504611b9da5fcd119284b2dcb4b59d3bf4 100644 --- a/src/main/java/net/minecraft/world/effect/HealOrHarmMobEffect.java +++ b/src/main/java/net/minecraft/world/effect/HealOrHarmMobEffect.java @@ -16,6 +16,11 @@ class HealOrHarmMobEffect extends InstantenousMobEffect { @Override public void applyEffectTick(LivingEntity entity, int amplifier) { super.applyEffectTick(entity, 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; + 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 { @@ -27,6 +32,10 @@ class HealOrHarmMobEffect extends InstantenousMobEffect { @Override 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);