diff --git a/Spigot-API-Patches/Add-sun-related-API.patch b/Spigot-API-Patches/Add-sun-related-API.patch index ac326e04e0..1a5b92229f 100644 --- a/Spigot-API-Patches/Add-sun-related-API.patch +++ b/Spigot-API-Patches/Add-sun-related-API.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Add sun related API diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java -index 6b91635f..3d8ff98a 100644 +index 38dae649..107f4173 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 { 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 72f7eefe75..3ecdf59b8b 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,22 +18,29 @@ 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 84b7d93cf..334e31350 100644 +index 4c2a269d..2719eecb 100644 --- a/src/main/java/org/bukkit/Location.java +++ b/src/main/java/org/bukkit/Location.java +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable; + + // Paper start + import java.util.Collection; +-import java.util.Collections; + import java.util.function.Predicate; + import org.bukkit.entity.Entity; + import org.bukkit.entity.LivingEntity; @@ -0,0 +0,0 @@ public class Location implements Cloneable, ConfigurationSerializable { blockLoc.setZ(getBlockZ()); return blockLoc; } + + // Paper Start -+ + /** + * @return The block key for this location's block location. -+ * @see Block#getBlockKey() ++ * @see Block#getBlockKey(int, int, int) + */ + public long toBlockKey() { -+ return ((long)getBlockX() & 0x7FFFFFF) | (((long)getBlockZ() & 0x7FFFFFF) << 27) | ((long)getBlockY() << 54); ++ return Block.getBlockKey(getBlockX(), getBlockY(), getBlockZ()); + } + // Paper End + @@ -41,7 +48,7 @@ index 84b7d93cf..334e31350 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 1b0744ed9..158917492 100644 +index 1b0744ed..fa736b07 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 { @@ -54,29 +61,28 @@ index 1b0744ed9..158917492 100644 + * + * @param key The block key. See {@link Block#getBlockKey()} + * @return Block at the key -+ * @see Location#toBlockKey() -+ * @see Block#getBlockKey() ++ * @see Block#getBlockKey(int, int, int) + */ + @NotNull + public default Block getBlockAtKey(long key) { -+ int x = (int) ((key << 37) >> 37); -+ int y = (int) (key >>> 54); -+ int z = (int) ((key << 10) >> 37); ++ int x = Block.getBlockKeyX(key); ++ int y = Block.getBlockKeyY(key); ++ int z = Block.getBlockKeyZ(key); + return getBlockAt(x, y, z); + } ++ + /** + * 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() ++ * @see Block#getBlockKey(int, int, int) + */ + @NotNull + public default Location getLocationAtKey(long key) { -+ int x = (int) ((key << 37) >> 37); -+ int y = (int) (key >>> 54); -+ int z = (int) ((key << 10) >> 37); ++ int x = Block.getBlockKeyX(key); ++ int y = Block.getBlockKeyY(key); ++ int z = Block.getBlockKeyZ(key); + return new Location(this, x, y, z); + } + // Paper end @@ -85,7 +91,7 @@ index 1b0744ed9..158917492 100644 * 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 708288e99..42f31db29 100644 +index 708288e9..c20f903a 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 { @@ -93,29 +99,72 @@ index 708288e99..42f31db29 100644 int getZ(); + // Paper Start ++ /** ++ * Returns this block's coordinates packed into a long value. ++ * Computed via: {@code Block.getBlockKey(this.getX(), this.getY(), this.getZ())} ++ * @see Block#getBlockKey(int, int, int) ++ * @return This block's x, y, and z coordinates packed into a long value ++ */ ++ public default long getBlockKey() { ++ return Block.getBlockKey(this.getX(), this.getY(), this.getZ()); ++ } + + /** -+ * Returns this block's coordinates packed into a long value ++ * Returns the specified block coordinates packed into a long value + *
+ * The return value can be computed as follows:
+ *
-+ * {@code long value = ((long)getX() & 0x7FFFFFF) | (((long)getZ() & 0x7FFFFFF) << 27) | ((long)getY() << 54);}
++ * {@code long value = ((long)x & 0x7FFFFFF) | (((long)z & 0x7FFFFFF) << 27) | ((long)y << 54);}
++ *
+ *
+ * And may be unpacked as follows:
-+ *
++ *
+ * {@code int x = (int) ((packed << 37) >> 37);}
++ *
+ *
+ * {@code int y = (int) (packed >>> 54);}
++ *
+ *
+ * {@code int z = (int) ((packed << 10) >> 37);}
++ *
+ *