Merge the two spawn calculation fixes

This commit is contained in:
md_5 2013-06-21 17:35:08 +10:00
parent 20e0c70bd8
commit 8a883922a8
20 changed files with 82 additions and 126 deletions

View File

@ -1,14 +1,58 @@
From 944e72c8c821cfea28fb2d0f49262f209ab99bec Mon Sep 17 00:00:00 2001
From 9e053fee3c3d3b2af10a4eb74a3d11d1a06ccb14 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Fri, 21 Jun 2013 17:29:54 +1000
Subject: [PATCH] Fix Mob Spawning Relative to View Distance
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 7416edc..e8d30c5 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -33,6 +33,7 @@ public class Chunk {
public int p;
private int u;
boolean q;
+ protected gnu.trove.map.hash.TObjectIntHashMap<Class> entityCount = new gnu.trove.map.hash.TObjectIntHashMap<Class>(); // Spigot
public Chunk(World world, int i, int j) {
this.sections = new ChunkSection[16];
@@ -560,6 +561,15 @@ public class Chunk {
entity.ak = k;
entity.al = this.z;
this.entitySlices[k].add(entity);
+ // Spigot start - increment creature type count
+ for ( EnumCreatureType creatureType : EnumCreatureType.values() )
+ {
+ if ( creatureType.a().isAssignableFrom( entity.getClass() ) )
+ {
+ this.entityCount.adjustOrPutValue( creatureType.a(), 1, 1 );
+ }
+ }
+ // Spigot end
}
public void b(Entity entity) {
@@ -576,6 +586,15 @@ public class Chunk {
}
this.entitySlices[i].remove(entity);
+ // Spigot start - decrement creature type count
+ for ( EnumCreatureType creatureType : EnumCreatureType.values() )
+ {
+ if ( creatureType.a().isAssignableFrom( entity.getClass() ) )
+ {
+ this.entityCount.adjustValue( creatureType.a(), -1 );
+ }
+ }
+ // Spigot end
}
public boolean d(int i, int j, int k) {
diff --git a/src/main/java/net/minecraft/server/SpawnerCreature.java b/src/main/java/net/minecraft/server/SpawnerCreature.java
index 056100f..c17ad8b 100644
index 056100f..bec0d91 100644
--- a/src/main/java/net/minecraft/server/SpawnerCreature.java
+++ b/src/main/java/net/minecraft/server/SpawnerCreature.java
@@ -26,6 +26,32 @@ public final class SpawnerCreature {
@@ -26,6 +26,23 @@ public final class SpawnerCreature {
return new ChunkPosition(k, i1, l);
}
@ -20,18 +64,9 @@ index 056100f..c17ad8b 100644
+ {
+ int x = LongHash.msw( coord );
+ int z = LongHash.lsw( coord );
+ if ( !server.chunkProviderServer.unloadQueue.contains( x, z ) && server.isChunkLoaded( x, z ) )
+ if ( !server.chunkProviderServer.unloadQueue.contains( coord ) && server.isChunkLoaded( x, z ) )
+ {
+ for ( List<Entity> entitySlice : server.getChunkAt( x, z ).entitySlices )
+ {
+ for ( Entity entity : entitySlice )
+ {
+ if ( oClass.isAssignableFrom( entity.getClass() ) )
+ {
+ ++i;
+ }
+ }
+ }
+ i += server.getChunkAt( x, z ).entityCount.get( oClass );
+ }
+ }
+ return i;
@ -41,7 +76,7 @@ index 056100f..c17ad8b 100644
public static final int spawnEntities(WorldServer worldserver, boolean flag, boolean flag1, boolean flag2) {
if (!flag && !flag1) {
return 0;
@@ -41,6 +67,11 @@ public final class SpawnerCreature {
@@ -41,6 +58,11 @@ public final class SpawnerCreature {
j = MathHelper.floor(entityhuman.locZ / 16.0D);
byte b0 = 8;
@ -53,7 +88,7 @@ index 056100f..c17ad8b 100644
for (int l = -b0; l <= b0; ++l) {
for (int i1 = -b0; i1 <= b0; ++i1) {
@@ -88,13 +119,15 @@ public final class SpawnerCreature {
@@ -88,13 +110,15 @@ public final class SpawnerCreature {
if (limit == 0) {
continue;
}
@ -71,7 +106,7 @@ index 056100f..c17ad8b 100644
// CraftBukkit start
long key = ((Long) iterator.next()).longValue();
@@ -158,6 +191,13 @@ public final class SpawnerCreature {
@@ -158,6 +182,13 @@ public final class SpawnerCreature {
a(entityliving, worldserver, f, f1, f2);
worldserver.addEntity(entityliving, SpawnReason.NATURAL);
// CraftBukkit end

View File

@ -1,4 +1,4 @@
From 055bea092702d1912c8bd99415f3b1d91046672e Mon Sep 17 00:00:00 2001
From 59f6244d29ad8a3a8b383267a4fe1749d7b34db4 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 3 Feb 2013 05:10:21 -0500
Subject: [PATCH] Entity Activation Range
@ -462,12 +462,12 @@ index 0000000..93ce20e
+ }
+}
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
index 5e1cfa9..31f4c39 100644
index e807ec8..c567250 100644
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
@@ -142,4 +142,15 @@ public class SpigotWorldConfig
antiXrayInstance = new AntiXray( this );
@@ -149,4 +149,15 @@ public class SpigotWorldConfig
mobSpawnRange = getByte( "mob-spawn-range", 4 );
log( "Mob Spawn Range: " + mobSpawnRange );
}
+
+ public int animalActivationRange = 32;

View File

@ -1,4 +1,4 @@
From a8d2f288d11999d0de83c613c73e5455ea3156c7 Mon Sep 17 00:00:00 2001
From 21f77e26c9c80277b474d950860e63a27b0fd8f1 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Sat, 23 Feb 2013 12:33:20 +1100
Subject: [PATCH] Watchdog Thread.
@ -142,12 +142,12 @@ index 0000000..a5c4549
+ }
+}
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
index 8711c7a..6e8bae8 100644
index b5f3532..89b2927 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -114,4 +114,15 @@ public class SpigotConfig
{
preventProxies = getBoolean( "settings.prevent-proxies", preventProxies );
preventProxies = getBoolean( "settings.prevent-proxies", false );
}
+
+ public static int timeoutTime = 60;

View File

@ -1,4 +1,4 @@
From fd0be11a5ce06767e30b2d3f424712d24edc28f7 Mon Sep 17 00:00:00 2001
From 909c3ed4c89b1a12496686b431ba74c1deb28c9c Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 20 Feb 2013 11:58:47 -0500
Subject: [PATCH] Entity Tracking Ranges
@ -24,10 +24,10 @@ index d7efe3e..59586c2 100644
i = this.d;
}
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
index 31f4c39..8ae36fe 100644
index c567250..de052ad 100644
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
@@ -153,4 +153,19 @@ public class SpigotWorldConfig
@@ -160,4 +160,19 @@ public class SpigotWorldConfig
miscActivationRange = getInt( "entity-activation-range.misc", miscActivationRange );
log( "Entity Activation Range: An " + animalActivationRange + " / Mo " + monsterActivationRange + " / Mi " + miscActivationRange );
}

View File

@ -1,79 +0,0 @@
From 9f6ff0b5899268bf52d195f7316c97d0b43ec22b Mon Sep 17 00:00:00 2001
From: Ammar Askar <ammar@ammaraskar.com>
Date: Sat, 20 Apr 2013 12:26:20 +0500
Subject: [PATCH] Save entity counts for randomly spawned creatures to avoid
repeatedly traversing over the entity slices
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 7416edc..958b5af 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -9,6 +9,7 @@ import java.util.Map;
import java.util.Random;
import org.bukkit.Bukkit; // CraftBukkit
+import gnu.trove.map.hash.TObjectIntHashMap; // Spigot
public class Chunk {
@@ -33,6 +34,7 @@ public class Chunk {
public int p;
private int u;
boolean q;
+ protected TObjectIntHashMap<Class> entityCount = new TObjectIntHashMap<Class>(); // Spigot
public Chunk(World world, int i, int j) {
this.sections = new ChunkSection[16];
@@ -560,6 +562,13 @@ public class Chunk {
entity.ak = k;
entity.al = this.z;
this.entitySlices[k].add(entity);
+ // Spigot start - increment creature type count
+ for (EnumCreatureType creatureType : EnumCreatureType.values()) {
+ if (creatureType.a().isAssignableFrom(entity.getClass())) {
+ this.entityCount.adjustOrPutValue(creatureType.a(), 1, 1);
+ }
+ }
+ // Spigot end
}
public void b(Entity entity) {
@@ -576,6 +585,13 @@ public class Chunk {
}
this.entitySlices[i].remove(entity);
+ // Spigot start - decrement creature type count
+ for (EnumCreatureType creatureType : EnumCreatureType.values()) {
+ if (creatureType.a().isAssignableFrom(entity.getClass())) {
+ this.entityCount.adjustValue(creatureType.a(), -1);
+ }
+ }
+ // Spigot end
}
public boolean d(int i, int j, int k) {
diff --git a/src/main/java/net/minecraft/server/SpawnerCreature.java b/src/main/java/net/minecraft/server/SpawnerCreature.java
index 3529074..25b83f7 100644
--- a/src/main/java/net/minecraft/server/SpawnerCreature.java
+++ b/src/main/java/net/minecraft/server/SpawnerCreature.java
@@ -33,14 +33,8 @@ public final class SpawnerCreature {
for (Long coord : b.keySet()) {
int x = LongHash.msw(coord);
int z = LongHash.lsw(coord);
- if (!server.chunkProviderServer.unloadQueue.contains(x,z) && server.isChunkLoaded(x, z)) {
- for (List<Entity> entitySlice : server.getChunkAt(x, z).entitySlices) {
- for (Entity entity : entitySlice) {
- if (oClass.isAssignableFrom(entity.getClass())) {
- ++i;
- }
- }
- }
+ if (!server.chunkProviderServer.unloadQueue.contains(coord) && server.isChunkLoaded(x, z)) {
+ i += server.getChunkAt(x, z).entityCount.get(oClass);
}
}
return i;
--
1.8.1.2

View File

@ -1,4 +1,4 @@
From 86bed296f3b5ca333b92ae8d08ca2345b9d9a55f Mon Sep 17 00:00:00 2001
From 53d53552c6ef582d5116ed29763c7e75087b3912 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Tue, 23 Apr 2013 11:50:27 +1000
Subject: [PATCH] Thread Naming and Tweaks

View File

@ -1,4 +1,4 @@
From 26cc0b29eadbb08eb1b3c68895e3c3c2ac217d76 Mon Sep 17 00:00:00 2001
From b7b4d3fffc0fbf57e0a1d65d839fefc7a304cc74 Mon Sep 17 00:00:00 2001
From: Antony Riley <antony@cyberiantiger.org>
Date: Wed, 27 Mar 2013 01:41:54 +0200
Subject: [PATCH] Close Unloaded World's Save Files
@ -18,7 +18,7 @@ index 900ed68..829f4a3 100644
public static synchronized RegionFile a(File file1, int i, int j) {
File file2 = new File(file1, "region");
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 20ba4b7..2e8187e 100644
index c18e5e3..b32f6f1 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -37,6 +37,8 @@ import net.minecraft.server.MinecraftServer;

View File

@ -1,4 +1,4 @@
From da31d0f873c70b080ce64923ce8879ad80c37383 Mon Sep 17 00:00:00 2001
From c23cc99833fb558581a2ca3be5c99c1f1bba72ac Mon Sep 17 00:00:00 2001
From: snowleo <schneeleo@gmail.com>
Date: Wed, 8 May 2013 12:09:45 +1000
Subject: [PATCH] Optimized version of LocaleLanguage

View File

@ -1,4 +1,4 @@
From 73fc7751d67136785fe9dd8e37e6bd93e2b70b2a Mon Sep 17 00:00:00 2001
From 034219b07622cced54214debbd0fa0c8acea439f Mon Sep 17 00:00:00 2001
From: Mike Primm <mike@primmhome.com>
Date: Wed, 24 Apr 2013 01:43:33 -0500
Subject: [PATCH] Improve next-tick-list performance on chunk unloads, large

View File

@ -1,4 +1,4 @@
From e5fe9ccaefc62d0e2ec1c6c3f6c86f6d3512a77c Mon Sep 17 00:00:00 2001
From 89b2eed1417170cf2023553d4faa6046e19453a9 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Sun, 19 May 2013 18:29:48 +1000
Subject: [PATCH] Remove -o Option

View File

@ -1,4 +1,4 @@
From aa8e03fbad9d6f5752f6a607cf9f4be005a0a645 Mon Sep 17 00:00:00 2001
From ec8e652e930e20d85863f583db5d82405d239885 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Sat, 1 Jun 2013 16:34:38 +1000
Subject: [PATCH] Recipe Deconstruction

View File

@ -1,4 +1,4 @@
From de527072801296213e67bec9e91c49309864229d Mon Sep 17 00:00:00 2001
From f2e9b44c737fee7f28844e142871a84e98767a3c Mon Sep 17 00:00:00 2001
From: Nick Minkler <sleaker@gmail.com>
Date: Sun, 2 Jun 2013 14:54:11 +1000
Subject: [PATCH] Fix Health Scaling

View File

@ -1,4 +1,4 @@
From 7fdad06746184ebc24668b3358d60142108107d5 Mon Sep 17 00:00:00 2001
From 786be74a1dcb09d71c6992fa89699dfd084f3aaa Mon Sep 17 00:00:00 2001
From: Nick Minkler <sleaker@gmail.com>
Date: Sun, 2 Jun 2013 15:04:37 +1000
Subject: [PATCH] Fix EntityShootBowEvent with Skeletons

View File

@ -1,4 +1,4 @@
From 6a923051c0ba21fb7179bac35c4b4a93562b90bc Mon Sep 17 00:00:00 2001
From 486edfbe72d601217a4dd8a6695de10b5c333c0a Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Sun, 2 Jun 2013 15:16:05 +1000
Subject: [PATCH] Implement Arrow API

View File

@ -1,4 +1,4 @@
From da41cfb02d8d4c9c0ef92f3da1d0dba1ad597c86 Mon Sep 17 00:00:00 2001
From 21866de8328ae6f2caebf0112212db82d8271adb Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Sun, 2 Jun 2013 16:14:30 +1000
Subject: [PATCH] Particle API

View File

@ -1,4 +1,4 @@
From 862436c501725e9bc306c4d7f931daec482a3a4d Mon Sep 17 00:00:00 2001
From 82ed5616d56e9808448eddaff3c1704853e4d4d5 Mon Sep 17 00:00:00 2001
From: DerFlash <bte@freenet.de>
Date: Sun, 2 Jun 2013 16:23:46 +1000
Subject: [PATCH] Hopper Cooldowns
@ -64,10 +64,10 @@ index f6d269d..1f69c7b 100644
iinventory.update();
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
index 8ae36fe..aea0b37 100644
index de052ad..6d30a58 100644
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
@@ -168,4 +168,13 @@ public class SpigotWorldConfig
@@ -175,4 +175,13 @@ public class SpigotWorldConfig
maxTrackingRange = getInt( "entity-tracking-range.other", maxTrackingRange );
log( "Entity Tracking Range: Pl " + playerTrackingRange + " / An " + animalTrackingRange + " / Mo " + monsterTrackingRange + " / Mi " + miscTrackingRange + " / Other " + maxTrackingRange );
}

View File

@ -1,4 +1,4 @@
From 8a29ec73d104d1095f4e308ca9f544360a36604d Mon Sep 17 00:00:00 2001
From 761f033bf12a80a479d7cac62eba1603773a97e7 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Tue, 11 Jun 2013 11:54:32 +1000
Subject: [PATCH] Prevent Shutdown Hang

View File

@ -1,4 +1,4 @@
From a3262c25cfe4ed0aba83221d6ead8287fff8b7a7 Mon Sep 17 00:00:00 2001
From bb650303050f8dc42e5bdc7861e53cd609179bd3 Mon Sep 17 00:00:00 2001
From: Andy Shulman <andy.shulman@hotmail.com>
Date: Mon, 15 Apr 2013 20:06:37 -0500
Subject: [PATCH] Implement SpawnerSpawnEvent.

View File

@ -1,4 +1,4 @@
From 74402ddfe7d7f0a239f0ee650d08fcde49e5ca46 Mon Sep 17 00:00:00 2001
From 5045925cd02c861e4c6199c0d5eb9148c365daba Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Sat, 15 Jun 2013 21:34:48 +1000
Subject: [PATCH] Firework Meta Crash Fix

View File

@ -1,4 +1,4 @@
From e6ff7cb814f556fd3bac83c60e8a7d89d147e339 Mon Sep 17 00:00:00 2001
From 0ba4e79de49929e8f82c0f42539af7b7333a7e6f Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Sun, 16 Jun 2013 08:20:26 +1000
Subject: [PATCH] Do Not Search for Offline Players
@ -6,7 +6,7 @@ Subject: [PATCH] Do Not Search for Offline Players
By default we do not want to search as this leads to massive load times for plugins wanting to do mass data lookups.
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 2e8187e..e7f4b14 100644
index b32f6f1..8990b9f 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1085,7 +1085,7 @@ public final class CraftServer implements Server {