Skip to content

Commit c855ebf

Browse files
rootroot
authored andcommitted
Preserve rotation on teleport command
1 parent 7a1c5c7 commit c855ebf

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

folia-server/minecraft-patches/features/0001-Region-Threading-Base.patch

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3732,7 +3732,7 @@ index 0000000000000000000000000000000000000000..820b1c4dc1b19ee8602333295f203436
37323732
\ No newline at end of file
37333733
diff --git a/io/papermc/paper/threadedregions/TeleportUtils.java b/io/papermc/paper/threadedregions/TeleportUtils.java
37343734
new file mode 100644
3735-
index 0000000000000000000000000000000000000000..2a64a5b2cf049661fe3f5a22ddfa39979624f5ec
3735+
index 0000000000000000000000000000000000000000..8f7c514693e0fe360b0a5a1ca93c1a9f161c8826
37363736
--- /dev/null
37373737
+++ b/io/papermc/paper/threadedregions/TeleportUtils.java
37383738
@@ -0,0 +1,82 @@
@@ -3779,7 +3779,7 @@ index 0000000000000000000000000000000000000000..2a64a5b2cf049661fe3f5a22ddfa3997
37793779
+ return;
37803780
+ }
37813781
+ (useFromRootVehicle ? realFrom.getRootVehicle() : realFrom).teleportAsync(
3782-
+ ((CraftWorld)loc.getWorld()).getHandle(), pos, null, null, null,
3782+
+ ((CraftWorld)loc.getWorld()).getHandle(), pos, yaw, pitch, null,
37833783
+ cause, teleportFlags, onComplete
37843784
+ );
37853785
+ },
@@ -10019,7 +10019,7 @@ index 3d3d766b376891bdfb2d47a26284f805d0b01b92..2289f7383d85de023e062fe5c5ae37e9
1001910019
} else {
1002010020
return entity;
1002110021
diff --git a/net/minecraft/server/commands/TeleportCommand.java b/net/minecraft/server/commands/TeleportCommand.java
10022-
index 6d8ac5f80d5267a2159a464ec331e9b3c65313e2..178a67b24095af02e7f75e8d80abdfc7b462639a 100644
10022+
index 6d8ac5f80d5267a2159a464ec331e9b3c65313e2..6fa4b9920fc470c9d4b9d22f103a543fae6ae13b 100644
1002310023
--- a/net/minecraft/server/commands/TeleportCommand.java
1002410024
+++ b/net/minecraft/server/commands/TeleportCommand.java
1002510025
@@ -154,18 +154,7 @@ public class TeleportCommand {
@@ -10042,16 +10042,16 @@ index 6d8ac5f80d5267a2159a464ec331e9b3c65313e2..178a67b24095af02e7f75e8d80abdfc7
1004210042
}
1004310043

1004410044
if (targets.size() == 1) {
10045-
@@ -290,6 +279,24 @@ public class TeleportCommand {
10046-
float f1 = relatives.contains(Relative.X_ROT) ? xRot - target.getXRot() : xRot;
10047-
float f2 = Mth.wrapDegrees(f);
10048-
float f3 = Mth.wrapDegrees(f1);
10045+
@@ -283,6 +272,24 @@ public class TeleportCommand {
10046+
if (!Level.isInSpawnableBounds(blockPos)) {
10047+
throw INVALID_POSITION.create();
10048+
} else {
1004910049
+ // Folia start - region threading
1005010050
+ if (true) {
1005110051
+ ServerLevel worldFinal = level;
1005210052
+ Vec3 posFinal = new Vec3(x, y, z);
10053-
+ Float yawFinal = Float.valueOf(f);
10054-
+ Float pitchFinal = Float.valueOf(f1);
10053+
+ Float yawFinal = Float.valueOf(yRot);
10054+
+ Float pitchFinal = Float.valueOf(xRot);
1005510055
+ target.getBukkitEntity().taskScheduler.schedule((Entity nmsEntity) -> {
1005610056
+ nmsEntity.unRide();
1005710057
+ nmsEntity.teleportAsync(
@@ -10064,9 +10064,9 @@ index 6d8ac5f80d5267a2159a464ec331e9b3c65313e2..178a67b24095af02e7f75e8d80abdfc7
1006410064
+ return;
1006510065
+ }
1006610066
+ // Folia end - region threading
10067-
// CraftBukkit start - Teleport event
10068-
boolean result;
10069-
if (target instanceof final net.minecraft.server.level.ServerPlayer player) {
10067+
double d = relatives.contains(Relative.X) ? x - target.getX() : x;
10068+
double d1 = relatives.contains(Relative.Y) ? y - target.getY() : y;
10069+
double d2 = relatives.contains(Relative.Z) ? z - target.getZ() : z;
1007010070
diff --git a/net/minecraft/server/commands/TimeCommand.java b/net/minecraft/server/commands/TimeCommand.java
1007110071
index ba4dffb47b01e83748f7c4cd396f6d959b658d51..b11b1ad2b67340c2d07bf01531b8d459526f572b 100644
1007210072
--- a/net/minecraft/server/commands/TimeCommand.java

0 commit comments

Comments
 (0)