Paper/patches/api/0141-isChunkGenerated-API.patch
Jake Potrebic 526795bacd
Update patches to handle vineflower decompiler (#10406)
* Update patches to handle vineflower decompiler

* update patches again to handle inlined simple lambdas

* update vf again and re-apply/rebuild patches

* update patches after removal of verify-merges flag

* fix compile issue

* remove maven local

* fix some issues

* address more issues

* fix collision patch

* use paperweight release

* more fixes

* update fineflower and fix patches again

* add missing comment descriptor

---------

Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
2024-04-12 12:14:06 -07:00

63 lines
2.5 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: cswhite2000 <18whitechristop@gmail.com>
Date: Tue, 21 Aug 2018 19:39:46 -0700
Subject: [PATCH] isChunkGenerated API
diff --git a/src/main/java/org/bukkit/Location.java b/src/main/java/org/bukkit/Location.java
index 042d69e6d4584eb6d678b8ea13a3e4bea78703b8..02b4ffa6b918269bd64f7c518fcceef1f6990737 100644
--- a/src/main/java/org/bukkit/Location.java
+++ b/src/main/java/org/bukkit/Location.java
@@ -3,6 +3,7 @@ package org.bukkit;
import com.google.common.base.Preconditions;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
+import com.google.common.base.Preconditions; // Paper
import java.util.HashMap;
import java.util.Map;
import org.bukkit.block.Block;
@@ -544,6 +545,19 @@ public class Location implements Cloneable, ConfigurationSerializable, io.paperm
public boolean isChunkLoaded() { return this.getWorld().isChunkLoaded(locToBlock(x) >> 4, locToBlock(z) >> 4); } // Paper
+ // Paper start - isGenerated API
+ /**
+ * Checks if a {@link Chunk} has been generated at this location.
+ *
+ * @return true if a chunk has been generated at this location
+ */
+ public boolean isGenerated() {
+ World world = this.getWorld();
+ Preconditions.checkNotNull(world, "Location has no world!");
+ return world.isChunkGenerated(locToBlock(x) >> 4, locToBlock(z) >> 4);
+ }
+ // Paper end - isGenerated API
+
// Paper start - expand location manipulation API
/**
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index 48f2c64491f93e5ac720bdb19a20f3f435a7e888..8bef6168caf0932a5a64cf69eb7988fa3191b13a 100644
--- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java
@@ -248,6 +248,19 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
}
// Paper end - chunk long key API
+ // Paper start - isChunkGenerated API
+ /**
+ * Checks if a {@link Chunk} has been generated at the specified chunk key,
+ * which is the X and Z packed into a long.
+ *
+ * @param chunkKey The Chunk Key to look up the chunk by
+ * @return true if the chunk has been generated, otherwise false
+ */
+ default boolean isChunkGenerated(long chunkKey) {
+ return isChunkGenerated((int) chunkKey, (int) (chunkKey >> 32));
+ }
+ // Paper end - isChunkGenerated API
+
/**
* Checks if the specified {@link Chunk} is loaded
*