mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-29 19:52:55 +01:00
c97ce029e9
PaperMC believes that 1.16.2 is now ready for general release as we fixed the main issue plagueing the 1.16.x release, the MapLike data conversion issues. Until now, it was not safe for a server to convert a world to 1.16.2 without data conversion issues around villages and potentially other things. If you did, those MapLike errors meant something went wrong. This is now resolved. Big thanks to all those that helped, notably @BillyGalbreath and @Proximyst who did large parts of the update process with me. Please as always, backup your worlds and test before updating to 1.16.2! If you update to 1.16.2, there is no going back to an older build than this. --------------------------------- Co-authored-by: William Blake Galbreath <Blake.Galbreath@GMail.com> Co-authored-by: Mariell Hoversholm <proximyst@proximyst.com> Co-authored-by: krolik-exe <69214078+krolik-exe@users.noreply.github.com> Co-authored-by: BillyGalbreath <BillyGalbreath@users.noreply.github.com> Co-authored-by: stonar96 <minecraft.stonar96@gmail.com> Co-authored-by: Shane Freeder <theboyetronic@gmail.com> Co-authored-by: Jason <jasonpenilla2@me.com> Co-authored-by: kashike <kashike@vq.lc> Co-authored-by: Aurora <21148213+aurorasmiles@users.noreply.github.com> Co-authored-by: KennyTV <kennytv@t-online.de> Co-authored-by: commandblockguy <commandblockguy1@gmail.com> Co-authored-by: DigitalRegent <misterwener@gmail.com> Co-authored-by: ishland <ishlandmc@yeah.net>
182 lines
8.8 KiB
Diff
182 lines
8.8 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
|
|
|
|
Deprecated 2020-02-08 MC 1.15.2
|
|
|
|
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 d5d67b3d84cd88ed0f858497e68535ec0162c700..ec9eb042ee8354d17f8ad4230c4acc5fcb46f894 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 {
|
|
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(com.destroystokyo.paper.HeightmapType.LIGHT_BLOCKING);
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * 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
|
|
+ */
|
|
+ @NotNull
|
|
+ public Location toHighestLocation(@NotNull final com.destroystokyo.paper.HeightmapType 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 51b2b6d3f5de413391957a42d6a9ccb69688e0eb..cbd39760fd6e18a9d21794c468d874ca8a10d988 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 PluginMessageRecipient, Metadatable {
|
|
@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.
|