80 Zeilen
4.4 KiB
Diff
80 Zeilen
4.4 KiB
Diff
From a6f63db4333363a12ea2905bc4a2093abde6839d Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Tue, 29 Jan 2013 13:25:53 -0500
|
|
Subject: [PATCH] Only count entities in chunks being processed for the spawn
|
|
wave. Fixes mob spawn issues.
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/SpawnerCreature.java b/src/main/java/net/minecraft/server/SpawnerCreature.java
|
|
index b3e2818..21fbf7d 100644
|
|
--- a/src/main/java/net/minecraft/server/SpawnerCreature.java
|
|
+++ b/src/main/java/net/minecraft/server/SpawnerCreature.java
|
|
@@ -16,6 +16,7 @@ public final class SpawnerCreature {
|
|
|
|
private static LongObjectHashMap<Boolean> b = new LongObjectHashMap<Boolean>(); // CraftBukkit - HashMap -> LongObjectHashMap
|
|
protected static final Class[] a = new Class[] { EntitySpider.class, EntityZombie.class, EntitySkeleton.class};
|
|
+ private static byte spawnRadius = 0; // Spigot
|
|
|
|
protected static ChunkPosition getRandomPosition(World world, int i, int j) {
|
|
Chunk chunk = world.getChunkAt(i, j);
|
|
@@ -34,13 +35,24 @@ public final class SpawnerCreature {
|
|
|
|
int i;
|
|
int j;
|
|
+ // Spigot start - limit radius to spawn distance (chunks aren't loaded)
|
|
+ if (spawnRadius == 0) {
|
|
+ spawnRadius = (byte) worldserver.getWorld().mobSpawnRange;
|
|
+ if (spawnRadius > (byte) worldserver.getServer().getViewDistance()) {
|
|
+ spawnRadius = (byte) worldserver.getServer().getViewDistance();
|
|
+ }
|
|
+ if (spawnRadius > 8) {
|
|
+ spawnRadius = 8;
|
|
+ }
|
|
+ }
|
|
+ // Spigot end
|
|
|
|
for (i = 0; i < worldserver.players.size(); ++i) {
|
|
EntityHuman entityhuman = (EntityHuman) worldserver.players.get(i);
|
|
int k = MathHelper.floor(entityhuman.locX / 16.0D);
|
|
|
|
j = MathHelper.floor(entityhuman.locZ / 16.0D);
|
|
- byte b0 = 8;
|
|
+ byte b0 = spawnRadius; // Spigot - replace 8 with view distance constrained value
|
|
|
|
for (int l = -b0; l <= b0; ++l) {
|
|
for (int i1 = -b0; i1 <= b0; ++i1) {
|
|
@@ -88,13 +100,15 @@ public final class SpawnerCreature {
|
|
if (limit == 0) {
|
|
continue;
|
|
}
|
|
+ int mobcnt = 0;
|
|
// CraftBukkit end
|
|
|
|
- if ((!enumcreaturetype.d() || flag1) && (enumcreaturetype.d() || flag) && (!enumcreaturetype.e() || flag2) && worldserver.a(enumcreaturetype.a()) <= limit * b.size() / 256) { // CraftBukkit - use per-world limits
|
|
+ if ((!enumcreaturetype.d() || flag1) && (enumcreaturetype.d() || flag) && (!enumcreaturetype.e() || flag2) && (mobcnt = worldserver.a(enumcreaturetype.a())) <= limit * b.size() / 256) { // CraftBukkit - use per-world limits and use all loaded chunks
|
|
Iterator iterator = b.keySet().iterator();
|
|
|
|
+ int moblimit = (limit * b.size() / 256) - mobcnt + 1; // CraftBukkit - up to 1 more than limit
|
|
label110:
|
|
- while (iterator.hasNext()) {
|
|
+ while (iterator.hasNext() && (moblimit > 0)) { // Spigot - while more allowed
|
|
// CraftBukkit start
|
|
long key = ((Long) iterator.next()).longValue();
|
|
|
|
@@ -158,6 +172,12 @@ public final class SpawnerCreature {
|
|
a(entityliving, worldserver, f, f1, f2);
|
|
worldserver.addEntity(entityliving, SpawnReason.NATURAL);
|
|
// CraftBukkit end
|
|
+ // Spigot start
|
|
+ moblimit--;
|
|
+ if (moblimit <= 0) { // If we're past limit, stop spawn
|
|
+ continue label110;
|
|
+ }
|
|
+ // Spigot end
|
|
if (j2 >= entityliving.by()) {
|
|
continue label110;
|
|
}
|
|
--
|
|
1.7.11.msysgit.0
|
|
|