aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0741-Add-entity-knockback-API.patch
blob: 3fe877123b3c2afe464777e6fa43b6d4e72a9aca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MelnCat <melncatuwu@gmail.com>
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 2028f9874e96a3b274528858d4149b04a075f256..ed67bf4f30afa9dba604cc406b0a4fbe99dbb2b2 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -1146,4 +1146,12 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
         throw new UnsupportedOperationException("Cannot set the hurt direction on a non player");
     }
     // Paper end - hurt direction API
+
+    // Paper start - knockback API
+    @Override
+    public void knockback(final double strength, final double directionX, final double directionZ) {
+        Preconditions.checkArgument(strength > 0, "Knockback strength must be > 0");
+        this.getHandle().knockback(strength, directionX, directionZ);
+    };
+    // Paper end - knockback API
 }