100 lines
4.8 KiB
Diff
100 lines
4.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
|
Date: Sun, 26 Nov 2023 21:23:06 +0800
|
|
Subject: [PATCH] Try fixing folia spector teleportation
|
|
|
|
|
|
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
|
index d032786938db9725e1be72dae63a1387bcb69d79..dcc52141b34b87a67c3d6070b68b58af4a7c4f26 100644
|
|
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
|
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
|
@@ -31,6 +31,7 @@ public class LuminolConfig {
|
|
public static String[] tpsColors = new String[]{"GREEN","YELLOW","RED","PURPLE"};
|
|
public static String[] pingColors = new String[]{"GREEN","YELLOW","RED","PURPLE"};
|
|
public static boolean disableUsernameCheck = false;
|
|
+ public static boolean fixSpectorTeleportFolia = false;
|
|
|
|
public static boolean safeTeleportation = true;
|
|
public static boolean enableSandDuping = false;
|
|
@@ -130,6 +131,7 @@ public class LuminolConfig {
|
|
tpsColors = get("misc.tpsbar_range_colors", List.of(tpsColors),"The bar and text color of each tps ranges.The last is the color of initial bar's color").toArray(String[]::new);
|
|
pingColors = get("misc.tpsbar_ping_range_colors",List.of(pingColors),"As same as the tpsColors").toArray(String[]::new);
|
|
disableUsernameCheck = get("misc.disable_username_check",disableUsernameCheck,"Disable username check that can accept usernames with other characters(such as Chinese).Not recommended to use");
|
|
+ fixSpectorTeleportFolia = get("misc.fix_folia_spector_teleport",fixSpectorTeleportFolia);
|
|
|
|
if (tpsbarEnabled){
|
|
initTpsbar();
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
index d7a280427442bac8cc8ccb542d24d4e0901df70a..755294e3f5b3fbcfbdc0cc85627b2487663ce591 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
@@ -18,6 +18,9 @@ import java.util.Optional;
|
|
import java.util.OptionalInt;
|
|
import java.util.Set;
|
|
import javax.annotation.Nullable;
|
|
+
|
|
+import io.papermc.paper.util.TickThread;
|
|
+import me.earthme.luminol.LuminolConfig;
|
|
import net.minecraft.BlockUtil;
|
|
import net.minecraft.ChatFormatting;
|
|
import net.minecraft.CrashReport;
|
|
@@ -836,18 +839,7 @@ public class ServerPlayer extends Player {
|
|
|
|
Entity entity = this.getCamera();
|
|
|
|
- if (entity != this) {
|
|
- if (entity.isAlive()) {
|
|
- this.absMoveTo(entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot());
|
|
- this.serverLevel().getChunkSource().move(this);
|
|
- if (this.wantsToStopRiding()) {
|
|
- this.setCamera(this);
|
|
- }
|
|
- } else {
|
|
- this.setCamera(this);
|
|
- }
|
|
- }
|
|
-
|
|
+ //Luminol - move up
|
|
CriteriaTriggers.TICK.trigger(this);
|
|
if (this.levitationStartPos != null) {
|
|
CriteriaTriggers.LEVITATION.trigger(this, this.levitationStartPos, this.tickCount - this.levitationStartTime);
|
|
@@ -856,6 +848,38 @@ public class ServerPlayer extends Player {
|
|
this.trackStartFallingPosition();
|
|
this.trackEnteredOrExitedLavaOnVehicle();
|
|
this.advancements.flushDirty(this);
|
|
+
|
|
+ if (entity != this) {
|
|
+ if (entity.isAlive()) {
|
|
+ //Luminol start - Fix spector camera
|
|
+ if (TickThread.isTickThreadFor(entity) || !LuminolConfig.fixSpectorTeleportFolia){
|
|
+ this.absMoveTo(entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot());
|
|
+ this.serverLevel().getChunkSource().move(this);
|
|
+ if (this.wantsToStopRiding()) {
|
|
+ this.setCamera(this);
|
|
+ }
|
|
+ }else{
|
|
+ this.teleportAsync(
|
|
+ ((ServerLevel) entity.level()),
|
|
+ entity.position,
|
|
+ entity.getYRot(),
|
|
+ entity.getXRot(),
|
|
+ null,
|
|
+ TeleportCause.SPECTATE,
|
|
+ Entity.TELEPORT_FLAG_LOAD_CHUNK | Entity.TELEPORT_FLAG_TELEPORT_PASSENGERS,
|
|
+ r -> {
|
|
+ this.serverLevel().getChunkSource().move(this);
|
|
+ if (this.wantsToStopRiding()) {
|
|
+ this.setCamera(this);
|
|
+ }
|
|
+ }
|
|
+ );
|
|
+ }
|
|
+ //Luminol end
|
|
+ } else {
|
|
+ this.setCamera(this);
|
|
+ }
|
|
+ }
|
|
}
|
|
|
|
public void doTick() {
|