Skip to content

Commit 3aba006

Browse files
committed
Use getLocalPlayers for PhantomSpawner
Using the entire world player list will almost certainly result in tripping thread checks.
1 parent 6c77040 commit 3aba006

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

folia-server/minecraft-patches/features/0001-Region-Threading-Base.patch

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19005,7 +19005,7 @@ index c2e37714bae008087b0b5086e51d675beb672ca4..4b8b71f07096b27f3508b637eedcf2be
1900519005

1900619006
if (days >= level.paperConfig().entities.behavior.pillagerPatrols.start.day && level.isBrightOutside()) {
1900719007
diff --git a/net/minecraft/world/level/levelgen/PhantomSpawner.java b/net/minecraft/world/level/levelgen/PhantomSpawner.java
19008-
index d2e674b046bcf82a239b4706c3b89197ec6749c8..a7f56126a26e1fca86c39d8d656b648f5d6bb4ca 100644
19008+
index d2e674b046bcf82a239b4706c3b89197ec6749c8..0cafe46e9a1b053c5e70f20a26b4402632d0f8bf 100644
1900919009
--- a/net/minecraft/world/level/levelgen/PhantomSpawner.java
1901019010
+++ b/net/minecraft/world/level/levelgen/PhantomSpawner.java
1901119011
@@ -19,7 +19,7 @@ import net.minecraft.world.level.block.state.BlockState;
@@ -19017,7 +19017,7 @@ index d2e674b046bcf82a239b4706c3b89197ec6749c8..a7f56126a26e1fca86c39d8d656b648f
1901719017

1901819018
@Override
1901919019
public void tick(ServerLevel level, boolean spawnEnemies, boolean spawnFriendlies) {
19020-
@@ -31,12 +31,13 @@ public class PhantomSpawner implements CustomSpawner {
19020+
@@ -31,15 +31,16 @@ public class PhantomSpawner implements CustomSpawner {
1902119021
}
1902219022
// Paper end - Ability to control player's insomnia and phantoms
1902319023
RandomSource randomSource = level.random;
@@ -19033,7 +19033,11 @@ index d2e674b046bcf82a239b4706c3b89197ec6749c8..a7f56126a26e1fca86c39d8d656b648f
1903319033
+ worldData.phantomSpawnerNextTick += (spawnAttemptMinSeconds + randomSource.nextInt(spawnAttemptMaxSeconds - spawnAttemptMinSeconds + 1)) * 20; // Folia - region threading
1903419034
// Paper end - Ability to control player's insomnia and phantoms
1903519035
if (level.getSkyDarken() >= 5 || !level.dimensionType().hasSkyLight()) {
19036-
for (ServerPlayer serverPlayer : level.players()) {
19036+
- for (ServerPlayer serverPlayer : level.players()) {
19037+
+ for (ServerPlayer serverPlayer : level.getLocalPlayers()) { // Folia - region threading
19038+
if (!serverPlayer.isSpectator() && (!level.paperConfig().entities.behavior.phantomsDoNotSpawnOnCreativePlayers || !serverPlayer.isCreative())) { // Paper - Add phantom creative and insomniac controls
19039+
BlockPos blockPos = serverPlayer.blockPosition();
19040+
if (!level.dimensionType().hasSkyLight() || blockPos.getY() >= level.getSeaLevel() && level.canSeeSky(blockPos)) {
1903719041
diff --git a/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.java b/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.java
1903819042
index dfe8b815987a0ee385846616e4845428a81f2782..49b810ae9d9a8d0718a5f8c512e15a5573ed04fd 100644
1903919043
--- a/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.java

0 commit comments

Comments
 (0)