Disable enderpearls when they hit non-ticking chunk if disableEnderpearlExploit is enabled

This commit is contained in:
Omer Uddin 2021-01-28 20:32:58 -05:00
parent cca58e20a0
commit 36a14149e6

View File

@ -38,3 +38,31 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java
@@ -0,0 +0,0 @@ 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;
@@ -0,0 +0,0 @@ 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