aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0551-Add-Mob-lookAt-API.patch
blob: 3139490a6152f012c1b297df811cb1a03d26bb09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: BillyGalbreath <blake.galbreath@gmail.com>
Date: Fri, 14 May 2021 13:42:17 -0500
Subject: [PATCH] Add Mob#lookAt API


diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
index 2a8596e4f9d7be966c18e867c2c7b5bfbea9742c..60d09655c5b8b9ff289291ee6badfb5aadf8533e 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
@@ -96,5 +96,53 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob {
     public boolean isInDaylight() {
         return getHandle().isSunBurnTick();
     }
+
+    @Override
+    public void lookAt(@org.jetbrains.annotations.NotNull org.bukkit.Location location) {
+        com.google.common.base.Preconditions.checkNotNull(location, "location cannot be null");
+        com.google.common.base.Preconditions.checkArgument(location.getWorld().equals(getWorld()), "location in a different world");
+        getHandle().getLookControl().setLookAt(location.getX(), location.getY(), location.getZ());
+    }
+
+    @Override
+    public void lookAt(@org.jetbrains.annotations.NotNull org.bukkit.Location location, float headRotationSpeed, float maxHeadPitch) {
+        com.google.common.base.Preconditions.checkNotNull(location, "location cannot be null");
+        com.google.common.base.Preconditions.checkArgument(location.getWorld().equals(getWorld()), "location in a different world");
+        getHandle().getLookControl().setLookAt(location.getX(), location.getY(), location.getZ(), headRotationSpeed, maxHeadPitch);
+    }
+
+    @Override
+    public void lookAt(@org.jetbrains.annotations.NotNull org.bukkit.entity.Entity entity) {
+        com.google.common.base.Preconditions.checkNotNull(entity, "entity cannot be null");
+        com.google.common.base.Preconditions.checkArgument(entity.getWorld().equals(getWorld()), "entity in a different world");
+        getHandle().getLookControl().setLookAt(((CraftEntity) entity).getHandle());
+    }
+
+    @Override
+    public void lookAt(@org.jetbrains.annotations.NotNull org.bukkit.entity.Entity entity, float headRotationSpeed, float maxHeadPitch) {
+        com.google.common.base.Preconditions.checkNotNull(entity, "entity cannot be null");
+        com.google.common.base.Preconditions.checkArgument(entity.getWorld().equals(getWorld()), "entity in a different world");
+        getHandle().getLookControl().setLookAt(((CraftEntity) entity).getHandle(), headRotationSpeed, maxHeadPitch);
+    }
+
+    @Override
+    public void lookAt(double x, double y, double z) {
+        getHandle().getLookControl().setLookAt(x, y, z);
+    }
+
+    @Override
+    public void lookAt(double x, double y, double z, float headRotationSpeed, float maxHeadPitch) {
+        getHandle().getLookControl().setLookAt(x, y, z, headRotationSpeed, maxHeadPitch);
+    }
+
+    @Override
+    public int getHeadRotationSpeed() {
+        return getHandle().getHeadRotSpeed();
+    }
+
+    @Override
+    public int getMaxHeadPitch() {
+        return getHandle().getMaxHeadXRot();
+    }
     // Paper end
 }