2021-06-11 14:02:28 +02:00
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.
2022-11-20 00:53:20 +01:00
== AT ==
public net.minecraft.world.entity.projectile.Projectile cachedOwner
public net.minecraft.world.entity.projectile.Projectile ownerUUID
2022-04-08 02:52:25 +02:00
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
2022-12-08 11:53:14 +01:00
index 349a9f4596cd1411ec3a69cd7d6f5414971b74ef..45485383943f1ae0d4c5b5064cbaa8f56181dad3 100644
2022-04-08 02:52:25 +02:00
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
2022-12-08 11:53:14 +01:00
@@ -2179,6 +2179,12 @@ public class ServerLevel extends Level implements WorldGenLevel {
2022-04-08 02:52:25 +02:00
public void onTickingEnd(Entity entity) {
ServerLevel.this.entityTickList.remove(entity);
+ // Paper start - Reset pearls when they stop being ticked
2022-06-09 10:51:45 +02:00
+ if (paperConfig().fixes.disableUnloadedChunkEnderpearlExploit && entity instanceof net.minecraft.world.entity.projectile.ThrownEnderpearl pearl) {
2022-04-08 02:52:25 +02:00
+ pearl.cachedOwner = null;
+ pearl.ownerUUID = null;
+ }
+ // Paper end
}
public void onTrackingStart(Entity entity) {
2021-06-11 14:02:28 +02:00
diff --git a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
2023-02-13 18:52:27 +01:00
index e19251bc9cb18ea3c37628b55ae73bb2e5ba69bd..95ee8f85dd7e6c32f751f5c754a351cc7bcd6245 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
2022-12-07 19:52:24 +01:00
@@ -89,6 +89,7 @@ public abstract class Projectile extends Entity {
2021-06-12 21:30:37 +02:00
protected void readAdditionalSaveData(CompoundTag nbt) {
if (nbt.hasUUID("Owner")) {
this.ownerUUID = nbt.getUUID("Owner");
2022-06-09 10:51:45 +02:00
+ if (this instanceof ThrownEnderpearl && this.level != null && this.level.paperConfig().fixes.disableUnloadedChunkEnderpearlExploit) { this.ownerUUID = null; } // Paper - Don't store shooter name for pearls to block enderpearl travel exploit
2021-06-11 14:02:28 +02:00
}
2021-06-12 21:30:37 +02:00
this.leftOwner = nbt.getBoolean("LeftOwner");