Location#getHighestLocation should support Upstream API (#4770)

This commit is contained in:
Jake Potrebic 2020-11-16 06:44:14 -08:00 committed by GitHub
parent c093c43171
commit a162213b24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 4 deletions

View File

@ -3,7 +3,7 @@ From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Sat, 1 Dec 2018 19:00:36 -0800
Subject: [PATCH] Add Heightmap API
Deprecated 2020-02-08 MC 1.15.2
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
@ -51,10 +51,10 @@ index 0000000000000000000000000000000000000000..709e44ea1b14ab6917501c928e689cc6
+ SOLID_OR_LIQUID_NO_LEAVES;
+}
diff --git a/src/main/java/org/bukkit/Location.java b/src/main/java/org/bukkit/Location.java
index d5d67b3d84cd88ed0f858497e68535ec0162c700..ec9eb042ee8354d17f8ad4230c4acc5fcb46f894 100644
index d5d67b3d84cd88ed0f858497e68535ec0162c700..432d5711b7ec34eafeb27df82d367612dfe1fe54 100644
--- a/src/main/java/org/bukkit/Location.java
+++ b/src/main/java/org/bukkit/Location.java
@@ -638,6 +638,33 @@ public class Location implements Cloneable, ConfigurationSerializable {
@@ -638,6 +638,47 @@ public class Location implements Cloneable, ConfigurationSerializable {
return centerLoc;
}
@ -67,7 +67,7 @@ index d5d67b3d84cd88ed0f858497e68535ec0162c700..ec9eb042ee8354d17f8ad4230c4acc5f
+ */
+ @NotNull
+ public Location toHighestLocation() {
+ return this.toHighestLocation(com.destroystokyo.paper.HeightmapType.LIGHT_BLOCKING);
+ return this.toHighestLocation(HeightMap.WORLD_SURFACE);
+ }
+
+ /**
@ -76,13 +76,27 @@ index d5d67b3d84cd88ed0f858497e68535ec0162c700..ec9eb042ee8354d17f8ad4230c4acc5f
+ * @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
+
/**