mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-27 04:55:47 +01:00
789bc79280
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: c9a46ebf #653: Add World#spawn with randomizeData parameter e49c2e3a Damageable should extend ItemMeta 01ff04f4 SPIGOT-5880, SPIGOT-5567: New ChunkGenerator API ca5b4b1a SPIGOT-6697: Deprecate generateTree with BlockChangeDelegate as it does not handle tiles CraftBukkit Changes: 7c8bbcbe SPIGOT-6716: Preserve the order of stored enchantments of enchanted books. 18027d02 #914: Add World#spawn with randomizeData parameter 3cad0316 SPIGOT-6714: Don't fire PlayerBucketEvent when empty 8c6d60cf Fix server crash with BlockPopulator when entities are at a negative chunk border 4f6bcc84 SPIGOT-5880, SPIGOT-5567: New ChunkGenerator API 78d5b35b SPIGOT-6697: Restore generateTree with BlockChangeDelegate behaviour 15792f0d Rebuild patch c949675e SPIGOT-6713: Cancelling EntityTransformEvent Causes Deceased Slimes To Not Despawn a955f15c Fix issues with new ChunkGenerator API a0a37f41 SPIGOT-6630: Replacing an enchantment on an item creates a conflict error Spigot Changes: b166a49b Rebuild patches 3c1fc60a SPIGOT-6693: Composters only take in one item at custom hopper speeds
197 lines
9.5 KiB
Diff
197 lines
9.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
|
Date: Sat, 1 Dec 2018 19:00:36 -0800
|
|
Subject: [PATCH] Add Heightmap API
|
|
|
|
Changed to use upstream's heightmap API - Machine_Maker
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/HeightmapType.java b/src/main/java/com/destroystokyo/paper/HeightmapType.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..709e44ea1b14ab6917501c928e689cc6cbdf4bb4
|
|
--- /dev/null
|
|
+++ b/src/main/java/com/destroystokyo/paper/HeightmapType.java
|
|
@@ -0,0 +1,39 @@
|
|
+package com.destroystokyo.paper;
|
|
+
|
|
+import org.bukkit.*;
|
|
+
|
|
+/**
|
|
+ * Enumeration of different heightmap types maintained by the server. Generally using these maps is much faster
|
|
+ * than using an iterative search for a block in a given x, z coordinate.
|
|
+ *
|
|
+ * @deprecated Upstream has added their own API for using the game heightmaps. See {@link org.bukkit.HeightMap} and the
|
|
+ * non-deprecated getHighestBlock methods on World such as {@link org.bukkit.World#getHighestBlockAt(Location, HeightMap)}.
|
|
+ */
|
|
+@Deprecated
|
|
+public enum HeightmapType {
|
|
+
|
|
+ /**
|
|
+ * The highest block used for lighting in the world. Also the block returned by {@link World#getHighestBlockYAt(int, int)}}
|
|
+ */
|
|
+ LIGHT_BLOCKING,
|
|
+
|
|
+ /**
|
|
+ * References the highest block in the world.
|
|
+ */
|
|
+ ANY,
|
|
+
|
|
+ /**
|
|
+ * References the highest solid block in a world.
|
|
+ */
|
|
+ SOLID,
|
|
+
|
|
+ /**
|
|
+ * References the highest solid or liquid block in a world.
|
|
+ */
|
|
+ SOLID_OR_LIQUID,
|
|
+
|
|
+ /**
|
|
+ * References the highest solid or liquid block in a world, excluding leaves.
|
|
+ */
|
|
+ SOLID_OR_LIQUID_NO_LEAVES;
|
|
+}
|
|
diff --git a/src/main/java/org/bukkit/Location.java b/src/main/java/org/bukkit/Location.java
|
|
index 23ca89dde7f6ac9082d4b97fce2959425f3680cb..8321441b8f528a05e297f485672f928e76fe017d 100644
|
|
--- a/src/main/java/org/bukkit/Location.java
|
|
+++ b/src/main/java/org/bukkit/Location.java
|
|
@@ -638,6 +638,47 @@ public class Location implements Cloneable, ConfigurationSerializable {
|
|
return centerLoc;
|
|
}
|
|
|
|
+ // Paper start - Add heightmap api
|
|
+
|
|
+ /**
|
|
+ * Returns a copy of this location except with y = getWorld().getHighestBlockYAt(this.getBlockX(), this.getBlockZ())
|
|
+ * @return A copy of this location except with y = getWorld().getHighestBlockYAt(this.getBlockX(), this.getBlockZ())
|
|
+ * @throws NullPointerException if {{@link #getWorld()}} is {@code null}
|
|
+ */
|
|
+ @NotNull
|
|
+ public Location toHighestLocation() {
|
|
+ return this.toHighestLocation(HeightMap.WORLD_SURFACE);
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Returns a copy of this location except with y = getWorld().getHighestBlockYAt(this.getBlockX(), this.getBlockZ(), heightmap)
|
|
+ * @param heightmap The heightmap to use for finding the highest y location.
|
|
+ * @return A copy of this location except with y = getWorld().getHighestBlockYAt(this.getBlockX(), this.getBlockZ(), heightmap)
|
|
+ * @throws NullPointerException if {{@link #getWorld()}} is {@code null}
|
|
+ * @throws UnsupportedOperationException if {@link World#getHighestBlockYAt(int, int, com.destroystokyo.paper.HeightmapType)} does not support the specified heightmap
|
|
+ * @deprecated Use {@link org.bukkit.Location#toHighestLocation(HeightMap)}
|
|
+ */
|
|
+ @NotNull
|
|
+ @Deprecated
|
|
+ public Location toHighestLocation(@NotNull final com.destroystokyo.paper.HeightmapType heightmap) {
|
|
+ final Location ret = this.clone();
|
|
+ ret.setY(this.getWorld().getHighestBlockYAt(this, heightmap));
|
|
+ return ret;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Returns a copy of this location except with y = getWorld().getHighestBlockYAt(this.getBlockX(), this.getBlockZ(), heightMap)
|
|
+ * @param heightMap The heightmap to use for finding the highest y location.
|
|
+ * @return A copy of this location except with y = getWorld().getHighestBlockYAt(this.getBlockX(), this.getBlockZ(), heightMap)
|
|
+ */
|
|
+ @NotNull
|
|
+ public Location toHighestLocation(@NotNull final HeightMap heightMap) {
|
|
+ final Location ret = this.clone();
|
|
+ ret.setY(this.getWorld().getHighestBlockYAt(this, heightMap));
|
|
+ return ret;
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
/**
|
|
* Creates explosion at this location with given power
|
|
*
|
|
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
|
|
index ef17e3caf6a899fc19ed5b1df1446d42322fb098..57b4b3056d6408b67f070be5fe29e58c4699b486 100644
|
|
--- a/src/main/java/org/bukkit/World.java
|
|
+++ b/src/main/java/org/bukkit/World.java
|
|
@@ -160,6 +160,87 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
|
|
@NotNull
|
|
public Block getHighestBlockAt(@NotNull Location location);
|
|
|
|
+ // Paper start - Add heightmap API
|
|
+ /**
|
|
+ * Returns the highest block's y-coordinate at the specified block coordinates that match the specified heightmap's conditions.
|
|
+ * <p>
|
|
+ * <b>implNote:</b> Implementations are recommended to use an iterative search as a fallback before resorting to
|
|
+ * throwing an {@code UnsupportedOperationException}.
|
|
+ * </p>
|
|
+ *
|
|
+ * @param x The block's x-coordinate.
|
|
+ * @param z The block's z-coordinate.
|
|
+ * @param heightmap The specified heightmap to use. See {@link com.destroystokyo.paper.HeightmapType}
|
|
+ * @return The highest block's y-coordinate at (x, z) that matches the specified heightmap's conditions.
|
|
+ * @throws UnsupportedOperationException If the heightmap type is not supported.
|
|
+ * @deprecated Upstream has added support for this, use {@link World#getHighestBlockYAt(int, int, HeightMap)}
|
|
+ *
|
|
+ * @see com.destroystokyo.paper.HeightmapType
|
|
+ */
|
|
+ @Deprecated
|
|
+ public int getHighestBlockYAt(int x, int z, @NotNull com.destroystokyo.paper.HeightmapType heightmap) throws UnsupportedOperationException;
|
|
+
|
|
+ /**
|
|
+ * Returns the highest block's y-coordinate at the specified block coordinates that match the specified heightmap's conditions.
|
|
+ * Note that the y-coordinate of the specified location is ignored.
|
|
+ * <p>
|
|
+ * <b>implNote:</b> Implementations are recommended to use an iterative search as a fallback before resorting to
|
|
+ * throwing an {@code UnsupportedOperationException}.
|
|
+ * </p>
|
|
+ *
|
|
+ * @param location The specified block coordinates.
|
|
+ * @param heightmap The specified heightmap to use. See {@link com.destroystokyo.paper.HeightmapType}
|
|
+ * @return The highest block's y-coordinate at {@code location} that matches the specified heightmap's conditions.
|
|
+ * @throws UnsupportedOperationException If the heightmap type is not supported.
|
|
+ * @deprecated Upstream has added support for this, use {@link World#getHighestBlockYAt(Location, HeightMap)}
|
|
+ * @see com.destroystokyo.paper.HeightmapType
|
|
+ */
|
|
+ @Deprecated
|
|
+ default int getHighestBlockYAt(@NotNull Location location, @NotNull com.destroystokyo.paper.HeightmapType heightmap) throws UnsupportedOperationException {
|
|
+ return this.getHighestBlockYAt(location.getBlockX(), location.getBlockZ(), heightmap);
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Returns the highest {@link Block} at the specified block coordinates that match the specified heightmap's conditions.
|
|
+ * <p>
|
|
+ * <b>implNote:</b> Implementations are recommended to use an iterative search as a fallback before resorting to
|
|
+ * throwing an {@code UnsupportedOperationException}.
|
|
+ * </p>
|
|
+ * @param x The block's x-coordinate.
|
|
+ * @param z The block's z-coordinate.
|
|
+ * @param heightmap The specified heightmap to use. See {@link com.destroystokyo.paper.HeightmapType}
|
|
+ * @return The highest {@link Block} at (x, z) that matches the specified heightmap's conditions.
|
|
+ * @throws UnsupportedOperationException If the heightmap type is not supported.
|
|
+ * @deprecated Upstream has added support for this, use {@link World#getHighestBlockAt(int, int, HeightMap)}
|
|
+ * @see com.destroystokyo.paper.HeightmapType
|
|
+ */
|
|
+ @Deprecated
|
|
+ @NotNull
|
|
+ default Block getHighestBlockAt(int x, int z, @NotNull com.destroystokyo.paper.HeightmapType heightmap) throws UnsupportedOperationException {
|
|
+ return this.getBlockAt(x, this.getHighestBlockYAt(x, z, heightmap), z);
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Returns the highest {@link Block} at the specified block coordinates that match the specified heightmap's conditions.
|
|
+ * Note that the y-coordinate of the specified location is ignored.
|
|
+ * <p>
|
|
+ * <b>implNote:</b> Implementations are recommended to use an iterative search as a fallback before resorting to
|
|
+ * throwing an {@code UnsupportedOperationException}.
|
|
+ * </p>
|
|
+ * @param location The specified block coordinates.
|
|
+ * @param heightmap The specified heightmap to use. See {@link com.destroystokyo.paper.HeightmapType}
|
|
+ * @return The highest {@link Block} at {@code location} that matches the specified heightmap's conditions.
|
|
+ * @throws UnsupportedOperationException If the heightmap type is not supported.
|
|
+ * @deprecated Upstream has added support for this, use {@link World#getHighestBlockAt(Location, HeightMap)}
|
|
+ * @see com.destroystokyo.paper.HeightmapType
|
|
+ */
|
|
+ @Deprecated
|
|
+ @NotNull
|
|
+ default Block getHighestBlockAt(@NotNull Location location, @NotNull com.destroystokyo.paper.HeightmapType heightmap) throws UnsupportedOperationException {
|
|
+ return this.getHighestBlockAt(location.getBlockX(), location.getBlockZ(), heightmap);
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
/**
|
|
* Gets the highest coordinate corresponding to the {@link HeightMap} at the
|
|
* given coordinates.
|