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.
2024-10-22 23:30:51 +02:00
Note: Currently removed as enderpearls are ticked as long as their owner is online in 1.21.2.
Might be worth to re-add once an option to disable the above vanilla mechanic is added, to
fully prevent enderpearl travel exploits.
2022-11-20 00:53:20 +01:00
== AT ==
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
2024-12-04 11:11:12 +01:00
index 3817703e5b759a27bb6c722f56b41ef321b9c432..5c9d15dbc55aec3ec99143a255e42b5e28a9e95e 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
2024-12-04 11:11:12 +01:00
@@ -2682,6 +2682,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
2023-09-22 00:01:00 +02:00
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
2024-10-30 18:09:05 +01:00
+ if (ServerLevel.this.paperConfig().fixes.disableUnloadedChunkEnderpearlExploit && ServerLevel.this.paperConfig().misc.legacyEnderPearlBehavior && entity instanceof net.minecraft.world.entity.projectile.ThrownEnderpearl pearl) {
2022-04-08 02:52:25 +02:00
+ pearl.cachedOwner = null;
+ pearl.ownerUUID = null;
+ }
2024-01-22 18:04:55 +01:00
+ // Paper end - Reset pearls when they stop being ticked
2022-04-08 02:52:25 +02:00
}
2023-09-22 00:01:00 +02:00
2022-04-08 02:52:25 +02:00
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
2024-12-03 21:24:17 +01:00
index 4c71642474d97d1943db302947a4566a326b9ac3..9a7b56b653848974e1194eb4f6d40cb99a96ff57 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
2024-10-30 18:09:05 +01:00
@@ -134,6 +134,7 @@ public abstract class Projectile extends Entity implements TraceableEntity {
2024-10-22 23:30:51 +02:00
protected void readAdditionalSaveData(CompoundTag nbt) {
2021-06-12 21:30:37 +02:00
if (nbt.hasUUID("Owner")) {
2024-10-22 23:30:51 +02:00
this.setOwnerThroughUUID(nbt.getUUID("Owner"));
2024-10-30 18:09:05 +01:00
+ if (this instanceof ThrownEnderpearl && this.level() != null && this.level().paperConfig().fixes.disableUnloadedChunkEnderpearlExploit && this.level().paperConfig().misc.legacyEnderPearlBehavior) { this.ownerUUID = null; } // Paper - Reset pearls when they stop being ticked; Don't store shooter name for pearls to block enderpearl travel exploit
2021-06-11 14:02:28 +02:00
}
2023-09-22 00:01:00 +02:00
2021-06-12 21:30:37 +02:00
this.leftOwner = nbt.getBoolean("LeftOwner");