-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configurable player knockback zombie
- Loading branch information
1 parent
8bcdca0
commit 6f892c1
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
patches/server/0092-Configurable-player-knockback-zombie.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
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/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java | ||
index 7c75298c8ea7a828c2d9cd4e7ffd4d09a0113aed..8b0cd878d8bf633283b645dc06dfbb98c06e269f 100644 | ||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java | ||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java | ||
@@ -2028,6 +2028,8 @@ public abstract class LivingEntity extends Entity implements Attackable { | ||
} | ||
|
||
public void knockback(double d0, double d1, double d2, @Nullable Entity attacker, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause cause) { // Paper - knockback events | ||
+ if (!canKnockback(attacker, this)) return; // Leaf - Configurable player knockback zombie | ||
+ | ||
d0 *= 1.0D - this.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE); | ||
if (true || d0 > 0.0D) { // CraftBukkit - Call event even when force is 0 | ||
//this.hasImpulse = true; // CraftBukkit - Move down | ||
@@ -2055,6 +2057,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 deltaX, double deltaZ) {} | ||
|
||
@Nullable | ||
diff --git a/src/main/java/org/dreeam/leaf/config/modules/gameplay/Knockback.java b/src/main/java/org/dreeam/leaf/config/modules/gameplay/Knockback.java | ||
index 35e8a9568cd37f4ed75d10a38beea996c8729388..df26a6e47fba5781000bafbda735629f9057971f 100644 | ||
--- a/src/main/java/org/dreeam/leaf/config/modules/gameplay/Knockback.java | ||
+++ b/src/main/java/org/dreeam/leaf/config/modules/gameplay/Knockback.java | ||
@@ -11,6 +11,7 @@ public class Knockback extends ConfigModules { | ||
|
||
public static boolean snowballCanKnockback = false; | ||
public static boolean eggCanKnockback = false; | ||
+ public static boolean canPlayerKnockbackZombie = true; | ||
|
||
@Override | ||
public void onLoaded() { | ||
@@ -18,5 +19,7 @@ public class Knockback extends ConfigModules { | ||
"Make snowball can knockback players"); | ||
eggCanKnockback = config.getBoolean(getBasePath() + ".egg-knockback-players", eggCanKnockback, | ||
"Make egg can knockback players"); | ||
+ canPlayerKnockbackZombie = config.getBoolean(getBasePath() + ".can-player-knockback-zombie", canPlayerKnockbackZombie, | ||
+ "Make players can knockback zombie"); | ||
} | ||
} |