From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com> Date: Sun, 4 Aug 2024 19:34:29 +0800 Subject: [PATCH] Configurable player knockback zombie diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java index 6214467ae7e2e9d84e46abed00a94bc22d4a3da7..1904cdab2e2cc6e6996d4d1ba578f2dd0a005d08 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java @@ -2111,6 +2111,8 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } public void knockback(double strength, double x, double z, @Nullable Entity attacker, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause eventCause) { // Paper - knockback events + if (!canKnockback(attacker, this)) return; // Leaf - Configurable player knockback zombie + strength *= 1.0 - this.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE); if (true || !(strength <= 0.0)) { // CraftBukkit - Call event even when force is 0 // this.hasImpulse = true; // CraftBukkit - Move down @@ -2141,6 +2143,20 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } } + // Leaf start - Configurable player knockback zombie + private boolean canKnockback(@Nullable Entity attacker, LivingEntity target) { + if (!org.dreeam.leaf.config.modules.gameplay.Knockback.canPlayerKnockbackZombie) { + if (attacker instanceof ServerPlayer && target.getType() == EntityType.ZOMBIE) { // Player -> Zombie + return false; + } else if (attacker instanceof Projectile projectile && projectile.getOwner() instanceof ServerPlayer && target.getType() == EntityType.ZOMBIE) { // Player -> projectile -> Zombie + return false; + } + } + + return true; + } + // Leaf end - Configurable player knockback zombie + public void indicateDamage(double xDistance, double zDistance) { }