121 lines
7.2 KiB
Diff
121 lines
7.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: MrHua269 <wangxyper@163.com>
|
|
Date: Wed, 29 Jan 2025 09:08:22 +0800
|
|
Subject: [PATCH] Add config to disable async catchers
|
|
|
|
|
|
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 c95769a4e64fabd7acdff6c5f6f349107e1cf5c0..4efa1c057ae6cfdea7889c372bd62dc14637daa0 100644
|
|
--- a/src/main/java/ca/spottedleaf/moonrise/common/util/TickThread.java
|
|
+++ b/src/main/java/ca/spottedleaf/moonrise/common/util/TickThread.java
|
|
@@ -48,14 +48,14 @@ public class TickThread extends Thread {
|
|
*/
|
|
@Deprecated
|
|
public static void ensureTickThread(final String reason) {
|
|
- if (!isTickThread()) {
|
|
+ if (!isTickThread() && !me.earthme.luminol.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Luminol
|
|
LOGGER.error("Thread failed main thread check: " + reason + ", context=" + getThreadContext(), new Throwable());
|
|
throw new IllegalStateException(reason);
|
|
}
|
|
}
|
|
|
|
public static void ensureTickThread(final Level world, final BlockPos pos, final String reason) {
|
|
- if (!isTickThreadFor(world, pos)) {
|
|
+ if (!isTickThreadFor(world, pos) && !me.earthme.luminol.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Luminol
|
|
final String ex = "Thread failed main thread check: " +
|
|
reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", block_pos=" + pos;
|
|
LOGGER.error(ex, new Throwable());
|
|
@@ -64,7 +64,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)) {
|
|
+ if (!isTickThreadFor(world, pos, blockRadius) && !me.earthme.luminol.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Luminol
|
|
final String ex = "Thread failed main thread check: " +
|
|
reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", block_pos=" + pos + ", block_radius=" + blockRadius;
|
|
LOGGER.error(ex, new Throwable());
|
|
@@ -73,7 +73,7 @@ public class TickThread extends Thread {
|
|
}
|
|
|
|
public static void ensureTickThread(final Level world, final ChunkPos pos, final String reason) {
|
|
- if (!isTickThreadFor(world, pos)) {
|
|
+ if (!isTickThreadFor(world, pos) && !me.earthme.luminol.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Luminol
|
|
final String ex = "Thread failed main thread check: " +
|
|
reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", chunk_pos=" + pos;
|
|
LOGGER.error(ex, new Throwable());
|
|
@@ -82,7 +82,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)) {
|
|
+ if (!isTickThreadFor(world, chunkX, chunkZ) && !me.earthme.luminol.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Luminol
|
|
final String ex = "Thread failed main thread check: " +
|
|
reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", chunk_pos=" + new ChunkPos(chunkX, chunkZ);
|
|
LOGGER.error(ex, new Throwable());
|
|
@@ -91,7 +91,7 @@ public class TickThread extends Thread {
|
|
}
|
|
|
|
public static void ensureTickThread(final Entity entity, final String reason) {
|
|
- if (!isTickThreadFor(entity)) {
|
|
+ if (!isTickThreadFor(entity) && !me.earthme.luminol.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Luminol
|
|
final String ex = "Thread failed main thread check: " +
|
|
reason + ", context=" + getThreadContext() + ", entity=" + EntityUtil.dumpEntity(entity);
|
|
LOGGER.error(ex, new Throwable());
|
|
@@ -100,7 +100,7 @@ public class TickThread extends Thread {
|
|
}
|
|
|
|
public static void ensureTickThread(final Level world, final AABB aabb, final String reason) {
|
|
- if (!isTickThreadFor(world, aabb)) {
|
|
+ if (!isTickThreadFor(world, aabb) && !me.earthme.luminol.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Luminol
|
|
final String ex = "Thread failed main thread check: " +
|
|
reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", aabb=" + aabb;
|
|
LOGGER.error(ex, new Throwable());
|
|
@@ -109,7 +109,7 @@ 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)) {
|
|
+ if (!isTickThreadFor(world, blockX, blockZ) && !me.earthme.luminol.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Luminol
|
|
final String ex = "Thread failed main thread check: " +
|
|
reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", block_pos=" + new Vec3(blockX, 0.0, blockZ);
|
|
LOGGER.error(ex, new Throwable());
|
|
diff --git a/src/main/java/me/earthme/luminol/config/modules/experiment/DisableAsyncCatcherConfig.java b/src/main/java/me/earthme/luminol/config/modules/experiment/DisableAsyncCatcherConfig.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..61f653eeca366672ded88c491cf5c59e546e7301
|
|
--- /dev/null
|
|
+++ b/src/main/java/me/earthme/luminol/config/modules/experiment/DisableAsyncCatcherConfig.java
|
|
@@ -0,0 +1,20 @@
|
|
+package me.earthme.luminol.config.modules.experiment;
|
|
+
|
|
+import me.earthme.luminol.config.ConfigInfo;
|
|
+import me.earthme.luminol.config.EnumConfigCategory;
|
|
+import me.earthme.luminol.config.IConfigModule;
|
|
+
|
|
+public class DisableAsyncCatcherConfig implements IConfigModule {
|
|
+ @ConfigInfo(baseName = "enabled")
|
|
+ public static boolean enabled = false;
|
|
+
|
|
+ @Override
|
|
+ public EnumConfigCategory getCategory() {
|
|
+ return EnumConfigCategory.EXPERIMENT;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public String getBaseName() {
|
|
+ return "disable_async_catchers";
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/org/spigotmc/AsyncCatcher.java b/src/main/java/org/spigotmc/AsyncCatcher.java
|
|
index 50f01faa88c8c658252fade3748f20e48e9c8432..36fa1f83c3286e10cc7c208a2a2f1a718d525ad8 100644
|
|
--- a/src/main/java/org/spigotmc/AsyncCatcher.java
|
|
+++ b/src/main/java/org/spigotmc/AsyncCatcher.java
|
|
@@ -7,7 +7,7 @@ public class AsyncCatcher {
|
|
public static boolean enabled = true;
|
|
|
|
public static void catchOp(String reason) {
|
|
- if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThread()) { // Paper - chunk system
|
|
+ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThread() && !me.earthme.luminol.config.modules.experiment.DisableAsyncCatcherConfig.enabled) { // Paper - chunk system // Luminol
|
|
MinecraftServer.LOGGER.error("Thread {} failed main thread check: {}", Thread.currentThread().getName(), reason, new Throwable()); // Paper
|
|
throw new IllegalStateException("Asynchronous " + reason + "!");
|
|
}
|