mirror of
https://github.com/PaperMC/Paper.git
synced 2025-02-03 21:37:28 +01:00
Check for world change in MoveEvent API methods
This commit is contained in:
parent
306c8c7be4
commit
bad7e5b236
1 changed files with 30 additions and 12 deletions
|
@ -14,31 +14,49 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
|
||||
+ // Paper start - PlayerMoveEvent improvements
|
||||
+ /**
|
||||
+ * Check if the player has changed position in the event
|
||||
+ *
|
||||
+ * Check if the player has changed position (even within the same block) in the event
|
||||
+ *
|
||||
+ * @return whether the player has changed position or not
|
||||
+ */
|
||||
+ public boolean hasChangedPosition() {
|
||||
+ return hasExplicitlyChangedPosition() || !from.getWorld().equals(to.getWorld());
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Check if the player has changed position (even within the same block) in the event, disregarding a possible world change
|
||||
+ *
|
||||
+ * @return whether the player has changed position or not
|
||||
+ */
|
||||
+ public boolean hasExplicitlyChangedPosition() {
|
||||
+ return from.getX() != to.getX() || from.getY() != to.getY() || from.getZ() != to.getZ();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Check if the player has moved to a new block in the event
|
||||
+ *
|
||||
+ * @return whether the player has moved to a new block or not
|
||||
+ */
|
||||
+ public boolean hasChangedBlock() {
|
||||
+ return hasExplicitlyChangedBlock() || !from.getWorld().equals(to.getWorld());
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Check if the player has moved to a new block in the event, disregarding a possible world change
|
||||
+ *
|
||||
+ * @return whether the player 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 player has changed orientation in the event
|
||||
+ *
|
||||
+ *
|
||||
+ * @return whether the player has changed orientation or not
|
||||
+ */
|
||||
+ public boolean hasChangedOrientation() {
|
||||
+ return from.getPitch() != to.getPitch() || from.getYaw() != to.getYaw();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Check if the player has changed to a new block in the event
|
||||
+ *
|
||||
+ * @return whether the player has changed block or not
|
||||
+ */
|
||||
+ public boolean hasChangedBlock() {
|
||||
+ return from.getBlockX() != to.getBlockX() || from.getBlockY() != to.getBlockY() || from.getBlockZ() != to.getBlockZ();
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
private void validateLocation(@NotNull Location loc) {
|
||||
|
|
Loading…
Add table
Reference in a new issue