PaperMC/patches/server/0748-Add-entity-knockback-API.patch
Noah van der Aa d52e2d241d
MOOOOOOOORE
2024-10-23 23:35:21 +02:00

23 lines
1.2 KiB
Diff

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 14b4c3835388d957653ba34444968bb718ce7f68..4fa19ddb1414282020e118eea298d57d2bf42754 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
}