Paper/patches/server/0719-Improve-CraftChunk-getEntities.patch
kennytv 0aa0a1d973 Updated Upstream (CraftBukkit)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

CraftBukkit Changes:
b5d7883a SPIGOT-6634: Override needed method
99561c21 SPIGOT-6624: Explosions do not destroy blocks out of vanilla heights in custom dimensions
2021-07-09 16:20:40 +02:00

30 Zeilen
1.5 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Fri, 25 Jun 2021 12:06:35 -0700
Subject: [PATCH] Improve CraftChunk#getEntities
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
index 08a5fabb1d13db26014bb5751aa271c0a0bdcb7a..40d6dfe30e8f388fb2014ba81f9ea4a986354b88 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
@@ -110,11 +110,13 @@ public class CraftChunk implements Chunk {
this.getWorld().getChunkAt(x, z); // Transient load for this tick
}
- Location location = new Location(null, 0, 0, 0);
- return this.getWorld().getEntities().stream().filter((entity) -> {
- entity.getLocation(location);
- return location.getBlockX() >> 4 == this.x && location.getBlockZ() >> 4 == this.z;
- }).toArray(Entity[]::new);
+ // Paper start - improve CraftChunk#getEntities
+ return this.worldServer.entityManager.sectionStorage.getExistingSectionsInChunk(ChunkPos.asLong(this.x, this.z))
+ .flatMap(net.minecraft.world.level.entity.EntitySection::getEntities)
+ .map(net.minecraft.world.entity.Entity::getBukkitEntity)
+ .filter(entity -> entity != null && entity.isValid())
+ .toArray(Entity[]::new);
+ // Paper end
}
@Override