68 lines
3.3 KiB
Diff
68 lines
3.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: MrHua269 <novau233@163.com>
|
|
Date: Wed, 7 Feb 2024 06:30:03 +0000
|
|
Subject: [PATCH] Try fixing folia spector teleportation
|
|
|
|
|
|
diff --git a/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaSpectorTeleportationFixConfig.java b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaSpectorTeleportationFixConfig.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..01f8c6ff3662569be5a4ff998bcd4fbbcb555105
|
|
--- /dev/null
|
|
+++ b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaSpectorTeleportationFixConfig.java
|
|
@@ -0,0 +1,25 @@
|
|
+package me.earthme.luminol.config.modules.fixes;
|
|
+
|
|
+import me.earthme.luminol.config.ConfigInfo;
|
|
+import me.earthme.luminol.config.EnumConfigCategory;
|
|
+import me.earthme.luminol.config.IConfigModule;
|
|
+
|
|
+public class FoliaSpectorTeleportationFixConfig implements IConfigModule {
|
|
+ @ConfigInfo(baseName = "enabled", comments =
|
|
+ """
|
|
+ The teleportation of spector players would call absMoveTo directly.\s
|
|
+ And when the camera teleported to another region,this would call absMoveTo\s
|
|
+ to let the spector player move to another region without any checks, which \s
|
|
+ would trigger the async catcher and crash the server""")
|
|
+ public static boolean fixSpectorTeleportFolia = false;
|
|
+
|
|
+ @Override
|
|
+ public EnumConfigCategory getCategory() {
|
|
+ return EnumConfigCategory.FIXES;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public String getBaseName() {
|
|
+ return "folia.fix_spector_teleportation";
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
index 93c038ba1fd216fd11ab8b5cec5807453f34e152..c72bda7413d9a7ce763743d0efbd85257262477e 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
@@ -1162,9 +1162,24 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
|
|
}
|
|
|
|
Entity entity = this.getCamera();
|
|
+ //Luminol start - Fix folia spector teleportation
|
|
+ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(entity) && me.earthme.luminol.config.modules.fixes.FoliaSpectorTeleportationFixConfig.fixSpectorTeleportFolia){
|
|
+ this.setCamera(this);
|
|
+ }
|
|
+ //Luminol end
|
|
|
|
if (entity != this) {
|
|
- if (entity.isAlive()) {
|
|
+ // Luminol start - Fix folia spector teleportation
|
|
+ var flag = false;
|
|
+ var cameraPos = entity.blockPosition();
|
|
+ var cameraLevel = entity.level();
|
|
+ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(cameraLevel, cameraPos) && me.earthme.luminol.config.modules.fixes.FoliaSpectorTeleportationFixConfig.fixSpectorTeleportFolia){
|
|
+ this.setCamera(this);
|
|
+ flag = true;
|
|
+ }
|
|
+ // Luminol end
|
|
+
|
|
+ if (entity.isAlive() && !flag) { // Luminol - Fix folia spector teleportation
|
|
this.absMoveTo(entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot());
|
|
this.serverLevel().getChunkSource().move(this);
|
|
if (this.wantsToStopRiding()) {
|