aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMelncat <[email protected]>2022-10-18 00:33:58 -0700
committerGitHub <[email protected]>2022-10-18 09:33:58 +0200
commited2c88ba89b99fb31da43860be46c28f0dd60747 (patch)
treee50cd3c969ab33c86e019964604f96bef87c40ab
parent7d64d7ce779a1e625cc91de260659f57807faa7d (diff)
downloadPaper-ed2c88ba89b99fb31da43860be46c28f0dd60747.tar.gz
Paper-ed2c88ba89b99fb31da43860be46c28f0dd60747.zip
Add LivingEntity knockback API (#8479)
-rw-r--r--patches/api/0403-Add-entity-knockback-API.patch28
-rw-r--r--patches/server/0928-Add-entity-knockback-API.patch22
2 files changed, 50 insertions, 0 deletions
diff --git a/patches/api/0403-Add-entity-knockback-API.patch b/patches/api/0403-Add-entity-knockback-API.patch
new file mode 100644
index 0000000000..402bff1723
--- /dev/null
+++ b/patches/api/0403-Add-entity-knockback-API.patch
@@ -0,0 +1,28 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: MelnCat <[email protected]>
+Date: Sun, 16 Oct 2022 12:10:00 -0700
+Subject: [PATCH] Add entity knockback API
+
+
+diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
+index 319e4571aca24d1e3f6c85b7435d65c0e77a5245..c9a44e8024f903da83181ee752c971bab22c8895 100644
+--- a/src/main/java/org/bukkit/entity/LivingEntity.java
++++ b/src/main/java/org/bukkit/entity/LivingEntity.java
+@@ -1003,5 +1003,17 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
+ this.swingOffHand();
+ }
+ }
++
++ /**
++ * Knocks back this entity from a specific direction with a specified strength. Mechanics such
++ * as knockback resistance will be factored in.
++ *
++ * The direction specified in this method will be the direction of the source of the knockback,
++ * so the entity will be pushed in the opposite direction.
++ * @param strength The strength of the knockback. Must be greater than 0.
++ * @param directionX The relative x position of the knockback source direction
++ * @param directionZ The relative z position of the knockback source direction
++ */
++ void knockback(double strength, double directionX, double directionZ);
+ // Paper end
+ }
diff --git a/patches/server/0928-Add-entity-knockback-API.patch b/patches/server/0928-Add-entity-knockback-API.patch
new file mode 100644
index 0000000000..27409e5603
--- /dev/null
+++ b/patches/server/0928-Add-entity-knockback-API.patch
@@ -0,0 +1,22 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: MelnCat <[email protected]>
+Date: Sun, 16 Oct 2022 12:10:17 -0700
+Subject: [PATCH] Add entity knockback API
+
+
+diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+index e807ef287136e7b3931197e45434a3f618cf3054..06559a620b36f744c3d9fa2754e3c3eabead4752 100644
+--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+@@ -977,5 +977,11 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
+ }
+ throw new IllegalArgumentException(entityCategory + " is an unrecognized entity category");
+ }
++
++ @Override
++ public void knockback(double strength, double directionX, double directionZ) {
++ Preconditions.checkArgument(strength > 0, "Knockback strength must be > 0");
++ getHandle().knockback(strength, directionX, directionZ);
++ };
+ // Paper end
+ }