mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
add World#getLocationAtKey for Block Key API
For when you don't want to actually load the block
This commit is contained in:
parent
9920287a0f
commit
4cf5e15b50
1 changed files with 19 additions and 5 deletions
|
@ -18,7 +18,7 @@ Y range: [0, 1023]
|
|||
X, Z range: [-67 108 864, 67 108 863]
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Location.java b/src/main/java/org/bukkit/Location.java
|
||||
index 253f0c2d..a457abcf 100644
|
||||
index 8dcb15fb8..7e1ee875e 100644
|
||||
--- a/src/main/java/org/bukkit/Location.java
|
||||
+++ b/src/main/java/org/bukkit/Location.java
|
||||
@@ -0,0 +0,0 @@ import org.bukkit.util.Vector;
|
||||
|
@ -49,14 +49,14 @@ index 253f0c2d..a457abcf 100644
|
|||
* @return A new location where X/Y/Z are the center of the block
|
||||
*/
|
||||
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
|
||||
index 7b166b21..21c43dea 100644
|
||||
index 9b46e8892..a6facc4b0 100644
|
||||
--- a/src/main/java/org/bukkit/World.java
|
||||
+++ b/src/main/java/org/bukkit/World.java
|
||||
@@ -0,0 +0,0 @@ public interface World extends PluginMessageRecipient, Metadatable {
|
||||
*/
|
||||
public Block getBlockAt(Location location);
|
||||
|
||||
+ // Paper Start
|
||||
+ // Paper start
|
||||
+ /**
|
||||
+ * Gets the {@link Block} at the given block key
|
||||
+ *
|
||||
|
@ -71,13 +71,27 @@ index 7b166b21..21c43dea 100644
|
|||
+ int z = (int) ((key << 10) >> 37);
|
||||
+ return getBlockAt(x, y, z);
|
||||
+ }
|
||||
+ // Paper End
|
||||
+ /**
|
||||
+ * Gets the {@link Location} at the given block key
|
||||
+ *
|
||||
+ * @param key The block key. See {@link Location#toBlockKey()}
|
||||
+ * @return Location at the key
|
||||
+ * @see Location#toBlockKey()
|
||||
+ * @see Block#getBlockKey()
|
||||
+ */
|
||||
+ public default Location getLocationAtKey(long key) {
|
||||
+ int x = (int) ((key << 37) >> 37);
|
||||
+ int y = (int) (key >>> 54);
|
||||
+ int z = (int) ((key << 10) >> 37);
|
||||
+ return new Location(this, x, y, z);
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
/**
|
||||
* Gets the block type ID at the given coordinates
|
||||
*
|
||||
diff --git a/src/main/java/org/bukkit/block/Block.java b/src/main/java/org/bukkit/block/Block.java
|
||||
index 359b81f3..2dbc784c 100644
|
||||
index 359b81f31..2dbc784cb 100644
|
||||
--- a/src/main/java/org/bukkit/block/Block.java
|
||||
+++ b/src/main/java/org/bukkit/block/Block.java
|
||||
@@ -0,0 +0,0 @@ public interface Block extends Metadatable {
|
||||
|
|
Loading…
Reference in a new issue