mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-16 06:30:46 +01:00
Add new methods from PlayerMoveEvent to EntityMoveEvent (#5591)
This commit is contained in:
parent
7bc482249f
commit
0f71d4bcab
1 changed files with 45 additions and 0 deletions
|
@ -89,6 +89,51 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ 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!");
|
||||
|
|
Loading…
Reference in a new issue