Skip to content

Commit 6c77040

Browse files
committed
Use getRandomLocalPlayer for CatSpawner
Retrieving a random global player is a sure way to trip a thread check.
1 parent da0d7cd commit 6c77040

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15830,10 +15830,10 @@ index 1d3381f1481bb2b192bb78462c85c2a185d94ad5..2496dafa51b48512e88bc8bbe5c96f42
1583015830
}
1583115831

1583215832
diff --git a/net/minecraft/world/entity/npc/CatSpawner.java b/net/minecraft/world/entity/npc/CatSpawner.java
15833-
index e282b6ab6d0d1c11ee40f5f436bd50fa90ddc88b..f5d27988605d48cdf314f28ba332f33f0a314266 100644
15833+
index e282b6ab6d0d1c11ee40f5f436bd50fa90ddc88b..a92769d2c0a93afa85797c0e778f460cc6d28599 100644
1583415834
--- a/net/minecraft/world/entity/npc/CatSpawner.java
1583515835
+++ b/net/minecraft/world/entity/npc/CatSpawner.java
15836-
@@ -18,14 +18,15 @@ import net.minecraft.world.phys.AABB;
15836+
@@ -18,15 +18,16 @@ import net.minecraft.world.phys.AABB;
1583715837

1583815838
public class CatSpawner implements CustomSpawner {
1583915839
private static final int TICK_DELAY = 1200;
@@ -15846,13 +15846,15 @@ index e282b6ab6d0d1c11ee40f5f436bd50fa90ddc88b..f5d27988605d48cdf314f28ba332f33f
1584615846
- this.nextTick--;
1584715847
- if (this.nextTick <= 0) {
1584815848
- this.nextTick = 1200;
15849+
- Player randomPlayer = level.getRandomPlayer();
1584915850
+ io.papermc.paper.threadedregions.RegionizedWorldData worldData = level.getCurrentWorldData(); // Folia - region threading
1585015851
+ worldData.catSpawnerNextTick--; // Folia - region threading
1585115852
+ if (worldData.catSpawnerNextTick <= 0) { // Folia - region threading
1585215853
+ worldData.catSpawnerNextTick = 1200; // Folia - region threading
15853-
Player randomPlayer = level.getRandomPlayer();
15854+
+ Player randomPlayer = level.getRandomLocalPlayer(); // Folia - region threading
1585415855
if (randomPlayer != null) {
1585515856
RandomSource randomSource = level.random;
15857+
int i = (8 + randomSource.nextInt(24)) * (randomSource.nextBoolean() ? -1 : 1);
1585615858
diff --git a/net/minecraft/world/entity/npc/Villager.java b/net/minecraft/world/entity/npc/Villager.java
1585715859
index e0e0d2ea7fc60e3142c675404d152eca60263240..aac65526817b1767511c7e180a4d9ded89ef89a1 100644
1585815860
--- a/net/minecraft/world/entity/npc/Villager.java

0 commit comments

Comments
 (0)