|
|
|
|
@@ -3,34 +3,26 @@ From: Altiami <yoshimo.kristin@gmail.com>
|
|
|
|
|
Date: Wed, 5 Mar 2025 13:16:44 -0800
|
|
|
|
|
Subject: [PATCH] SparklyPaper: Parallel world ticking
|
|
|
|
|
|
|
|
|
|
Original project: https://github.com/SparklyPower/SparklyPaper
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/ca/spottedleaf/moonrise/common/util/TickThread.java b/src/main/java/ca/spottedleaf/moonrise/common/util/TickThread.java
|
|
|
|
|
index a4aa2615823d77920ff55b8aa0bcc27a54b8c3e1..8d2694977f29b680d9daf83f2c8cc3502d3cb7dd 100644
|
|
|
|
|
index a4aa2615823d77920ff55b8aa0bcc27a54b8c3e1..2fb65ce228da94eb7d9364ee0f94582300178f1d 100644
|
|
|
|
|
--- a/src/main/java/ca/spottedleaf/moonrise/common/util/TickThread.java
|
|
|
|
|
+++ b/src/main/java/ca/spottedleaf/moonrise/common/util/TickThread.java
|
|
|
|
|
@@ -6,6 +6,7 @@ import net.minecraft.world.level.ChunkPos;
|
|
|
|
|
import net.minecraft.world.level.Level;
|
|
|
|
|
import net.minecraft.world.phys.AABB;
|
|
|
|
|
import net.minecraft.world.phys.Vec3;
|
|
|
|
|
+import org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
|
|
@@ -14,6 +15,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
@@ -14,6 +14,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
public class TickThread extends Thread {
|
|
|
|
|
|
|
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(TickThread.class);
|
|
|
|
|
+ public static final boolean HARD_THROW = !SparklyPaperParallelWorldTicking.disableHardThrow; // SparklyPaper - parallel world ticking - THIS SHOULD NOT BE DISABLED SINCE IT CAN CAUSE DATA CORRUPTION!!! Anyhow, for production servers, if you want to make a test run to see if the server could crash, you can test it with this disabled
|
|
|
|
|
+ private static final boolean HARD_THROW = !org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking.disableHardThrow; // SparklyPaper - parallel world ticking - THIS SHOULD NOT BE DISABLED SINCE IT CAN CAUSE DATA CORRUPTION!!! Anyhow, for production servers, if you want to make a test run to see if the server could crash, you can test it with this disabled
|
|
|
|
|
|
|
|
|
|
private static String getThreadContext() {
|
|
|
|
|
return "thread=" + Thread.currentThread().getName();
|
|
|
|
|
@@ -26,14 +28,15 @@ public class TickThread extends Thread {
|
|
|
|
|
@@ -26,14 +27,14 @@ public class TickThread extends Thread {
|
|
|
|
|
public static void ensureTickThread(final String reason) {
|
|
|
|
|
if (!isTickThread()) {
|
|
|
|
|
LOGGER.error("Thread failed main thread check: " + reason + ", context=" + getThreadContext(), new Throwable());
|
|
|
|
|
- throw new IllegalStateException(reason);
|
|
|
|
|
+ if (HARD_THROW)
|
|
|
|
|
+ throw new IllegalStateException(reason); // SparklyPaper - parallel world ticking
|
|
|
|
|
+ if (HARD_THROW) throw new IllegalStateException(reason); // SparklyPaper - parallel world ticking
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -38,90 +30,86 @@ index a4aa2615823d77920ff55b8aa0bcc27a54b8c3e1..8d2694977f29b680d9daf83f2c8cc350
|
|
|
|
|
if (!isTickThreadFor(world, pos)) {
|
|
|
|
|
final String ex = "Thread failed main thread check: " +
|
|
|
|
|
- reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", block_pos=" + pos;
|
|
|
|
|
+ reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", block_pos=" + pos + " - " + getTickThreadInformation(world.getServer());
|
|
|
|
|
+ reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", block_pos=" + pos + " - " + getTickThreadInformation(world.getServer()); // SparklyPaper - parallel world ticking
|
|
|
|
|
LOGGER.error(ex, new Throwable());
|
|
|
|
|
throw new IllegalStateException(ex);
|
|
|
|
|
}
|
|
|
|
|
@@ -42,7 +45,7 @@ public class TickThread extends Thread {
|
|
|
|
|
@@ -42,7 +43,7 @@ public class TickThread extends Thread {
|
|
|
|
|
public static void ensureTickThread(final Level world, final BlockPos pos, final int blockRadius, final String reason) {
|
|
|
|
|
if (!isTickThreadFor(world, pos, blockRadius)) {
|
|
|
|
|
final String ex = "Thread failed main thread check: " +
|
|
|
|
|
- reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", block_pos=" + pos + ", block_radius=" + blockRadius;
|
|
|
|
|
+ reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", block_pos=" + pos + ", block_radius=" + blockRadius + " - " + getTickThreadInformation(world.getServer());
|
|
|
|
|
+ reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", block_pos=" + pos + ", block_radius=" + blockRadius + " - " + getTickThreadInformation(world.getServer()); // SparklyPaper - parallel world ticking
|
|
|
|
|
LOGGER.error(ex, new Throwable());
|
|
|
|
|
throw new IllegalStateException(ex);
|
|
|
|
|
}
|
|
|
|
|
@@ -51,7 +54,7 @@ public class TickThread extends Thread {
|
|
|
|
|
@@ -51,7 +52,7 @@ public class TickThread extends Thread {
|
|
|
|
|
public static void ensureTickThread(final Level world, final ChunkPos pos, final String reason) {
|
|
|
|
|
if (!isTickThreadFor(world, pos)) {
|
|
|
|
|
final String ex = "Thread failed main thread check: " +
|
|
|
|
|
- reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", chunk_pos=" + pos;
|
|
|
|
|
+ reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", chunk_pos=" + pos + " - " + getTickThreadInformation(world.getServer());
|
|
|
|
|
+ reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", chunk_pos=" + pos + " - " + getTickThreadInformation(world.getServer()); // SparklyPaper - parallel world ticking
|
|
|
|
|
LOGGER.error(ex, new Throwable());
|
|
|
|
|
throw new IllegalStateException(ex);
|
|
|
|
|
}
|
|
|
|
|
@@ -60,7 +63,7 @@ public class TickThread extends Thread {
|
|
|
|
|
@@ -60,7 +61,7 @@ public class TickThread extends Thread {
|
|
|
|
|
public static void ensureTickThread(final Level world, final int chunkX, final int chunkZ, final String reason) {
|
|
|
|
|
if (!isTickThreadFor(world, chunkX, chunkZ)) {
|
|
|
|
|
final String ex = "Thread failed main thread check: " +
|
|
|
|
|
- reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", chunk_pos=" + new ChunkPos(chunkX, chunkZ);
|
|
|
|
|
+ reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", chunk_pos=" + new ChunkPos(chunkX, chunkZ) + " - " + getTickThreadInformation(world.getServer());
|
|
|
|
|
+ reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", chunk_pos=" + new ChunkPos(chunkX, chunkZ) + " - " + getTickThreadInformation(world.getServer()); // SparklyPaper - parallel world ticking
|
|
|
|
|
LOGGER.error(ex, new Throwable());
|
|
|
|
|
throw new IllegalStateException(ex);
|
|
|
|
|
}
|
|
|
|
|
@@ -69,7 +72,7 @@ public class TickThread extends Thread {
|
|
|
|
|
@@ -69,7 +70,7 @@ public class TickThread extends Thread {
|
|
|
|
|
public static void ensureTickThread(final Entity entity, final String reason) {
|
|
|
|
|
if (!isTickThreadFor(entity)) {
|
|
|
|
|
final String ex = "Thread failed main thread check: " +
|
|
|
|
|
- reason + ", context=" + getThreadContext() + ", entity=" + EntityUtil.dumpEntity(entity);
|
|
|
|
|
+ reason + ", context=" + getThreadContext() + ", entity=" + EntityUtil.dumpEntity(entity) + " - " + getTickThreadInformation(entity.getServer());
|
|
|
|
|
+ reason + ", context=" + getThreadContext() + ", entity=" + EntityUtil.dumpEntity(entity) + " - " + getTickThreadInformation(entity.getServer()); // SparklyPaper - parallel world ticking
|
|
|
|
|
LOGGER.error(ex, new Throwable());
|
|
|
|
|
throw new IllegalStateException(ex);
|
|
|
|
|
}
|
|
|
|
|
@@ -78,7 +81,7 @@ public class TickThread extends Thread {
|
|
|
|
|
@@ -78,7 +79,7 @@ public class TickThread extends Thread {
|
|
|
|
|
public static void ensureTickThread(final Level world, final AABB aabb, final String reason) {
|
|
|
|
|
if (!isTickThreadFor(world, aabb)) {
|
|
|
|
|
final String ex = "Thread failed main thread check: " +
|
|
|
|
|
- reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", aabb=" + aabb;
|
|
|
|
|
+ reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", aabb=" + aabb + " - " + getTickThreadInformation(world.getServer());
|
|
|
|
|
+ reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", aabb=" + aabb + " - " + getTickThreadInformation(world.getServer()); // SparklyPaper - parallel world ticking
|
|
|
|
|
LOGGER.error(ex, new Throwable());
|
|
|
|
|
throw new IllegalStateException(ex);
|
|
|
|
|
}
|
|
|
|
|
@@ -87,12 +90,74 @@ public class TickThread extends Thread {
|
|
|
|
|
@@ -87,12 +88,70 @@ public class TickThread extends Thread {
|
|
|
|
|
public static void ensureTickThread(final Level world, final double blockX, final double blockZ, final String reason) {
|
|
|
|
|
if (!isTickThreadFor(world, blockX, blockZ)) {
|
|
|
|
|
final String ex = "Thread failed main thread check: " +
|
|
|
|
|
- reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", block_pos=" + new Vec3(blockX, 0.0, blockZ);
|
|
|
|
|
+ reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", block_pos=" + new Vec3(blockX, 0.0, blockZ) + " - " + getTickThreadInformation(world.getServer());
|
|
|
|
|
+ reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", block_pos=" + new Vec3(blockX, 0.0, blockZ) + " - " + getTickThreadInformation(world.getServer()); // SparklyPaper - parallel world ticking
|
|
|
|
|
LOGGER.error(ex, new Throwable());
|
|
|
|
|
throw new IllegalStateException(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // SparklyPaper - parallel world ticking
|
|
|
|
|
+ // SparklyPaper start - parallel world ticking
|
|
|
|
|
+ // This is an additional method to check if the tick thread is bound to a specific world because, by default, Paper's isTickThread methods do not provide this information
|
|
|
|
|
+ // Because we only tick worlds in parallel (instead of regions), we can use this for our checks
|
|
|
|
|
+ public static void ensureTickThread(final net.minecraft.server.level.ServerLevel world, final String reason) {
|
|
|
|
|
+ if (!isTickThreadFor(world)) {
|
|
|
|
|
+ LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason + " @ world " + world.getWorld().getName() + " - " + getTickThreadInformation(world.getServer()), new Throwable());
|
|
|
|
|
+ if (HARD_THROW)
|
|
|
|
|
+ throw new IllegalStateException(reason);
|
|
|
|
|
+ LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason + " @ world " + world.getWorld().getName() + " - " + getTickThreadInformation(world.getServer()), new Throwable()); // SparklyPaper - parallel world ticking
|
|
|
|
|
+ if (HARD_THROW) throw new IllegalStateException(reason);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // SparklyPaper - parallel world ticking
|
|
|
|
|
+ // This is an additional method to check if it is a tick thread but ONLY a tick thread
|
|
|
|
|
+ public static void ensureOnlyTickThread(final String reason) {
|
|
|
|
|
+ boolean isTickThread = isTickThread();
|
|
|
|
|
+ boolean isServerLevelTickThread = isServerLevelTickThread();
|
|
|
|
|
+ if (!isTickThread || isServerLevelTickThread) {
|
|
|
|
|
+ LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread ONLY tick thread check: " + reason, new Throwable());
|
|
|
|
|
+ if (HARD_THROW)
|
|
|
|
|
+ throw new IllegalStateException(reason);
|
|
|
|
|
+ if (HARD_THROW) throw new IllegalStateException(reason);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // SparklyPaper - parallel world ticking
|
|
|
|
|
+ // This is an additional method to check if the tick thread is bound to a specific world or if it is an async thread.
|
|
|
|
|
+ public static void ensureTickThreadOrAsyncThread(final net.minecraft.server.level.ServerLevel world, final String reason) {
|
|
|
|
|
+ boolean isValidTickThread = isTickThreadFor(world);
|
|
|
|
|
@@ -129,8 +117,7 @@ index a4aa2615823d77920ff55b8aa0bcc27a54b8c3e1..8d2694977f29b680d9daf83f2c8cc350
|
|
|
|
|
+ boolean isValid = isAsyncThread || isValidTickThread;
|
|
|
|
|
+ if (!isValid) {
|
|
|
|
|
+ LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread or async thread check: " + reason + " @ world " + world.getWorld().getName() + " - " + getTickThreadInformation(world.getServer()), new Throwable());
|
|
|
|
|
+ if (HARD_THROW)
|
|
|
|
|
+ throw new IllegalStateException(reason);
|
|
|
|
|
+ if (HARD_THROW) throw new IllegalStateException(reason);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
@@ -159,70 +146,73 @@ index a4aa2615823d77920ff55b8aa0bcc27a54b8c3e1..8d2694977f29b680d9daf83f2c8cc350
|
|
|
|
|
+ public static boolean isServerLevelTickThread() {
|
|
|
|
|
+ return Thread.currentThread() instanceof ServerLevelTickThread;
|
|
|
|
|
+ }
|
|
|
|
|
+ // SparklyPaper end - parallel world ticking
|
|
|
|
|
+
|
|
|
|
|
public final int id; /* We don't override getId as the spec requires that it be unique (with respect to all other threads) */
|
|
|
|
|
|
|
|
|
|
private static final AtomicInteger ID_GENERATOR = new AtomicInteger();
|
|
|
|
|
@@ -133,46 +198,73 @@ public class TickThread extends Thread {
|
|
|
|
|
@@ -133,46 +192,74 @@ public class TickThread extends Thread {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean isTickThreadFor(final Level world, final BlockPos pos) {
|
|
|
|
|
- return isTickThread();
|
|
|
|
|
+ return isTickThreadFor(world); // Leaf - SparklyPaper parallel world ticking mod (use methods for what they were made for)
|
|
|
|
|
+ return isTickThreadFor(world); // Leaf - SparklyPaper - parallel world ticking mod (use methods for what they were made for)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean isTickThreadFor(final Level world, final BlockPos pos, final int blockRadius) {
|
|
|
|
|
- return isTickThread();
|
|
|
|
|
+ return isTickThreadFor(world); // Leaf - SparklyPaper parallel world ticking mod (add missing replacement / use methods for what they were made for)
|
|
|
|
|
+ return isTickThreadFor(world); // Leaf - SparklyPaper - parallel world ticking mod (add missing replacement / use methods for what they were made for)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean isTickThreadFor(final Level world, final ChunkPos pos) {
|
|
|
|
|
- return isTickThread();
|
|
|
|
|
+ return isTickThreadFor(world); // Leaf - SparklyPaper parallel world ticking mod (use methods for what they were made for)
|
|
|
|
|
+ return isTickThreadFor(world); // Leaf - SparklyPaper - parallel world ticking mod (use methods for what they were made for)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean isTickThreadFor(final Level world, final Vec3 pos) {
|
|
|
|
|
- return isTickThread();
|
|
|
|
|
+ return isTickThreadFor(world); // Leaf - SparklyPaper parallel world ticking mod (use methods for what they were made for)
|
|
|
|
|
+ return isTickThreadFor(world); // Leaf - SparklyPaper - parallel world ticking mod (use methods for what they were made for)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean isTickThreadFor(final Level world, final int chunkX, final int chunkZ) {
|
|
|
|
|
- return isTickThread();
|
|
|
|
|
+ return isTickThreadFor(world); // Leaf - SparklyPaper parallel world ticking mod (use methods for what they were made for)
|
|
|
|
|
+ return isTickThreadFor(world); // Leaf - SparklyPaper - parallel world ticking mod (use methods for what they were made for)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean isTickThreadFor(final Level world, final AABB aabb) {
|
|
|
|
|
- return isTickThread();
|
|
|
|
|
+ return isTickThreadFor(world); // Leaf - SparklyPaper parallel world ticking mod (use methods for what they were made for)
|
|
|
|
|
+ return isTickThreadFor(world); // Leaf - SparklyPaper - parallel world ticking mod (use methods for what they were made for)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean isTickThreadFor(final Level world, final double blockX, final double blockZ) {
|
|
|
|
|
- return isTickThread();
|
|
|
|
|
+ return isTickThreadFor(world); // Leaf - SparklyPaper parallel world ticking mod (use methods for what they were made for)
|
|
|
|
|
+ return isTickThreadFor(world); // Leaf - SparklyPaper - parallel world ticking mod (use methods for what they were made for)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean isTickThreadFor(final Level world, final Vec3 position, final Vec3 deltaMovement, final int buffer) {
|
|
|
|
|
- return isTickThread();
|
|
|
|
|
+ return isTickThreadFor(world); // Leaf - SparklyPaper parallel world ticking mod (use methods for what they were made for)
|
|
|
|
|
+ return isTickThreadFor(world); // Leaf - SparklyPaper - parallel world ticking mod (use methods for what they were made for)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean isTickThreadFor(final Level world, final int fromChunkX, final int fromChunkZ, final int toChunkX, final int toChunkZ) {
|
|
|
|
|
- return isTickThread();
|
|
|
|
|
+ return isTickThreadFor(world); // Leaf - SparklyPaper parallel world ticking mod (use methods for what they were made for)
|
|
|
|
|
+ return isTickThreadFor(world); // Leaf - SparklyPaper - parallel world ticking mod (use methods for what they were made for)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean isTickThreadFor(final Level world, final int chunkX, final int chunkZ, final int radius) {
|
|
|
|
|
- return isTickThread();
|
|
|
|
|
+ return isTickThreadFor(world); // Leaf - SparklyPaper parallel world ticking mod (use methods for what they were made for)
|
|
|
|
|
+ return isTickThreadFor(world); // Leaf - SparklyPaper - parallel world ticking mod (use methods for what they were made for)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // SparklyPaper - parallel world ticking
|
|
|
|
|
+ // SparklyPaper start - parallel world ticking
|
|
|
|
|
+ // This is an additional method to check if the tick thread is bound to a specific world because, by default, Paper's isTickThread methods do not provide this information
|
|
|
|
|
+ // Because we only tick worlds in parallel (instead of regions), we can use this for our checks
|
|
|
|
|
+ public static boolean isTickThreadFor(final Level world) {
|
|
|
|
|
+ if (Thread.currentThread() instanceof ServerLevelTickThread serverLevelTickThread) {
|
|
|
|
|
+ return serverLevelTickThread.currentlyTickingServerLevel == world;
|
|
|
|
|
+ } else return isTickThread();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return isTickThread();
|
|
|
|
|
+ }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean isTickThreadFor(final Entity entity) {
|
|
|
|
|
@@ -231,10 +221,9 @@ index a4aa2615823d77920ff55b8aa0bcc27a54b8c3e1..8d2694977f29b680d9daf83f2c8cc350
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return isTickThreadFor(entity.level()); // Leaf - SparklyPaper parallel world ticking mod (use methods for what they were made for)
|
|
|
|
|
+ return isTickThreadFor(entity.level()); // Leaf - SparklyPaper - parallel world ticking mod (use methods for what they were made for)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // SparklyPaper start - parallel world ticking
|
|
|
|
|
+ public static class ServerLevelTickThread extends TickThread {
|
|
|
|
|
+ public ServerLevelTickThread(String name) {
|
|
|
|
|
+ super(name);
|
|
|
|
|
@@ -246,144 +235,128 @@ index a4aa2615823d77920ff55b8aa0bcc27a54b8c3e1..8d2694977f29b680d9daf83f2c8cc350
|
|
|
|
|
+
|
|
|
|
|
+ public net.minecraft.server.level.ServerLevel currentlyTickingServerLevel;
|
|
|
|
|
}
|
|
|
|
|
+ // SparklyPaper end
|
|
|
|
|
+ // SparklyPaper end - parallel world ticking
|
|
|
|
|
}
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
|
|
|
index 15673166e566b2a6d5093210d99b154e69fab0ad..3c80b73f969318ec12b4f39b50cf1e215b5ca23f 100644
|
|
|
|
|
index 15673166e566b2a6d5093210d99b154e69fab0ad..49abf1100271452e9c79c8643a25af3ce519773b 100644
|
|
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
|
|
|
@@ -145,6 +145,7 @@ import org.bukkit.util.NumberConversions;
|
|
|
|
|
import org.bukkit.util.RayTraceResult;
|
|
|
|
|
import org.bukkit.util.StructureSearchResult;
|
|
|
|
|
import org.bukkit.util.Vector;
|
|
|
|
|
+import org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking;
|
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
|
import org.jetbrains.annotations.Nullable;
|
|
|
|
|
|
|
|
|
|
@@ -455,7 +456,12 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
|
|
|
@@ -455,7 +455,12 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean unloadChunk0(int x, int z, boolean save) {
|
|
|
|
|
- org.spigotmc.AsyncCatcher.catchOp("chunk unload"); // Spigot
|
|
|
|
|
+ // Leaf start - SparklyPaper parallel world ticking mod (make configurable)
|
|
|
|
|
+ if (SparklyPaperParallelWorldTicking.enabled)
|
|
|
|
|
+ // Leaf start - SparklyPaper - parallel world ticking mod (make configurable)
|
|
|
|
|
+ if (org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking.enabled)
|
|
|
|
|
+ ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(this.world, x, z, "Cannot unload chunk asynchronously"); // SparklyPaper - parallel world ticking (additional concurrency issues logs)
|
|
|
|
|
+ else
|
|
|
|
|
+ org.spigotmc.AsyncCatcher.catchOp("chunk unload"); // Spigot
|
|
|
|
|
+ // Leaf end
|
|
|
|
|
+ // Leaf end - SparklyPaper - parallel world ticking mod (make configurable)
|
|
|
|
|
if (!this.isChunkLoaded(x, z)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
@@ -472,6 +478,8 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
|
|
|
@@ -472,6 +477,8 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean refreshChunk(int x, int z) {
|
|
|
|
|
+ if (SparklyPaperParallelWorldTicking.enabled) // Leaf - SparklyPaper parallel world ticking mod (make configurable)
|
|
|
|
|
+ if (org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking.enabled) // Leaf - SparklyPaper - parallel world ticking mod (make configurable)
|
|
|
|
|
+ ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(this.world, x, z, "Cannot refresh chunk asynchronously"); // SparklyPaper - parallel world ticking (additional concurrency issues logs)
|
|
|
|
|
ChunkHolder playerChunk = this.world.getChunkSource().chunkMap.getVisibleChunkIfPresent(ChunkPos.asLong(x, z));
|
|
|
|
|
if (playerChunk == null) return false;
|
|
|
|
|
|
|
|
|
|
@@ -522,7 +530,12 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
|
|
|
@@ -522,7 +529,12 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean loadChunk(int x, int z, boolean generate) {
|
|
|
|
|
- org.spigotmc.AsyncCatcher.catchOp("chunk load"); // Spigot
|
|
|
|
|
+ // Leaf start - SparklyPaper parallel world ticking mod (make configurable)
|
|
|
|
|
+ if (SparklyPaperParallelWorldTicking.enabled)
|
|
|
|
|
+ // Leaf start - SparklyPaper - parallel world ticking mod (make configurable)
|
|
|
|
|
+ if (org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking.enabled)
|
|
|
|
|
+ ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(this.getHandle(), x, z, "May not sync load chunks asynchronously"); // SparklyPaper - parallel world ticking (additional concurrency issues logs)
|
|
|
|
|
+ else
|
|
|
|
|
+ org.spigotmc.AsyncCatcher.catchOp("chunk load"); // Spigot
|
|
|
|
|
+ // Leaf end
|
|
|
|
|
+ // Leaf end - SparklyPaper - parallel world ticking mod (make configurable)
|
|
|
|
|
warnUnsafeChunk("loading a faraway chunk", x, z); // Paper
|
|
|
|
|
ChunkAccess chunk = this.world.getChunkSource().getChunk(x, z, generate || isChunkGenerated(x, z) ? ChunkStatus.FULL : ChunkStatus.EMPTY, true); // Paper
|
|
|
|
|
|
|
|
|
|
@@ -750,6 +763,8 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
|
|
|
@@ -750,6 +762,8 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) {
|
|
|
|
|
+ if (SparklyPaperParallelWorldTicking.enabled) // Leaf - SparklyPaper parallel world ticking mod (make configurable)
|
|
|
|
|
+ if (org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking.enabled) // Leaf - SparklyPaper - parallel world ticking mod (make configurable)
|
|
|
|
|
+ ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(this.world, loc.getX(), loc.getZ(), "Cannot generate tree asynchronously"); // SparklyPaper - parallel world ticking (additional concurrency issues logs)
|
|
|
|
|
this.world.captureTreeGeneration = true;
|
|
|
|
|
this.world.captureBlockStates = true;
|
|
|
|
|
boolean grownTree = this.generateTree(loc, type);
|
|
|
|
|
@@ -865,6 +880,8 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
|
|
|
@@ -865,6 +879,8 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
|
|
|
}
|
|
|
|
|
public boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks, Entity source, Consumer<net.minecraft.world.level.ServerExplosion> configurator) {
|
|
|
|
|
// Paper end - expand explosion API
|
|
|
|
|
+ if (SparklyPaperParallelWorldTicking.enabled) // Leaf - SparklyPaper parallel world ticking mod (make configurable)
|
|
|
|
|
+ if (org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking.enabled) // Leaf - SparklyPaper - parallel world ticking mod (make configurable)
|
|
|
|
|
+ ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(this.world, x, z, "Cannot create explosion asynchronously"); // SparklyPaper - parallel world ticking (additional concurrency issues logs)
|
|
|
|
|
net.minecraft.world.level.Level.ExplosionInteraction explosionType;
|
|
|
|
|
if (!breakBlocks) {
|
|
|
|
|
explosionType = net.minecraft.world.level.Level.ExplosionInteraction.NONE; // Don't break blocks
|
|
|
|
|
@@ -956,6 +973,8 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
|
|
|
@@ -956,6 +972,8 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int getHighestBlockYAt(int x, int z, org.bukkit.HeightMap heightMap) {
|
|
|
|
|
+ if (SparklyPaperParallelWorldTicking.enabled) // Leaf - SparklyPaper parallel world ticking mod (make configurable)
|
|
|
|
|
+ if (org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking.enabled) // Leaf - SparklyPaper - parallel world ticking mod (make configurable)
|
|
|
|
|
+ ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(this.world, x >> 4, z >> 4, "Cannot retrieve chunk asynchronously"); // SparklyPaper - parallel world ticking (additional concurrency issues logs)
|
|
|
|
|
warnUnsafeChunk("getting a faraway chunk", x >> 4, z >> 4); // Paper
|
|
|
|
|
// Transient load for this tick
|
|
|
|
|
return this.world.getChunk(x >> 4, z >> 4).getHeight(CraftHeightMap.toNMS(heightMap), x, z);
|
|
|
|
|
@@ -986,6 +1005,8 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
|
|
|
@@ -986,6 +1004,8 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
|
|
|
@Override
|
|
|
|
|
public void setBiome(int x, int y, int z, Holder<net.minecraft.world.level.biome.Biome> bb) {
|
|
|
|
|
BlockPos pos = new BlockPos(x, 0, z);
|
|
|
|
|
+ if (SparklyPaperParallelWorldTicking.enabled) // Leaf - SparklyPaper parallel world ticking mod (make configurable)
|
|
|
|
|
+ if (org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking.enabled) // Leaf - SparklyPaper - parallel world ticking mod (make configurable)
|
|
|
|
|
+ ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(this.world, pos, "Cannot retrieve chunk asynchronously"); // SparklyPaper - parallel world ticking (additional concurrency issues logs)
|
|
|
|
|
if (this.world.hasChunkAt(pos)) {
|
|
|
|
|
net.minecraft.world.level.chunk.LevelChunk chunk = this.world.getChunkAt(pos);
|
|
|
|
|
|
|
|
|
|
@@ -2328,6 +2349,8 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
|
|
|
@@ -2328,6 +2348,8 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void sendGameEvent(Entity sourceEntity, org.bukkit.GameEvent gameEvent, Vector position) {
|
|
|
|
|
+ if (SparklyPaperParallelWorldTicking.enabled) // Leaf - SparklyPaper parallel world ticking mod (make configurable)
|
|
|
|
|
+ if (org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking.enabled) // Leaf - SparklyPaper - parallel world ticking mod (make configurable)
|
|
|
|
|
+ ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(this.world, position.getX(), position.getZ(), "Cannot send game event asynchronously"); // SparklyPaper - parallel world ticking (additional concurrency issues logs)
|
|
|
|
|
getHandle().gameEvent(sourceEntity != null ? ((CraftEntity) sourceEntity).getHandle(): null, net.minecraft.core.registries.BuiltInRegistries.GAME_EVENT.get(org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(gameEvent.getKey())).orElseThrow(), org.bukkit.craftbukkit.util.CraftVector.toBlockPos(position));
|
|
|
|
|
}
|
|
|
|
|
// Paper end
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
|
|
|
|
index 973b297a22c0cc53f966582c67c3688f4b2205c7..747f20d080b602ab9a1c551c648bf54682e584e0 100644
|
|
|
|
|
index 973b297a22c0cc53f966582c67c3688f4b2205c7..61f9e88a7760b4bf23674ac8594dd31557768217 100644
|
|
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
|
|
|
|
@@ -60,6 +60,7 @@ import org.bukkit.util.BlockVector;
|
|
|
|
|
import org.bukkit.util.BoundingBox;
|
|
|
|
|
import org.bukkit.util.RayTraceResult;
|
|
|
|
|
import org.bukkit.util.Vector;
|
|
|
|
|
+import org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking;
|
|
|
|
|
|
|
|
|
|
public class CraftBlock implements Block {
|
|
|
|
|
private final net.minecraft.world.level.LevelAccessor world;
|
|
|
|
|
@@ -75,6 +76,11 @@ public class CraftBlock implements Block {
|
|
|
|
|
@@ -75,6 +75,11 @@ public class CraftBlock implements Block {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public net.minecraft.world.level.block.state.BlockState getNMS() {
|
|
|
|
|
+ // Folia start - parallel world ticking
|
|
|
|
|
+ if (SparklyPaperParallelWorldTicking.enabled && world instanceof ServerLevel serverWorld) { // Leaf - SparklyPaper parallel world ticking mod (make configurable)
|
|
|
|
|
+ // SparklyPaper start - parallel world ticking
|
|
|
|
|
+ if (org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking.enabled && world instanceof ServerLevel serverWorld) { // Leaf - SparklyPaper - parallel world ticking mod (make configurable)
|
|
|
|
|
+ ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(serverWorld, position, "Cannot read world asynchronously");
|
|
|
|
|
+ }
|
|
|
|
|
+ // Folia end - parallel world ticking
|
|
|
|
|
+ // SparklyPaper end - parallel world ticking
|
|
|
|
|
return this.world.getBlockState(this.position);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -157,6 +163,11 @@ public class CraftBlock implements Block {
|
|
|
|
|
@@ -157,6 +162,11 @@ public class CraftBlock implements Block {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setData(final byte data, int flag) {
|
|
|
|
|
+ // SparklyPaper start - parallel world ticking
|
|
|
|
|
+ if (SparklyPaperParallelWorldTicking.enabled && world instanceof ServerLevel serverWorld) { // Leaf - SparklyPaper parallel world ticking mod (make configurable)
|
|
|
|
|
+ if (org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking.enabled && world instanceof ServerLevel serverWorld) { // Leaf - SparklyPaper - parallel world ticking mod (make configurable)
|
|
|
|
|
+ ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(serverWorld, position, "Cannot modify world asynchronously");
|
|
|
|
|
+ }
|
|
|
|
|
+ // SparklyPaper end - parallel world ticking
|
|
|
|
|
this.world.setBlock(this.position, CraftMagicNumbers.getBlock(this.getType(), data), flag);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -198,6 +209,12 @@ public class CraftBlock implements Block {
|
|
|
|
|
@@ -198,6 +208,12 @@ public class CraftBlock implements Block {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean setTypeAndData(LevelAccessor world, BlockPos position, net.minecraft.world.level.block.state.BlockState old, net.minecraft.world.level.block.state.BlockState blockData, boolean applyPhysics) {
|
|
|
|
|
+ // SparklyPaper start - parallel world ticking
|
|
|
|
|
+ if (SparklyPaperParallelWorldTicking.enabled && world instanceof ServerLevel serverWorld) { // Leaf - SparklyPaper parallel world ticking mod (make configurable)
|
|
|
|
|
+ if (org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking.enabled && world instanceof ServerLevel serverWorld) { // Leaf - SparklyPaper - parallel world ticking mod (make configurable)
|
|
|
|
|
+ ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(serverWorld, position, "Cannot modify world asynchronously");
|
|
|
|
|
+ }
|
|
|
|
|
+ // SparklyPaper end - parallel world ticking
|
|
|
|
|
@@ -391,12 +364,12 @@ index 973b297a22c0cc53f966582c67c3688f4b2205c7..747f20d080b602ab9a1c551c648bf546
|
|
|
|
|
// SPIGOT-611: need to do this to prevent glitchiness. Easier to handle this here (like /setblock) than to fix weirdness in tile entity cleanup
|
|
|
|
|
if (old.hasBlockEntity() && blockData.getBlock() != old.getBlock()) { // SPIGOT-3725 remove old tile entity if block changes
|
|
|
|
|
// SPIGOT-4612: faster - just clear tile
|
|
|
|
|
@@ -343,18 +360,33 @@ public class CraftBlock implements Block {
|
|
|
|
|
@@ -343,18 +359,33 @@ public class CraftBlock implements Block {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Biome getBiome() {
|
|
|
|
|
+ // SparklyPaper start - parallel world ticking
|
|
|
|
|
+ if (SparklyPaperParallelWorldTicking.enabled && world instanceof ServerLevel serverWorld) { // Leaf - SparklyPaper parallel world ticking mod (make configurable)
|
|
|
|
|
+ if (org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking.enabled && world instanceof ServerLevel serverWorld) { // Leaf - SparklyPaper - parallel world ticking mod (make configurable)
|
|
|
|
|
+ ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(serverWorld, position, "Cannot read world asynchronously");
|
|
|
|
|
+ }
|
|
|
|
|
+ // SparklyPaper end - parallel world ticking
|
|
|
|
|
@@ -407,7 +380,7 @@ index 973b297a22c0cc53f966582c67c3688f4b2205c7..747f20d080b602ab9a1c551c648bf546
|
|
|
|
|
@Override
|
|
|
|
|
public Biome getComputedBiome() {
|
|
|
|
|
+ // SparklyPaper start - parallel world ticking
|
|
|
|
|
+ if (SparklyPaperParallelWorldTicking.enabled && world instanceof ServerLevel serverWorld) { // Leaf - SparklyPaper parallel world ticking mod (make configurable)
|
|
|
|
|
+ if (org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking.enabled && world instanceof ServerLevel serverWorld) { // Leaf - SparklyPaper - parallel world ticking mod (make configurable)
|
|
|
|
|
+ ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(serverWorld, position, "Cannot read world asynchronously");
|
|
|
|
|
+ }
|
|
|
|
|
+ // SparklyPaper end - parallel world ticking
|
|
|
|
|
@@ -418,102 +391,102 @@ index 973b297a22c0cc53f966582c67c3688f4b2205c7..747f20d080b602ab9a1c551c648bf546
|
|
|
|
|
@Override
|
|
|
|
|
public void setBiome(Biome bio) {
|
|
|
|
|
+ // SparklyPaper start - parallel world ticking
|
|
|
|
|
+ if (SparklyPaperParallelWorldTicking.enabled && world instanceof ServerLevel serverWorld) { // Leaf - SparklyPaper parallel world ticking mod (make configurable)
|
|
|
|
|
+ if (org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking.enabled && world instanceof ServerLevel serverWorld) { // Leaf - SparklyPaper - parallel world ticking mod (make configurable)
|
|
|
|
|
+ ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(serverWorld, position, "Cannot modify world asynchronously");
|
|
|
|
|
+ }
|
|
|
|
|
+ // SparklyPaper end - parallel world ticking
|
|
|
|
|
this.getWorld().setBiome(this.getX(), this.getY(), this.getZ(), bio);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -375,6 +407,11 @@ public class CraftBlock implements Block {
|
|
|
|
|
@@ -375,6 +406,11 @@ public class CraftBlock implements Block {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isBlockIndirectlyPowered() {
|
|
|
|
|
+ // SparklyPaper start - parallel world ticking
|
|
|
|
|
+ if (SparklyPaperParallelWorldTicking.enabled && world instanceof ServerLevel serverWorld) { // Leaf - SparklyPaper parallel world ticking mod (make configurable)
|
|
|
|
|
+ if (org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking.enabled && world instanceof ServerLevel serverWorld) { // Leaf - SparklyPaper - parallel world ticking mod (make configurable)
|
|
|
|
|
+ ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(serverWorld, position, "Cannot read world asynchronously");
|
|
|
|
|
+ }
|
|
|
|
|
+ // SparklyPaper end - parallel world ticking
|
|
|
|
|
return this.world.getMinecraftWorld().hasNeighborSignal(this.position);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -414,6 +451,11 @@ public class CraftBlock implements Block {
|
|
|
|
|
@@ -414,6 +450,11 @@ public class CraftBlock implements Block {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int getBlockPower(BlockFace face) {
|
|
|
|
|
+ // SparklyPaper start - parallel world ticking
|
|
|
|
|
+ if (SparklyPaperParallelWorldTicking.enabled && world instanceof ServerLevel serverWorld) { // Leaf - SparklyPaper parallel world ticking mod (make configurable)
|
|
|
|
|
+ if (org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking.enabled && world instanceof ServerLevel serverWorld) { // Leaf - SparklyPaper - parallel world ticking mod (make configurable)
|
|
|
|
|
+ ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(serverWorld, position, "Cannot read world asynchronously");
|
|
|
|
|
+ }
|
|
|
|
|
+ // SparklyPaper end - parallel world ticking
|
|
|
|
|
int power = 0;
|
|
|
|
|
net.minecraft.world.level.Level world = this.world.getMinecraftWorld();
|
|
|
|
|
int x = this.getX();
|
|
|
|
|
@@ -484,6 +526,11 @@ public class CraftBlock implements Block {
|
|
|
|
|
@@ -484,6 +525,11 @@ public class CraftBlock implements Block {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean breakNaturally() {
|
|
|
|
|
+ // SparklyPaper start - parallel world ticking
|
|
|
|
|
+ if (SparklyPaperParallelWorldTicking.enabled && world instanceof ServerLevel serverWorld) { // Leaf - SparklyPaper parallel world ticking mod (make configurable)
|
|
|
|
|
+ if (org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking.enabled && world instanceof ServerLevel serverWorld) { // Leaf - SparklyPaper - parallel world ticking mod (make configurable)
|
|
|
|
|
+ ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(serverWorld, position, "Cannot modify world asynchronously");
|
|
|
|
|
+ }
|
|
|
|
|
+ // SparklyPaper end - parallel world ticking
|
|
|
|
|
return this.breakNaturally(null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -543,6 +590,11 @@ public class CraftBlock implements Block {
|
|
|
|
|
@@ -543,6 +589,11 @@ public class CraftBlock implements Block {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean applyBoneMeal(BlockFace face) {
|
|
|
|
|
+ // SparklyPaper start - parallel world ticking
|
|
|
|
|
+ if (SparklyPaperParallelWorldTicking.enabled && world instanceof ServerLevel serverWorld) { // Leaf - SparklyPaper parallel world ticking mod (make configurable)
|
|
|
|
|
+ if (org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking.enabled && world instanceof ServerLevel serverWorld) { // Leaf - SparklyPaper - parallel world ticking mod (make configurable)
|
|
|
|
|
+ ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(serverWorld, position, "Cannot modify world asynchronously");
|
|
|
|
|
+ }
|
|
|
|
|
+ // SparklyPaper end - parallel world ticking
|
|
|
|
|
Direction direction = CraftBlock.blockFaceToNotch(face);
|
|
|
|
|
BlockFertilizeEvent event = null;
|
|
|
|
|
ServerLevel world = this.getCraftWorld().getHandle();
|
|
|
|
|
@@ -554,8 +606,8 @@ public class CraftBlock implements Block {
|
|
|
|
|
@@ -554,8 +605,8 @@ public class CraftBlock implements Block {
|
|
|
|
|
world.captureTreeGeneration = false;
|
|
|
|
|
|
|
|
|
|
if (world.capturedBlockStates.size() > 0) {
|
|
|
|
|
- TreeType treeType = SaplingBlock.treeType;
|
|
|
|
|
- SaplingBlock.treeType = null;
|
|
|
|
|
+ TreeType treeType = SaplingBlock.getTreeTypeRT(); // SparklyPaper - parallel world ticking // Leaf - SparklyPaper parallel world ticking mod (collapse original behavior)
|
|
|
|
|
+ SaplingBlock.setTreeTypeRT(null); // SparklyPaper - parallel world ticking // Leaf - SparklyPaper parallel world ticking mod (collapse original behavior)
|
|
|
|
|
+ TreeType treeType = SaplingBlock.getTreeTypeRT(); // SparklyPaper - parallel world ticking // Leaf - SparklyPaper - parallel world ticking mod (collapse original behavior)
|
|
|
|
|
+ SaplingBlock.setTreeTypeRT(null); // SparklyPaper - parallel world ticking // Leaf - SparklyPaper - parallel world ticking mod (collapse original behavior)
|
|
|
|
|
List<BlockState> blocks = new ArrayList<>(world.capturedBlockStates.values());
|
|
|
|
|
world.capturedBlockStates.clear();
|
|
|
|
|
StructureGrowEvent structureEvent = null;
|
|
|
|
|
@@ -644,6 +696,11 @@ public class CraftBlock implements Block {
|
|
|
|
|
@@ -644,6 +695,11 @@ public class CraftBlock implements Block {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public RayTraceResult rayTrace(Location start, Vector direction, double maxDistance, FluidCollisionMode fluidCollisionMode) {
|
|
|
|
|
+ // SparklyPaper start - parallel world ticking
|
|
|
|
|
+ if (SparklyPaperParallelWorldTicking.enabled && world instanceof ServerLevel serverWorld) { // Leaf - SparklyPaper parallel world ticking mod (make configurable)
|
|
|
|
|
+ if (org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking.enabled && world instanceof ServerLevel serverWorld) { // Leaf - SparklyPaper - parallel world ticking mod (make configurable)
|
|
|
|
|
+ ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(serverWorld, position, "Cannot read world asynchronously");
|
|
|
|
|
+ }
|
|
|
|
|
+ // SparklyPaper end - parallel world ticking
|
|
|
|
|
Preconditions.checkArgument(start != null, "Location start cannot be null");
|
|
|
|
|
Preconditions.checkArgument(this.getWorld().equals(start.getWorld()), "Location start cannot be a different world");
|
|
|
|
|
start.checkFinite();
|
|
|
|
|
@@ -685,6 +742,11 @@ public class CraftBlock implements Block {
|
|
|
|
|
@@ -685,6 +741,11 @@ public class CraftBlock implements Block {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean canPlace(BlockData data) {
|
|
|
|
|
+ // SparklyPaper start - parallel world ticking
|
|
|
|
|
+ if (SparklyPaperParallelWorldTicking.enabled && world instanceof ServerLevel serverWorld) { // Leaf - SparklyPaper parallel world ticking mod (make configurable)
|
|
|
|
|
+ if (org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking.enabled && world instanceof ServerLevel serverWorld) { // Leaf - SparklyPaper - parallel world ticking mod (make configurable)
|
|
|
|
|
+ ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(serverWorld, position, "Cannot read world asynchronously");
|
|
|
|
|
+ }
|
|
|
|
|
+ // SparklyPaper end - parallel world ticking
|
|
|
|
|
Preconditions.checkArgument(data != null, "BlockData cannot be null");
|
|
|
|
|
net.minecraft.world.level.block.state.BlockState iblockdata = ((CraftBlockData) data).getState();
|
|
|
|
|
net.minecraft.world.level.Level world = this.world.getMinecraftWorld();
|
|
|
|
|
@@ -719,6 +781,11 @@ public class CraftBlock implements Block {
|
|
|
|
|
@@ -719,6 +780,11 @@ public class CraftBlock implements Block {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void tick() {
|
|
|
|
|
+ // SparklyPaper start - parallel world ticking
|
|
|
|
|
+ if (SparklyPaperParallelWorldTicking.enabled && world instanceof ServerLevel serverWorld) { // Leaf - SparklyPaper parallel world ticking mod (make configurable)
|
|
|
|
|
+ if (org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking.enabled && world instanceof ServerLevel serverWorld) { // Leaf - SparklyPaper - parallel world ticking mod (make configurable)
|
|
|
|
|
+ ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(serverWorld, position, "Cannot modify world asynchronously");
|
|
|
|
|
+ }
|
|
|
|
|
+ // SparklyPaper end - parallel world ticking
|
|
|
|
|
@@ -521,34 +494,19 @@ index 973b297a22c0cc53f966582c67c3688f4b2205c7..747f20d080b602ab9a1c551c648bf546
|
|
|
|
|
this.getNMS().tick(level, this.position, level.random);
|
|
|
|
|
}
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java
|
|
|
|
|
index 768d3f93da2522d467183654260a8bd8653588b1..bad74104dcfde34ae0dec99adfe81e71132b7c28 100644
|
|
|
|
|
index 768d3f93da2522d467183654260a8bd8653588b1..58fdc0e7bb5d377c6dad1af6307d5d0d11b1ee45 100644
|
|
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java
|
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java
|
|
|
|
|
@@ -11,12 +11,14 @@ import net.minecraft.network.protocol.game.ClientGamePacketListener;
|
|
|
|
|
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
|
|
|
|
|
import net.minecraft.server.MinecraftServer;
|
|
|
|
|
import net.minecraft.world.level.LevelAccessor;
|
|
|
|
|
+import net.minecraft.world.level.block.DispenserBlock;
|
|
|
|
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
|
|
|
|
import org.bukkit.Location;
|
|
|
|
|
import org.bukkit.World;
|
|
|
|
|
import org.bukkit.block.TileState;
|
|
|
|
|
import org.bukkit.craftbukkit.util.CraftLocation;
|
|
|
|
|
import org.bukkit.persistence.PersistentDataContainer;
|
|
|
|
|
+import org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking;
|
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
|
import org.jetbrains.annotations.Nullable;
|
|
|
|
|
|
|
|
|
|
@@ -26,6 +28,26 @@ public abstract class CraftBlockEntityState<T extends BlockEntity> extends Craft
|
|
|
|
|
@@ -26,6 +26,27 @@ public abstract class CraftBlockEntityState<T extends BlockEntity> extends Craft
|
|
|
|
|
private final T snapshot;
|
|
|
|
|
public boolean snapshotDisabled; // Paper
|
|
|
|
|
public static boolean DISABLE_SNAPSHOT = false; // Paper
|
|
|
|
|
+ public static ThreadLocal<Boolean> DISABLE_SNAPSHOT_TL = ThreadLocal.withInitial(() -> Boolean.FALSE); // SparklyPaper - parallel world ticking // Leaf - SparklyPaper parallel world ticking mod (distinguish name)
|
|
|
|
|
+ public static ThreadLocal<Boolean> DISABLE_SNAPSHOT_TL = ThreadLocal.withInitial(() -> Boolean.FALSE); // SparklyPaper - parallel world ticking // Leaf - SparklyPaper - parallel world ticking mod (distinguish name)
|
|
|
|
|
+
|
|
|
|
|
+ // Leaf - SparklyPaper parallel world ticking mod
|
|
|
|
|
+ // Leaf start - SparklyPaper - parallel world ticking mod
|
|
|
|
|
+ // refer to original field in case plugins attempt to modify it
|
|
|
|
|
+ public static boolean getDisableSnapshotTL() {
|
|
|
|
|
+ if (SparklyPaperParallelWorldTicking.enabled && DISABLE_SNAPSHOT_TL.get())
|
|
|
|
|
+ if (org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking.enabled && DISABLE_SNAPSHOT_TL.get())
|
|
|
|
|
+ return true;
|
|
|
|
|
+ synchronized (CraftBlockEntityState.class) {
|
|
|
|
|
+ return DISABLE_SNAPSHOT;
|
|
|
|
|
@@ -557,44 +515,37 @@ index 768d3f93da2522d467183654260a8bd8653588b1..bad74104dcfde34ae0dec99adfe81e71
|
|
|
|
|
+
|
|
|
|
|
+ // update original field in case plugins attempt to access it
|
|
|
|
|
+ public static void setDisableSnapshotTL(boolean value) {
|
|
|
|
|
+ if (SparklyPaperParallelWorldTicking.enabled)
|
|
|
|
|
+ if (org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking.enabled)
|
|
|
|
|
+ DISABLE_SNAPSHOT_TL.set(value);
|
|
|
|
|
+ synchronized (CraftBlockEntityState.class) {
|
|
|
|
|
+ DISABLE_SNAPSHOT = value;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ // Leaf end - SparklyPaper - parallel world ticking mod
|
|
|
|
|
|
|
|
|
|
public CraftBlockEntityState(World world, T tileEntity) {
|
|
|
|
|
super(world, tileEntity.getBlockPos(), tileEntity.getBlockState());
|
|
|
|
|
@@ -34,8 +56,8 @@ public abstract class CraftBlockEntityState<T extends BlockEntity> extends Craft
|
|
|
|
|
@@ -34,8 +55,8 @@ public abstract class CraftBlockEntityState<T extends BlockEntity> extends Craft
|
|
|
|
|
|
|
|
|
|
try { // Paper - Show blockstate location if we failed to read it
|
|
|
|
|
// Paper start
|
|
|
|
|
- this.snapshotDisabled = DISABLE_SNAPSHOT;
|
|
|
|
|
- if (DISABLE_SNAPSHOT) {
|
|
|
|
|
+ this.snapshotDisabled = getDisableSnapshotTL(); // SparklyPaper - parallel world ticking // Leaf - SparklyPaper parallel world ticking mod (collapse original behavior)
|
|
|
|
|
+ if (getDisableSnapshotTL()) { // SparklyPaper - parallel world ticking // Leaf - SparklyPaper parallel world ticking mod (collapse original behavior)
|
|
|
|
|
+ this.snapshotDisabled = getDisableSnapshotTL(); // SparklyPaper - parallel world ticking // Leaf - SparklyPaper - parallel world ticking mod (collapse original behavior)
|
|
|
|
|
+ if (getDisableSnapshotTL()) { // SparklyPaper - parallel world ticking // Leaf - SparklyPaper - parallel world ticking mod (collapse original behavior)
|
|
|
|
|
this.snapshot = this.tileEntity;
|
|
|
|
|
} else {
|
|
|
|
|
this.snapshot = this.createSnapshot(tileEntity);
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
|
|
|
|
|
index fa63a6cfcfcc4eee4503a82d85333c139c8c8b2b..bc0f999f89fedebe58b6fa554c2abbacb65adbeb 100644
|
|
|
|
|
index fa63a6cfcfcc4eee4503a82d85333c139c8c8b2b..d106f65e4b745242484a195958fc559268a7dee0 100644
|
|
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
|
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
|
|
|
|
|
@@ -21,6 +21,7 @@ import org.bukkit.material.Attachable;
|
|
|
|
|
import org.bukkit.material.MaterialData;
|
|
|
|
|
import org.bukkit.metadata.MetadataValue;
|
|
|
|
|
import org.bukkit.plugin.Plugin;
|
|
|
|
|
+import org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking;
|
|
|
|
|
|
|
|
|
|
public class CraftBlockState implements BlockState {
|
|
|
|
|
|
|
|
|
|
@@ -215,6 +216,12 @@ public class CraftBlockState implements BlockState {
|
|
|
|
|
@@ -215,6 +215,12 @@ public class CraftBlockState implements BlockState {
|
|
|
|
|
LevelAccessor access = this.getWorldHandle();
|
|
|
|
|
CraftBlock block = this.getBlock();
|
|
|
|
|
|
|
|
|
|
+ // SparklyPaper start - parallel world ticking
|
|
|
|
|
+ if (SparklyPaperParallelWorldTicking.enabled && access instanceof net.minecraft.server.level.ServerLevel serverWorld) {
|
|
|
|
|
+ if (org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking.enabled && access instanceof net.minecraft.server.level.ServerLevel serverWorld) {
|
|
|
|
|
+ ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(serverWorld, position, "Cannot modify world asynchronously");
|
|
|
|
|
+ }
|
|
|
|
|
+ // SparklyPaper end - parallel world ticking
|
|
|
|
|
@@ -602,17 +553,17 @@ index fa63a6cfcfcc4eee4503a82d85333c139c8c8b2b..bc0f999f89fedebe58b6fa554c2abbac
|
|
|
|
|
if (block.getType() != this.getType()) {
|
|
|
|
|
if (!force) {
|
|
|
|
|
return false;
|
|
|
|
|
@@ -350,6 +357,8 @@ public class CraftBlockState implements BlockState {
|
|
|
|
|
@@ -350,6 +356,8 @@ public class CraftBlockState implements BlockState {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public java.util.Collection<org.bukkit.inventory.ItemStack> getDrops(org.bukkit.inventory.ItemStack item, org.bukkit.entity.Entity entity) {
|
|
|
|
|
+ if (SparklyPaperParallelWorldTicking.enabled) // Leaf - SparklyPaper parallel world ticking mod (make configurable)
|
|
|
|
|
+ if (org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking.enabled) // Leaf - SparklyPaper - parallel world ticking mod (make configurable)
|
|
|
|
|
+ ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(world.getHandle(), position, "Cannot modify world asynchronously"); // SparklyPaper - parallel world ticking
|
|
|
|
|
this.requirePlaced();
|
|
|
|
|
net.minecraft.world.item.ItemStack nms = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(item);
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java
|
|
|
|
|
index 55572e799b5c8a74a546ac8febc14f80d5731c52..11a3970a9f3bee1d05327b8a5c5dde4f746929ac 100644
|
|
|
|
|
index 55572e799b5c8a74a546ac8febc14f80d5731c52..08a06c23c831a4de45b3e537228b837911019da8 100644
|
|
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java
|
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java
|
|
|
|
|
@@ -249,8 +249,8 @@ public final class CraftBlockStates {
|
|
|
|
|
@@ -621,8 +572,8 @@ index 55572e799b5c8a74a546ac8febc14f80d5731c52..11a3970a9f3bee1d05327b8a5c5dde4f
|
|
|
|
|
// Paper start - block state snapshots
|
|
|
|
|
- boolean prev = CraftBlockEntityState.DISABLE_SNAPSHOT;
|
|
|
|
|
- CraftBlockEntityState.DISABLE_SNAPSHOT = !useSnapshot;
|
|
|
|
|
+ boolean prev = CraftBlockEntityState.getDisableSnapshotTL(); // SparklyPaper - parallel world ticking // Leaf - SparklyPaper parallel world ticking mod (collapse original behavior)
|
|
|
|
|
+ CraftBlockEntityState.setDisableSnapshotTL(!useSnapshot); // SparklyPaper - parallel world ticking // Leaf - SparklyPaper parallel world ticking mod (collapse original behavior)
|
|
|
|
|
+ boolean prev = CraftBlockEntityState.getDisableSnapshotTL(); // SparklyPaper - parallel world ticking // Leaf - SparklyPaper - parallel world ticking mod (collapse original behavior)
|
|
|
|
|
+ CraftBlockEntityState.setDisableSnapshotTL(!useSnapshot); // SparklyPaper - parallel world ticking // Leaf - SparklyPaper - parallel world ticking mod (collapse original behavior)
|
|
|
|
|
try {
|
|
|
|
|
// Paper end
|
|
|
|
|
CraftBlockState blockState = CraftBlockStates.getBlockState(world, blockPosition, blockData, tileEntity);
|
|
|
|
|
@@ -631,33 +582,25 @@ index 55572e799b5c8a74a546ac8febc14f80d5731c52..11a3970a9f3bee1d05327b8a5c5dde4f
|
|
|
|
|
// Paper start
|
|
|
|
|
} finally {
|
|
|
|
|
- CraftBlockEntityState.DISABLE_SNAPSHOT = prev;
|
|
|
|
|
+ CraftBlockEntityState.setDisableSnapshotTL(prev); // SparklyPaper - parallel world ticking // Leaf - SparklyPaper parallel world ticking mod (collapse original behavior)
|
|
|
|
|
+ CraftBlockEntityState.setDisableSnapshotTL(prev); // SparklyPaper - parallel world ticking // Leaf - SparklyPaper - parallel world ticking mod (collapse original behavior)
|
|
|
|
|
}
|
|
|
|
|
// Paper end
|
|
|
|
|
}
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
|
|
|
index fbb4dd93c263c898731902b73dbd1c62df1eea4b..d19f87f1bbad8832db10d4d49186fe260728b40e 100644
|
|
|
|
|
index fbb4dd93c263c898731902b73dbd1c62df1eea4b..138662f3e57f9741a41701b5a5a65a859a31dfc8 100644
|
|
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
|
|
|
@@ -254,6 +254,7 @@ import org.bukkit.inventory.meta.BookMeta;
|
|
|
|
|
import org.bukkit.inventory.view.AnvilView;
|
|
|
|
|
import org.bukkit.potion.PotionEffect;
|
|
|
|
|
import org.bukkit.util.Vector;
|
|
|
|
|
+import org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking;
|
|
|
|
|
|
|
|
|
|
public class CraftEventFactory {
|
|
|
|
|
|
|
|
|
|
@@ -961,6 +962,27 @@ public class CraftEventFactory {
|
|
|
|
|
@@ -961,6 +961,28 @@ public class CraftEventFactory {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static BlockPos sourceBlockOverride = null; // SPIGOT-7068: Add source block override, not the most elegant way but better than passing down a BlockPosition up to five methods deep.
|
|
|
|
|
+ public static final ThreadLocal<BlockPos> sourceBlockOverrideRT = new ThreadLocal<>(); // SparklyPaper - parallel world ticking (this is from Folia, fixes concurrency bugs with sculk catalysts)
|
|
|
|
|
+
|
|
|
|
|
+ // Leaf - SparklyPaper parallel world ticking mod
|
|
|
|
|
+ // Leaf start - SparklyPaper - parallel world ticking mod
|
|
|
|
|
+ // refer to original field in case plugins attempt to modify it
|
|
|
|
|
+ public static BlockPos getSourceBlockOverrideRT() {
|
|
|
|
|
+ BlockPos sourceBlockOverrideRTCopy;
|
|
|
|
|
+ if (SparklyPaperParallelWorldTicking.enabled && (sourceBlockOverrideRTCopy = sourceBlockOverrideRT.get()) != null)
|
|
|
|
|
+ if (org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking.enabled && (sourceBlockOverrideRTCopy = sourceBlockOverrideRT.get()) != null)
|
|
|
|
|
+ return sourceBlockOverrideRTCopy;
|
|
|
|
|
+ synchronized (CraftEventFactory.class) {
|
|
|
|
|
+ return sourceBlockOverride;
|
|
|
|
|
@@ -666,12 +609,13 @@ index fbb4dd93c263c898731902b73dbd1c62df1eea4b..d19f87f1bbad8832db10d4d49186fe26
|
|
|
|
|
+
|
|
|
|
|
+ // update original field in case plugins attempt to access it
|
|
|
|
|
+ public static void setSourceBlockOverrideRT(BlockPos value) {
|
|
|
|
|
+ if (SparklyPaperParallelWorldTicking.enabled)
|
|
|
|
|
+ if (org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking.enabled)
|
|
|
|
|
+ sourceBlockOverrideRT.set(value);
|
|
|
|
|
+ synchronized (CraftEventFactory.class) {
|
|
|
|
|
+ sourceBlockOverride = value;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ // Leaf end - SparklyPaper - parallel world ticking mod
|
|
|
|
|
|
|
|
|
|
public static boolean handleBlockSpreadEvent(LevelAccessor world, BlockPos source, BlockPos target, net.minecraft.world.level.block.state.BlockState block, int flag) {
|
|
|
|
|
// Suppress during worldgen
|
|
|
|
|
@@ -680,7 +624,7 @@ index fbb4dd93c263c898731902b73dbd1c62df1eea4b..d19f87f1bbad8832db10d4d49186fe26
|
|
|
|
|
state.setData(block);
|
|
|
|
|
|
|
|
|
|
- BlockSpreadEvent event = new BlockSpreadEvent(state.getBlock(), CraftBlock.at(world, CraftEventFactory.sourceBlockOverride != null ? CraftEventFactory.sourceBlockOverride : source), state);
|
|
|
|
|
+ BlockSpreadEvent event = new BlockSpreadEvent(state.getBlock(), CraftBlock.at(world, CraftEventFactory.getSourceBlockOverrideRT() != null ? CraftEventFactory.getSourceBlockOverrideRT() : source), state); // SparklyPaper - parallel world ticking // Leaf - SparklyPaper parallel world ticking mod (collapse original behavior)
|
|
|
|
|
+ BlockSpreadEvent event = new BlockSpreadEvent(state.getBlock(), CraftBlock.at(world, CraftEventFactory.getSourceBlockOverrideRT() != null ? CraftEventFactory.getSourceBlockOverrideRT() : source), state); // SparklyPaper - parallel world ticking // Leaf - SparklyPaper - parallel world ticking mod (collapse original behavior)
|
|
|
|
|
Bukkit.getPluginManager().callEvent(event);
|
|
|
|
|
|
|
|
|
|
if (!event.isCancelled()) {
|
|
|
|
|
@@ -689,7 +633,7 @@ index fbb4dd93c263c898731902b73dbd1c62df1eea4b..d19f87f1bbad8832db10d4d49186fe26
|
|
|
|
|
|
|
|
|
|
org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(bukkitBlock, craftItem.clone(), CraftVector.toBukkit(to));
|
|
|
|
|
- if (!net.minecraft.world.level.block.DispenserBlock.eventFired) {
|
|
|
|
|
+ if (!net.minecraft.world.level.block.DispenserBlock.getEventFiredTL()) { // SparklyPaper - parallel world ticking // Leaf - SparklyPaper parallel world ticking mod (collapse original behavior)
|
|
|
|
|
+ if (!net.minecraft.world.level.block.DispenserBlock.getEventFiredTL()) { // SparklyPaper - parallel world ticking // Leaf - SparklyPaper - parallel world ticking mod (collapse original behavior)
|
|
|
|
|
if (!event.callEvent()) {
|
|
|
|
|
return itemStack;
|
|
|
|
|
}
|
|
|
|
|
|