9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-29 11:59:24 +00:00
Files
Leaf/leaf-server/minecraft-patches/features/0164-Configurable-player-knockback-zombie.patch
Dreeam 3c25377465 Drop some unused patches
ClassInstanceMultiMap belongs to Minecraft vanilla entity storage.
And is unused, since replaced by spottedleaf's entity storage (rewrite chunk system).
However these patches might be useful for vanilla entity storage if is used.
2025-07-09 04:20:02 +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 4fc9b64bce70ef1169cf361d1414553f63f047ec..d81d1303fc3d23b35dbc177dd6a4c7f489eb5381 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) {
}