Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 04:20:04 +01:00
Location.toBlockLocation
Convert location objects to their block coordinates, or the center of the block
Dieser Commit ist enthalten in:
Ursprung
d45565f83b
Commit
45308a08d7
46
Spigot-API-Patches/0107-Location.toBlockLocation.patch
Normale Datei
46
Spigot-API-Patches/0107-Location.toBlockLocation.patch
Normale Datei
@ -0,0 +1,46 @@
|
||||
From 33768a6eb01492a7ce72ab71a02afcf32ee8186b Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Thu, 24 May 2018 21:01:13 -0400
|
||||
Subject: [PATCH] Location.toBlockLocation
|
||||
|
||||
Convert location objects to their block coordinates, or the center of the block
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Location.java b/src/main/java/org/bukkit/Location.java
|
||||
index 1ddebf3c..5c70e80d 100644
|
||||
--- a/src/main/java/org/bukkit/Location.java
|
||||
+++ b/src/main/java/org/bukkit/Location.java
|
||||
@@ -492,6 +492,31 @@ public class Location implements Cloneable, ConfigurationSerializable {
|
||||
}
|
||||
|
||||
public boolean isChunkLoaded() { return world.isChunkLoaded(locToBlock(x) >> 4, locToBlock(z) >> 4); } // Paper
|
||||
+
|
||||
+ // Paper start
|
||||
+ /**
|
||||
+ * @return A new location where X/Y/Z are on the Block location (integer value of X/Y/Z)
|
||||
+ */
|
||||
+ public Location toBlockLocation() {
|
||||
+ return toBlockLocation(false);
|
||||
+ }
|
||||
+ /**
|
||||
+ * @return A new location where X/Y/Z are on the Block location (integer value of X/Y/Z), or optionally the center
|
||||
+ */
|
||||
+ public Location toBlockLocation(boolean center) {
|
||||
+ Location blockLoc = clone();
|
||||
+ if (center) {
|
||||
+ blockLoc.setX(getBlockX() + 0.5);
|
||||
+ blockLoc.setY(getBlockY() + 0.5);
|
||||
+ blockLoc.setZ(getBlockZ() + 0.5);
|
||||
+ } else {
|
||||
+ blockLoc.setX(getBlockX());
|
||||
+ blockLoc.setY(getBlockY());
|
||||
+ blockLoc.setZ(getBlockZ());
|
||||
+ }
|
||||
+ return blockLoc;
|
||||
+ }
|
||||
+ // Paper end
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
--
|
||||
2.17.0
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren