geforkt von Mirrors/Paper
aa52bf9e33
Mojang made some changes to priorities in 1.17 and it seems that these changes conflict with the changes made in this patch, which in some cases appears to cause excessive rescheduling of tasks. This, however, is not confirmed as such but seems to be the behavior that we're seeing to cause this issue, if mojang has adopted the changes we suggested, then a good chunk of this patch may be unneeded, but, this needs a much better look than I'm currently able to do
30 Zeilen
1.5 KiB
Diff
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 591a66dcdb717ad041120ab27de8f2f3a1975358..0a76032b48af4327580b99730e534f628924fe35 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
|