From 40f7986a110c31d857d2cc7a7f7a802e619faf99 Mon Sep 17 00:00:00 2001 From: Erik Broes Date: Sun, 13 Feb 2011 01:21:50 +0100 Subject: [PATCH] Make the spawning listen to the server spawn-settings --- src/main/java/net/minecraft/server/EntityEgg.java | 8 ++++++-- .../net/minecraft/server/TileEntityMobSpawner.java | 7 +++++++ src/main/java/net/minecraft/server/World.java | 10 +++++++--- src/main/java/net/minecraft/server/WorldServer.java | 8 +++++--- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/main/java/net/minecraft/server/EntityEgg.java b/src/main/java/net/minecraft/server/EntityEgg.java index e7f542af86..adb823e11e 100644 --- a/src/main/java/net/minecraft/server/EntityEgg.java +++ b/src/main/java/net/minecraft/server/EntityEgg.java @@ -245,8 +245,12 @@ public class EntityEgg extends Entity { break; } - entity.c(this.locX, this.locY, this.locZ, this.yaw, 0.0F); - this.world.a(entity); + // The world we're spawning in accepts this creature + boolean isAnimal = entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal; + if ((isAnimal && this.world.L) || (!isAnimal && this.world.K)) { + entity.c(this.locX, this.locY, this.locZ, this.yaw, 0.0F); + this.world.a(entity); + } } } // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/TileEntityMobSpawner.java b/src/main/java/net/minecraft/server/TileEntityMobSpawner.java index 52f8a302fb..a52e8aa3b4 100644 --- a/src/main/java/net/minecraft/server/TileEntityMobSpawner.java +++ b/src/main/java/net/minecraft/server/TileEntityMobSpawner.java @@ -49,6 +49,13 @@ public class TileEntityMobSpawner extends TileEntity { return; } + // CraftBukkit start - The world we're spawning in accepts this creature + boolean isAnimal = entityliving instanceof EntityAnimal || entityliving instanceof EntityWaterAnimal; + if ((isAnimal && !this.a.L) || (!isAnimal && !this.a.K)) { + return; + } + // CraftBukkit end + int j = this.a.a(entityliving.getClass(), AxisAlignedBB.b((double) this.b, (double) this.c, (double) this.d, (double) (this.b + 1), (double) (this.c + 1), (double) (this.d + 1)).b(8.0D, 4.0D, 8.0D)).size(); if (j >= 6) { diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java index 9a1c5a2837..02c5be8339 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -61,8 +61,8 @@ public class World implements IBlockAccess { public boolean x; private ArrayList I = new ArrayList(); private int J = 0; - private boolean K = true; - private boolean L = true; + public boolean K = true; // CraftBukkit private->public + public boolean L = true; // CraftBukkit private->public static int y = 0; private Set M = new HashSet(); private int N; @@ -1439,7 +1439,11 @@ public class World implements IBlockAccess { } public void f() { - SpawnerCreature.a(this, this.K, this.L); + // CraftBukkit start -- Only call spawner if we have players online and the world allows for mobs or animals + if ((this.K || this.L) && (this instanceof WorldServer && ((WorldServer) this).getServer().getHandle().b.size() > 0)) + SpawnerCreature.a(this, this.K, this.L); + // CraftBukkit end + this.G.a(); int i = this.a(1.0F); diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java index f20b51f1c7..7a29714f1d 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -47,9 +47,11 @@ public class WorldServer extends World implements BlockChangeDelegate { } public void a(Entity entity, boolean flag) { - if (!this.D.m && (entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal)) { - entity.q(); - } + // CraftBukkit start -- We prevent spawning in general, so this butching is not needed + //if (!this.D.m && (entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal)) { + // entity.q(); + //} + // CraftBukkit end if (entity.passenger == null || !(entity.passenger instanceof EntityHuman)) { super.a(entity, flag);