aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0191-Block-Enderpearl-Travel-Exploit.patch
blob: e1163117f267a7d7d62deefc1cce561d87ef8b49 (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Mon, 30 Apr 2018 17:15:26 -0400
Subject: [PATCH] Block Enderpearl Travel Exploit

Players are able to use alt accounts and enderpearls to travel
long distances utilizing the pearls in unloaded chunks and loading
the chunk later when convenient.

This disables that by not saving the thrower when the chunk is unloaded.

This is mainly useful for survival servers that do not allow freeform teleporting.

== AT ==
public net.minecraft.world.entity.projectile.Projectile cachedOwner
public net.minecraft.world.entity.projectile.Projectile ownerUUID

diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index f2016ed77a2239bdc597175c24ce4427a808d1a6..7be0547f6225a6be6ca1037f63f4aff8759b5dc4 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -2149,6 +2149,12 @@ public class ServerLevel extends Level implements WorldGenLevel {
 
         public void onTickingEnd(Entity entity) {
             ServerLevel.this.entityTickList.remove(entity);
+            // Paper start - Reset pearls when they stop being ticked
+            if (paperConfig().fixes.disableUnloadedChunkEnderpearlExploit && entity instanceof net.minecraft.world.entity.projectile.ThrownEnderpearl pearl) {
+                pearl.cachedOwner = null;
+                pearl.ownerUUID = null;
+            }
+            // Paper end - Reset pearls when they stop being ticked
         }
 
         public void onTrackingStart(Entity entity) {
diff --git a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
index 1e7224d070fc48d93ce0c4e832d94c6a50019249..5e9ef75a14a91f01a1ae5b3fb591d7258740a75d 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
@@ -102,6 +102,7 @@ public abstract class Projectile extends Entity implements TraceableEntity {
         if (nbt.hasUUID("Owner")) {
             this.ownerUUID = nbt.getUUID("Owner");
             this.cachedOwner = null;
+            if (this instanceof ThrownEnderpearl && this.level() != null && this.level().paperConfig().fixes.disableUnloadedChunkEnderpearlExploit) { this.ownerUUID = null; } // Paper - Reset pearls when they stop being ticked; Don't store shooter name for pearls to block enderpearl travel exploit
         }
 
         this.leftOwner = nbt.getBoolean("LeftOwner");