Do not break when PlayerNaturallySpawnCreaturesEvent is cancelled

If there is a player nearby which had its event not cancelled,
then that should take precedence.
This commit is contained in:
Spottedleaf 2024-12-01 13:53:04 -08:00
parent 0f90942b1a
commit 4bc80b8a44

View File

@ -9,7 +9,7 @@ from triggering monster spawns on a server.
Also a highly more effecient way to blanket block spawns in a world Also a highly more effecient way to blanket block spawns in a world
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 261943f1f188643793a72bd239dfc5fe604e3b99..ebe6c631d772cf41038701aafbe4e0bbb024f7f5 100644 index 261943f1f188643793a72bd239dfc5fe604e3b99..e211cd62b9381df353c0921bfaa6ad63f251a6ac 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java --- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1094,11 +1094,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1094,11 +1094,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@ -34,7 +34,7 @@ index 261943f1f188643793a72bd239dfc5fe604e3b99..ebe6c631d772cf41038701aafbe4e0bb
+ blockRange = 16384.0D; + blockRange = 16384.0D;
+ if (reducedRange) { + if (reducedRange) {
+ event = entityplayer.playerNaturallySpawnedEvent; + event = entityplayer.playerNaturallySpawnedEvent;
+ if (event == null || event.isCancelled()) return false; + if (event == null || event.isCancelled()) continue;
+ blockRange = (double) ((event.getSpawnRadius() << 4) * (event.getSpawnRadius() << 4)); + blockRange = (double) ((event.getSpawnRadius() << 4) * (event.getSpawnRadius() << 4));
+ } + }
+ // Paper end - PlayerNaturallySpawnCreaturesEvent + // Paper end - PlayerNaturallySpawnCreaturesEvent