Improve cancelling PreCreatureSpawnEvent with per player mob spawns (#9400)

This commit is contained in:
Jake Potrebic 2023-08-21 00:44:47 -07:00 committed by GitHub
parent 5bf82aa136
commit 1b96c64620
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 131 additions and 17 deletions

View file

@ -386,7 +386,7 @@ index 5ea537b98fc038798ada3d60570aaf908571d6b9..9e4e2a23891031589a03a5e8dc3e6709
// Yes, this doesn't match Vanilla, but it's the best we can do for now.
diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
index f22e1d76586980edb2dc962b4d55ad7a542b61a7..a3461824fd2162d509facf6f64c5008e3f0fd42b 100644
index 23d53f3fd524cc4d827dc95ab95367702a110a05..e57bb23ec14263b7c9dd721fefbe912963b863d0 100644
--- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java
+++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
@@ -70,6 +70,12 @@ public final class NaturalSpawner {
@ -504,12 +504,12 @@ index f22e1d76586980edb2dc962b4d55ad7a542b61a7..a3461824fd2162d509facf6f64c5008e
while (k < 3) {
@@ -223,14 +270,14 @@ public final class NaturalSpawner {
// Paper start
Boolean doSpawning = isValidSpawnPostitionForType(world, group, structuremanager, chunkgenerator, biomesettingsmobs_c, blockposition_mutableblockposition, d2);
if (doSpawning == null) {
PreSpawnStatus doSpawning = isValidSpawnPostitionForType(world, group, structuremanager, chunkgenerator, biomesettingsmobs_c, blockposition_mutableblockposition, d2);
if (doSpawning == PreSpawnStatus.ABORT) {
- return;
+ return j; // Paper
}
if (doSpawning && checker.test(biomesettingsmobs_c.type, blockposition_mutableblockposition, chunk)) {
if (doSpawning == PreSpawnStatus.SUCCESS && checker.test(biomesettingsmobs_c.type, blockposition_mutableblockposition, chunk)) {
// Paper end
Mob entityinsentient = NaturalSpawner.getMobForSpawn(world, biomesettingsmobs_c.type);
@ -545,7 +545,7 @@ index f22e1d76586980edb2dc962b4d55ad7a542b61a7..a3461824fd2162d509facf6f64c5008e
}
private static boolean isRightDistanceToPlayerAndSpawnPoint(ServerLevel world, ChunkAccess chunk, BlockPos.MutableBlockPos pos, double squaredDistance) {
@@ -558,7 +611,7 @@ public final class NaturalSpawner {
@@ -567,7 +620,7 @@ public final class NaturalSpawner {
MobCategory enumcreaturetype = entitytypes.getCategory();
this.mobCategoryCounts.addTo(enumcreaturetype, 1);
@ -554,7 +554,7 @@ index f22e1d76586980edb2dc962b4d55ad7a542b61a7..a3461824fd2162d509facf6f64c5008e
}
public int getSpawnableChunkCount() {
@@ -574,6 +627,7 @@ public final class NaturalSpawner {
@@ -583,6 +636,7 @@ public final class NaturalSpawner {
int i = limit * this.spawnableChunkCount / NaturalSpawner.MAGIC_NUMBER;
// CraftBukkit end