From 04324c58b29f3eee8f8f12dbc2da129e715d4f42 Mon Sep 17 00:00:00 2001 From: Omer Uddin Date: Thu, 28 Jan 2021 20:32:58 -0500 Subject: [PATCH] Disable enderpearls when they hit non-ticking chunk if disableEnderpearlExploit is enabled --- ...0197-Block-Enderpearl-Travel-Exploit.patch | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/patches/server/0197-Block-Enderpearl-Travel-Exploit.patch b/patches/server/0197-Block-Enderpearl-Travel-Exploit.patch index 517fbba40b..afec4cdfb5 100644 --- a/patches/server/0197-Block-Enderpearl-Travel-Exploit.patch +++ b/patches/server/0197-Block-Enderpearl-Travel-Exploit.patch @@ -38,3 +38,31 @@ index e4294219be68c6f99cd0e5ea8330fae6dc03ddde..b09f52330b50879d5594b21302e70ca6 } 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 +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