2016-05-17 02:07:12 +00:00
|
|
|
From 665309dc76ad50bb5c79f50fcbf48cdcf5bc92f4 Mon Sep 17 00:00:00 2001
|
2016-04-16 02:35:03 +00:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Fri, 15 Apr 2016 21:27:14 -0400
|
|
|
|
Subject: [PATCH] Allow capping number of attempts at spawning mobs
|
|
|
|
|
|
|
|
By default, this logic would loop endlessly trying to fill the world
|
|
|
|
with entities until it hits the worlds spawn.
|
|
|
|
|
|
|
|
This patch will cap the # of attempts to so that the tick does not spend
|
|
|
|
extra long time on mob spawning
|
|
|
|
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
2016-05-17 02:07:12 +00:00
|
|
|
index 6a235d1..d470e75 100644
|
2016-04-16 02:35:03 +00:00
|
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
2016-05-17 02:07:12 +00:00
|
|
|
@@ -320,4 +320,18 @@ public class PaperWorldConfig {
|
2016-04-16 02:35:03 +00:00
|
|
|
private void useVanillaScoreboardColoring() {
|
|
|
|
useVanillaScoreboardColoring = getBoolean("use-vanilla-world-scoreboard-name-coloring", false);
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ public int maxMobSpawnAttempts;
|
|
|
|
+ private void maxMobSpawnAttempts() {
|
2016-05-17 02:07:12 +00:00
|
|
|
+ maxMobSpawnAttempts = getInt("max-mob-spawn-attempts", 250);
|
2016-04-16 02:35:03 +00:00
|
|
|
+ log( "Max Mob Spawn Attempts: " + maxMobSpawnAttempts);
|
2016-05-17 02:07:12 +00:00
|
|
|
+ if (maxMobSpawnAttempts < 0) {
|
|
|
|
+ maxMobSpawnAttempts = Integer.MAX_VALUE;
|
|
|
|
+ } else {
|
|
|
|
+ if (maxMobSpawnAttempts < 250 && PaperConfig.version < 10) {
|
|
|
|
+ set("max-mob-spawn-attempts", 250);
|
|
|
|
+ maxMobSpawnAttempts = 250;
|
|
|
|
+ }
|
|
|
|
+ }
|
2016-04-16 02:35:03 +00:00
|
|
|
+ }
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/SpawnerCreature.java b/src/main/java/net/minecraft/server/SpawnerCreature.java
|
2016-05-12 02:07:46 +00:00
|
|
|
index a034db2..113a372 100644
|
2016-04-16 02:35:03 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/SpawnerCreature.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/SpawnerCreature.java
|
|
|
|
@@ -140,8 +140,9 @@ public final class SpawnerCreature {
|
|
|
|
Iterator iterator1 = this.b.iterator();
|
|
|
|
|
|
|
|
int moblimit = (limit * i / 256) - mobcnt + 1; // Spigot - up to 1 more than limit
|
|
|
|
+ int maxMobSpawnAttempts = worldserver.paperConfig.maxMobSpawnAttempts; // Paper - max attempts
|
|
|
|
label120:
|
|
|
|
- while (iterator1.hasNext() && (moblimit > 0)) { // Spigot - while more allowed
|
|
|
|
+ while (iterator1.hasNext() && (moblimit > 0) && maxMobSpawnAttempts-- > 0) { // Spigot - while more allowed // Paper - max attempts
|
|
|
|
// CraftBukkit start = use LongHash and LongObjectHashMap
|
|
|
|
long key = ((Long) iterator1.next()).longValue();
|
|
|
|
BlockPosition blockposition1 = getRandomPosition(worldserver, LongHash.msw(key), LongHash.lsw(key));
|
|
|
|
--
|
2016-05-12 02:07:46 +00:00
|
|
|
2.8.2
|
2016-04-16 02:35:03 +00:00
|
|
|
|