Paper/patches/server/0626-Add-Mob-lookAt-API.patch

65 lines
3.2 KiB
Diff
Raw Normal View History

2021-06-15 04:59:31 +02:00
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 c92f7f31c3bf96f22fb1d2e783b14b80512448a0..4d0c6e3aaf984e295061d878dd4a8ef4d19511cb 100644
2021-06-15 04:59:31 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
@@ -99,5 +99,53 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob {
2021-06-15 04:59:31 +02:00
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
}