Merge branch 'master' into pre/1.13

* master:
  add World#getLocationAtKey for Block Key API
This commit is contained in:
Aikar 2018-08-19 11:53:05 -04:00
commit 236f91c82d

View file

@ -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 8dcb15fb..7e1ee875 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 8dcb15fb..7e1ee875 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 f84f151a..3d8b4925 100644
index f84f151ad..3170a0746 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 f84f151a..3d8b4925 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 y coordinate of the lowest block at this position such that the
* block and all blocks above it are transparent for lighting purposes.
diff --git a/src/main/java/org/bukkit/block/Block.java b/src/main/java/org/bukkit/block/Block.java
index 238de6f0..d700df53 100644
index 238de6f0a..d700df538 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 {