Fix infinite recursion in spawnCategoryForChunk/Position

This commit is contained in:
Nassim Jahnke 2022-02-02 21:57:11 +01:00
parent 2ec04e0938
commit f23c03955b
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
2 changed files with 7 additions and 7 deletions

View File

@ -269,7 +269,7 @@ index 0000000000000000000000000000000000000000..11de56afaf059b00fa5bec293516bcdc
+ }
+}
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 75381712377c1b77289a6b5877a657af8eb39a41..056e35b00bd840d8c62c4dc978cbbe5bb8c37887 100644
index d2755c00a28fa584d506259f33f8da44c2cf4842..6a8d929721f61b5235614496f60473b89a227ee5 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -151,6 +151,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@ -370,7 +370,7 @@ index f0dac1f596911eb2109192ef16a619f8ae71d1f7..07b616d9d7cde77c001f5c627daef073
this.naturalSpawnChunkCounter.runAllUpdates();
return this.naturalSpawnChunkCounter.chunks.size();
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index 7b391d6ab84eeaed7bdd27ea70d5e3f9690a0abf..0d380bba07c5c7b6b25fa2ce554418ef8ba9fdb1 100644
index cb57ac51f4acb35710f58ffce2fcc76cc88dd79b..06ddca6290b89ed96b8f9075f5c8b0b5244b9c3f 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -916,7 +916,18 @@ public class ServerChunkCache extends ChunkSource {
@ -418,7 +418,7 @@ index b193f8dfbe7b61c919ad5eb452d29885982e25e4..01b9edc8aaf472650f171f1b88229807
// 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 6f63f471c2c9a3b85c6fc92bdee31a5ff9714ff5..c0fb5d445ed18fbf52df2be754eab0d8fb6e9239 100644
index 6f63f471c2c9a3b85c6fc92bdee31a5ff9714ff5..a9d9c54c7bae0ad681a67106689897a31de49288 100644
--- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java
+++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
@@ -65,7 +65,13 @@ public final class NaturalSpawner {
@ -499,7 +499,7 @@ index 6f63f471c2c9a3b85c6fc92bdee31a5ff9714ff5..c0fb5d445ed18fbf52df2be754eab0d8
+ // Paper start - add parameters and int ret type
public static void spawnCategoryForChunk(MobCategory group, ServerLevel world, LevelChunk chunk, NaturalSpawner.SpawnPredicate checker, NaturalSpawner.AfterSpawnCallback runner) {
+ spawnCategoryForChunk(group, world, chunk, checker, runner);
+ spawnCategoryForChunk(group, world, chunk, checker, runner, Integer.MAX_VALUE, null);
+ }
+ public static int spawnCategoryForChunk(MobCategory group, ServerLevel world, LevelChunk chunk, NaturalSpawner.SpawnPredicate checker, NaturalSpawner.AfterSpawnCallback runner, int maxSpawns, Consumer<Entity> trackEntity) {
+ // Paper end - add parameters and int ret type
@ -519,7 +519,7 @@ index 6f63f471c2c9a3b85c6fc92bdee31a5ff9714ff5..c0fb5d445ed18fbf52df2be754eab0d8
+ // Paper start - add maxSpawns parameter and return spawned mobs
public static void spawnCategoryForPosition(MobCategory group, ServerLevel world, ChunkAccess chunk, BlockPos pos, NaturalSpawner.SpawnPredicate checker, NaturalSpawner.AfterSpawnCallback runner) {
+ spawnCategoryForPosition(group, world,chunk, pos, checker, runner);
+ spawnCategoryForPosition(group, world,chunk, pos, checker, runner, Integer.MAX_VALUE, null);
+ }
+ public static int spawnCategoryForPosition(MobCategory group, ServerLevel world, ChunkAccess chunk, BlockPos pos, NaturalSpawner.SpawnPredicate checker, NaturalSpawner.AfterSpawnCallback runner, int maxSpawns, Consumer<Entity> trackEntity) {
+ // Paper end - add maxSpawns parameter and return spawned mobs

View File

@ -272,7 +272,7 @@ index f436ab35798c9b6e6cb2eb60d2c02cbf9b742e69..4d7575087947f3b199dd895cd9aa02a7
List<org.bukkit.World> worlds;
if (args.length < 2 || args[1].equals("*")) {
diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
index c0fb5d445ed18fbf52df2be754eab0d8fb6e9239..abb57345a97f36d05eab9bc96ffd6396926c219f 100644
index a9d9c54c7bae0ad681a67106689897a31de49288..f0e67e007057c460f4f217fdaa60d3198d18684e 100644
--- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java
+++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
@@ -148,32 +148,16 @@ public final class NaturalSpawner {
@ -345,7 +345,7 @@ index c0fb5d445ed18fbf52df2be754eab0d8fb6e9239..abb57345a97f36d05eab9bc96ffd6396
+
// Paper start - add parameters and int ret type
public static void spawnCategoryForChunk(MobCategory group, ServerLevel world, LevelChunk chunk, NaturalSpawner.SpawnPredicate checker, NaturalSpawner.AfterSpawnCallback runner) {
spawnCategoryForChunk(group, world, chunk, checker, runner);
spawnCategoryForChunk(group, world, chunk, checker, runner, Integer.MAX_VALUE, null);
diff --git a/src/test/java/io/papermc/paper/PaperCommandTest.java b/src/test/java/io/papermc/paper/PaperCommandTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..4b5b368ef17bdb90f50e6ccc1f814cf93c7c0590