From d7625d926d10bb7be4c7eaab15956ca8ffbf5d17 Mon Sep 17 00:00:00 2001 From: TwoLeggedCat <80929284+TwoLeggedCat@users.noreply.github.com> Date: Sat, 8 May 2021 03:25:30 -0500 Subject: [PATCH] Add new methods from PlayerMoveEvent to EntityMoveEvent (#5591) --- Spigot-API-Patches/0269-EntityMoveEvent.patch | 49 ++++++++++++++++++- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/Spigot-API-Patches/0269-EntityMoveEvent.patch b/Spigot-API-Patches/0269-EntityMoveEvent.patch index 947021163..6ebe08caa 100644 --- a/Spigot-API-Patches/0269-EntityMoveEvent.patch +++ b/Spigot-API-Patches/0269-EntityMoveEvent.patch @@ -6,10 +6,10 @@ Subject: [PATCH] EntityMoveEvent diff --git a/src/main/java/io/papermc/paper/event/entity/EntityMoveEvent.java b/src/main/java/io/papermc/paper/event/entity/EntityMoveEvent.java new file mode 100644 -index 0000000000000000000000000000000000000000..299ff57b3001b4be41cf2f0eea29ed82b8fb8ec7 +index 0000000000000000000000000000000000000000..a5c017dc0392a4bbdccf33d9e963f96cbfbc0d9a --- /dev/null +++ b/src/main/java/io/papermc/paper/event/entity/EntityMoveEvent.java -@@ -0,0 +1,95 @@ +@@ -0,0 +1,140 @@ +package io.papermc.paper.event.entity; + +import com.google.common.base.Preconditions; @@ -89,6 +89,51 @@ index 0000000000000000000000000000000000000000..299ff57b3001b4be41cf2f0eea29ed82 + this.to = to; + } + ++ /** ++ * Check if the entity has changed position (even within the same block) in the event ++ * ++ * @return whether the entity has changed position or not ++ */ ++ public boolean hasChangedPosition() { ++ return hasExplicitlyChangedPosition() || !from.getWorld().equals(to.getWorld()); ++ } ++ ++ /** ++ * Check if the entity has changed position (even within the same block) in the event, disregarding a possible world change ++ * ++ * @return whether the entity has changed position or not ++ */ ++ public boolean hasExplicitlyChangedPosition() { ++ return from.getX() != to.getX() || from.getY() != to.getY() || from.getZ() != to.getZ(); ++ } ++ ++ /** ++ * Check if the entity has moved to a new block in the event ++ * ++ * @return whether the entity has moved to a new block or not ++ */ ++ public boolean hasChangedBlock() { ++ return hasExplicitlyChangedBlock() || !from.getWorld().equals(to.getWorld()); ++ } ++ ++ /** ++ * Check if the entity has moved to a new block in the event, disregarding a possible world change ++ * ++ * @return whether the entity has moved to a new block or not ++ */ ++ public boolean hasExplicitlyChangedBlock() { ++ return from.getBlockX() != to.getBlockX() || from.getBlockY() != to.getBlockY() || from.getBlockZ() != to.getBlockZ(); ++ } ++ ++ /** ++ * Check if the entity has changed orientation in the event ++ * ++ * @return whether the entity has changed orientation or not ++ */ ++ public boolean hasChangedOrientation() { ++ return from.getPitch() != to.getPitch() || from.getYaw() != to.getYaw(); ++ } ++ + private void validateLocation(@NotNull Location loc) { + Preconditions.checkArgument(loc != null, "Cannot use null location!"); + Preconditions.checkArgument(loc.getWorld() != null, "Cannot use null location with null world!");