aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/removed/1.18/No longer needed/0410-Restrict-vanilla-teleport-command-to-valid-locations.patch
blob: b0ce748234260e0293f77d0dc7a71012c400e2aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Zach Brown <zach@zachbr.io>
Date: Thu, 16 Apr 2020 20:07:29 -0500
Subject: [PATCH] Restrict vanilla teleport command to valid locations

Fixes GH-3165, GH-3575

diff --git a/src/main/java/net/minecraft/server/commands/TeleportCommand.java b/src/main/java/net/minecraft/server/commands/TeleportCommand.java
index 85ae18b7f8a26f83ea0cf1ae17cfa88b796fcc77..d0109df7fad51fc0444459f5d367254c8f4c355e 100644
--- a/src/main/java/net/minecraft/server/commands/TeleportCommand.java
+++ b/src/main/java/net/minecraft/server/commands/TeleportCommand.java
@@ -148,6 +148,12 @@ public class TeleportCommand {
 
     private static void performTeleport(CommandSourceStack source, Entity target, ServerLevel world, double x, double y, double z, Set<ClientboundPlayerPositionPacket.RelativeArgument> movementFlags, float yaw, float pitch, @Nullable TeleportCommand.LookAt facingLocation) throws CommandSyntaxException {
         BlockPos blockposition = new BlockPos(x, y, z);
+        // Paper start - Don't allow teleport command to invalid locations
+        if (x <= -30000000 || z <= -30000000 || x > 30000000 || z > 30000000 || y > 30000000 || y <= -30000000) { // Copy/pasta from BaseBlockPosition#isValidLocation
+            org.bukkit.Bukkit.getLogger().warning("Refused to teleport " + target.getScoreboardName() + " to " + x + ", " + y + ", " + z);
+            return;
+        }
+        // Paper end
 
         if (!Level.isInSpawnableBounds(blockposition)) {
             throw TeleportCommand.INVALID_POSITION.create();