Paper/Spigot-Server-Patches/0353-Implement-Force-Loaded-Chunk-API.patch
Aikar f956f185c8
Updated Upstream (Bukkit/CraftBukkit/Spigot)
Upstream has released updates that appears 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:
47b9cf30 SPIGOT-4372: LightningStrikeEvent cause API
a9ceda75 Include the plugin channel name in the exception message

CraftBukkit Changes:
a4bdecff SPIGOT-4372: LightningStrikeEvent cause API
34caaf6d SPIGOT-4371: Trident damaged when event cancelled
97315374 SPIGOT-4369: Handle cancelled trident event
bf1c8273 SPIGOT-4370: Remove vehicle if its passenger spawn event was cancelled

Spigot Changes:
6b015b4b SPIGOT-4370: Remove vehicle if its passenger spawn event was cancelled
2018-09-15 12:10:26 -04:00

60 lines
2.5 KiB
Diff

From 7eec24b0570c9d4303505151fb9311021987f5c5 Mon Sep 17 00:00:00 2001
From: willies952002 <admin@domnian.com>
Date: Wed, 29 Aug 2018 00:37:42 -0400
Subject: [PATCH] Implement Force-Loaded Chunk API
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 9a99a56c14..9636b40f97 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -3009,6 +3009,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
return forcedchunk != null && forcedchunk.a().contains(ChunkCoordIntPair.a(i, j));
}
+ public boolean setForcedChunk(int i, int j, boolean flag) { return b(i, j, flag); } // Paper - OBFHELPER
public boolean b(int i, int j, boolean flag) {
String s = "chunks";
ForcedChunk forcedchunk = (ForcedChunk) this.a(this.worldProvider.getDimensionManager(), ForcedChunk::new, "chunks");
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
index 12c6d850d2..55394e0c15 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
@@ -289,6 +289,18 @@ public class CraftChunk implements Chunk {
Preconditions.checkArgument(0 <= z && z <= 15, "z out of range (expected 0-15, got %s)", z);
}
+ // Paper start - Force-Loaded Chunk API
+ @Override
+ public boolean isForceLoaded() {
+ return getHandle().getWorld().isForcedChunk(this.x, this.z);
+ }
+
+ @Override
+ public void setForceLoaded(boolean force) {
+ getHandle().getWorld().setForcedChunk(this.x, this.z, force);
+ }
+ // Paper end
+
static {
Arrays.fill(emptySkyLight, (byte) 0xFF);
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 1ccf2a7609..755d2632fd 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -609,6 +609,10 @@ public class CraftWorld implements World {
public boolean isChunkGenerated(int x, int z) {
return this.getHandle().getChunkProviderServer().isChunkGenerated(x, z);
}
+
+ public boolean isChunkForceLoaded(int x, int z) {
+ return this.isChunkGenerated(x, z) && this.getHandle().isForcedChunk(x, z);
+ }
// Paper end
public ChunkGenerator getGenerator() {
--
2.19.0