Port basic lookAt methods from Player to Entity (#11775)

This commit is contained in:
Pedro
2024-12-24 19:00:07 -03:00
committed by GitHub
parent 321d17cc8c
commit d568e175ee
4 changed files with 48 additions and 44 deletions

View File

@ -3,6 +3,7 @@ package org.bukkit.entity;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import io.papermc.paper.entity.LookAnchor;
import org.bukkit.Chunk; // Paper
import org.bukkit.EntityEffect;
import org.bukkit.Location;
@ -150,6 +151,26 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
* @return <code>true</code> if the teleport was successful
*/
boolean teleport(@NotNull Location location, @NotNull TeleportCause cause, @NotNull io.papermc.paper.entity.TeleportFlag @NotNull... teleportFlags);
/**
* Causes the entity to look towards the given position.
*
* @param x x coordinate
* @param y y coordinate
* @param z z coordinate
* @param entityAnchor What part of the entity should face the given position
*/
void lookAt(double x, double y, double z, @NotNull LookAnchor entityAnchor);
/**
* Causes the entity to look towards the given position.
*
* @param position Position to look at in the player's current world
* @param entityAnchor What part of the entity should face the given position
*/
default void lookAt(@NotNull io.papermc.paper.math.Position position, @NotNull LookAnchor entityAnchor) {
this.lookAt(position.x(), position.y(), position.z(), entityAnchor);
}
// Paper end - Teleport API
/**

View File

@ -9,6 +9,7 @@ import java.util.Date;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import io.papermc.paper.entity.LookAnchor;
import org.bukkit.BanEntry;
import org.bukkit.DyeColor;
import org.bukkit.Effect;
@ -1309,8 +1310,8 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
* they have seen it before because this method was called.
* Note this method does not make the player invulnerable, which is normally expected when viewing credits.
*
* @see #hasSeenWinScreen()
* @see #setHasSeenWinScreen(boolean)
* @see #hasSeenWinScreen()
* @see #setHasSeenWinScreen(boolean)
* @see <a href="https://minecraft.wiki/wiki/End_Poem#Technical_details">https://minecraft.wiki/wiki/End_Poem#Technical_details</a>
*/
public void showWinScreen();
@ -3392,7 +3393,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
* @param simulationDistance the player's new simulation distance
*/
public void setSimulationDistance(int simulationDistance);
/**
* Gets the no-ticking view distance for this player.
* <p>
@ -3730,26 +3731,6 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
*/
void setRotation(float yaw, float pitch);
/**
* Causes the player to look towards the given position.
*
* @param x x coordinate
* @param y y coordinate
* @param z z coordinate
* @param playerAnchor What part of the player should face the given position
*/
void lookAt(double x, double y, double z, @NotNull io.papermc.paper.entity.LookAnchor playerAnchor);
/**
* Causes the player to look towards the given position.
*
* @param position Position to look at in the player's current world
* @param playerAnchor What part of the player should face the given position
*/
default void lookAt(@NotNull io.papermc.paper.math.Position position, @NotNull io.papermc.paper.entity.LookAnchor playerAnchor) {
this.lookAt(position.x(), position.y(), position.z(), playerAnchor);
}
/**
* Causes the player to look towards the given entity.
*
@ -3757,7 +3738,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
* @param playerAnchor What part of the player should face the entity
* @param entityAnchor What part of the entity the player should face
*/
void lookAt(@NotNull org.bukkit.entity.Entity entity, @NotNull io.papermc.paper.entity.LookAnchor playerAnchor, @NotNull io.papermc.paper.entity.LookAnchor entityAnchor);
void lookAt(@NotNull org.bukkit.entity.Entity entity, @NotNull LookAnchor playerAnchor, @NotNull LookAnchor entityAnchor);
// Paper end - Teleport API
// Paper start