Paper/patches/server/0191-Block-Enderpearl-Travel-Exploit.patch

62 lines
3.5 KiB
Diff
Raw Normal View History

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.
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
2022-03-11 21:13:46 +01:00
index ef9f6712046a22a8d0dfcf95d8e2d12403345532..ea426792b751fd7591bf09f2256dd6bdd31fac06 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
2022-03-11 21:13:46 +01:00
@@ -393,4 +393,10 @@ public class PaperWorldConfig {
2021-06-11 14:02:28 +02:00
private void disableSprintInterruptionOnAttack() {
disableSprintInterruptionOnAttack = getBoolean("game-mechanics.disable-sprint-interruption-on-attack", false);
}
+
+ public boolean disableEnderpearlExploit = true;
+ private void disableEnderpearlExploit() {
+ disableEnderpearlExploit = getBoolean("game-mechanics.disable-unloaded-chunk-enderpearl-exploit", disableEnderpearlExploit);
+ log("Disable Unloaded Chunk Enderpearl Exploit: " + (disableEnderpearlExploit ? "enabled" : "disabled"));
+ }
}
diff --git a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
2022-03-11 21:13:46 +01:00
index 1c3ae7c61c06f486e50e57f434b9f360c6cf55be..bdefda914a7f93b8393a06f112ea9239d9685d51 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
2021-06-12 21:30:37 +02:00
@@ -88,6 +88,7 @@ public abstract class Projectile extends Entity {
protected void readAdditionalSaveData(CompoundTag nbt) {
if (nbt.hasUUID("Owner")) {
this.ownerUUID = nbt.getUUID("Owner");
2021-06-11 14:02:28 +02:00
+ if (this instanceof ThrownEnderpearl && this.level != null && this.level.paperConfig.disableEnderpearlExploit) { this.ownerUUID = null; } // Paper - Don't store shooter name for pearls to block enderpearl travel exploit
}
2021-06-12 21:30:37 +02:00
this.leftOwner = nbt.getBoolean("LeftOwner");
diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java b/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java
2021-11-23 16:04:41 +01:00
index 23f77dfc6df93ef6a70e14a7e410263d39fae2cb..834ba402decb556a5f77809b37fa00578b67432e 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java
2021-09-07 23:33:28 +02:00
@@ -108,6 +108,16 @@ public class ThrownEnderpearl extends ThrowableItemProjectile {
super.tick();
}
+ // Paper start
+ if (this.level.paperConfig.disableEnderpearlExploit) {
2021-09-07 23:33:28 +02:00
+ final net.minecraft.server.level.ChunkHolder chunkHolder = ((net.minecraft.server.level.ServerChunkCache) this.level.getChunkSource()).chunkMap.getVisibleChunkIfPresent(net.minecraft.world.level.ChunkPos.asLong(this.blockPosition()));
+ if (chunkHolder == null || !net.minecraft.server.level.ChunkHolder.getFullChunkStatus(chunkHolder.getTicketLevel()).isOrAfter(net.minecraft.server.level.ChunkHolder.FullChunkStatus.ENTITY_TICKING)) {
+ this.cachedOwner = null;
+ this.ownerUUID = null;
+ }
+ }
+ // Paper end
+
}
@Nullable