From 4cf5e15b50951d266f6e1b7caca649f83c6b4584 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 19 Aug 2018 11:50:40 -0400
Subject: [PATCH] add World#getLocationAtKey for Block Key API

For when you don't want to actually load the block
---
 ...Blocks-to-be-accessed-via-a-long-key.patch | 24 +++++++++++++++----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/Spigot-API-Patches/Allow-Blocks-to-be-accessed-via-a-long-key.patch b/Spigot-API-Patches/Allow-Blocks-to-be-accessed-via-a-long-key.patch
index 0e583e5aec..2898ac1b98 100644
--- a/Spigot-API-Patches/Allow-Blocks-to-be-accessed-via-a-long-key.patch
+++ b/Spigot-API-Patches/Allow-Blocks-to-be-accessed-via-a-long-key.patch
@@ -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 {