From cf24658d7888f1e4ca7faa4fa85c90cf87f3da29 Mon Sep 17 00:00:00 2001 From: Sudzzy Date: Wed, 2 Mar 2016 14:48:03 -0600 Subject: [PATCH] Disable explosion knockback diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java index a39451c69a..65a99b2a4b 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -159,4 +159,9 @@ public class PaperWorldConfig { optimizeExplosions = getBoolean("optimize-explosions", false); log("Optimize explosions: " + optimizeExplosions); } + + public boolean disableExplosionKnockback; + private void disableExplosionKnockback(){ + disableExplosionKnockback = getBoolean("disable-explosion-knockback", false); + } } diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java index b092b0fa23..c5cc0b471b 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java @@ -1006,6 +1006,7 @@ public abstract class EntityLiving extends Entity { } } + boolean knockbackCancelled = world.paperConfig.disableExplosionKnockback && damagesource.isExplosion() && this instanceof EntityHuman; // Paper - Disable explosion knockback if (flag1) { if (flag) { this.world.broadcastEntityEffect(this, (byte) 29); @@ -1022,6 +1023,7 @@ public abstract class EntityLiving extends Entity { b0 = 2; } + if (!knockbackCancelled) // Paper - Disable explosion knockback this.world.broadcastEntityEffect(this, b0); } @@ -1045,6 +1047,8 @@ public abstract class EntityLiving extends Entity { } } + if (knockbackCancelled) this.world.broadcastEntityEffect(this, (byte) 2); // Paper - Disable explosion knockback + if (this.getHealth() <= 0.0F) { if (!this.e(damagesource)) { SoundEffect soundeffect = this.cs(); diff --git a/src/main/java/net/minecraft/server/Explosion.java b/src/main/java/net/minecraft/server/Explosion.java index 3e44b2d549..5591ccb3b0 100644 --- a/src/main/java/net/minecraft/server/Explosion.java +++ b/src/main/java/net/minecraft/server/Explosion.java @@ -153,7 +153,7 @@ public class Explosion { double d14 = d13; if (entity instanceof EntityLiving) { - d14 = EnchantmentProtection.a((EntityLiving) entity, d13); + d14 = entity instanceof EntityHuman && world.paperConfig.disableExplosionKnockback ? 0 : EnchantmentProtection.a((EntityLiving) entity, d13); // Paper - Disable explosion knockback } entity.motX += d8 * d14; @@ -162,7 +162,7 @@ public class Explosion { if (entity instanceof EntityHuman) { EntityHuman entityhuman = (EntityHuman) entity; - if (!entityhuman.isSpectator() && (!entityhuman.u() || !entityhuman.abilities.isFlying)) { + if (!entityhuman.isSpectator() && (!entityhuman.u() && !world.paperConfig.disableExplosionKnockback || !entityhuman.abilities.isFlying)) { // Paper - Disable explosion knockback this.l.put(entityhuman, new Vec3D(d8 * d13, d9 * d13, d10 * d13)); } } -- 2.21.0