@@ -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
|
||||
|
||||
Reference in New Issue
Block a user