Paper/patches/api/0122-Entity-getChunk-API.patch
2022-06-07 19:20:30 +02:00

37 lines
1.3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 4 Jul 2018 02:25:48 -0400
Subject: [PATCH] Entity#getChunk API
Get the chunk the entity is currently registered to
diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java
index b9a61d06d72831dc0c591e129553453a537d3785..df07eb07896790a09d1022daef5cffc6a435f739 100644
--- a/src/main/java/org/bukkit/entity/Entity.java
+++ b/src/main/java/org/bukkit/entity/Entity.java
@@ -3,6 +3,7 @@ package org.bukkit.entity;
import java.util.List;
import java.util.Set;
import java.util.UUID;
+import org.bukkit.Chunk; // Paper
import org.bukkit.EntityEffect;
import org.bukkit.Location;
import org.bukkit.Nameable;
@@ -688,5 +689,16 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
* @return True if entity spawned from a mob spawner
*/
boolean fromMobSpawner();
+
+ /**
+ * Gets the latest chunk an entity is currently or was in.
+ *
+ * @return The current, or most recent chunk if the entity is invalid (which may load the chunk)
+ */
+ @NotNull
+ default Chunk getChunk() {
+ // TODO remove impl here
+ return getLocation().getChunk();
+ }
// Paper end
}