2021-06-11 12:02:28 +00: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
2021-09-01 09:54:41 +00:00
index f3ce248c576643ec172ba42c4bea41a59cfe9ec6..10f7437d62bfa774309d6334ca791505254bcaf7 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
2021-09-01 09:54:41 +00:00
@@ -362,4 +362,10 @@ public class PaperWorldConfig {
2021-06-11 12:02:28 +00: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
2021-07-18 07:41:53 +00:00
index e4294219be68c6f99cd0e5ea8330fae6dc03ddde..b09f52330b50879d5594b21302e70ca676b60951 100644
2021-06-11 12:02:28 +00: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 19:30:37 +00: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 12:02:28 +00: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 19:30:37 +00:00
this.leftOwner = nbt.getBoolean("LeftOwner");
2021-01-29 01:32:58 +00:00
diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java b/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java
index 541ca82405d0b4d1457dcd63b58dc61eb67482d6..002725b24f0eaee10a9a529c847dfb78538c6bd4 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java
@@ -12,6 +12,7 @@ import net.minecraft.world.entity.monster.Endermite;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
+import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.EntityHitResult;
@@ -108,6 +109,15 @@ public class ThrownEnderpearl extends ThrowableItemProjectile {
super.tick();
}
+ // Paper start
+ if (this.level.paperConfig.disableEnderpearlExploit) {
+ final net.minecraft.server.level.ChunkHolder chunkHolder = ((net.minecraft.server.level.ServerChunkCache) this.level.getChunkSource()).chunkMap.getVisibleChunkIfPresent(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.setOwner(null);
+ }
+ }
+ // Paper end
+
}
@Nullable