9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-19 15:09:25 +00:00
Files
Leaf/leaf-server/minecraft-patches/features/0168-Configurable-player-knockback-zombie.patch
2025-06-28 10:37:38 +08:00

41 lines
2.0 KiB
Diff

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 ba6d9a5df71e9aae9defedf5bbe12f49599123cb..4c3eadc2d8480b2a2c2c08e58620544d403d3adc 100644
--- a/net/minecraft/world/entity/LivingEntity.java
+++ b/net/minecraft/world/entity/LivingEntity.java
@@ -2079,6 +2079,8 @@ public abstract class LivingEntity extends Entity implements Attackable {
}
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
@@ -2109,6 +2111,20 @@ public abstract class LivingEntity extends Entity implements Attackable {
}
}
+ // 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) {
}