diff options
author | feildmaster <admin@feildmaster.com> | 2012-04-03 17:41:55 -0500 |
---|---|---|
committer | feildmaster <admin@feildmaster.com> | 2012-04-03 18:06:51 -0500 |
commit | af0018a962b1e7aa48c86ed4d7bb4599a3983a98 (patch) | |
tree | ab7b218ae86fd07958d71ce0b8b6e6b400bc3e6b | |
parent | 0c9e1b13a06148961aa436ba5967a7b215ce6439 (diff) | |
download | craftbukkit-af0018a962b1e7aa48c86ed4d7bb4599a3983a98.tar craftbukkit-af0018a962b1e7aa48c86ed4d7bb4599a3983a98.tar.gz craftbukkit-af0018a962b1e7aa48c86ed4d7bb4599a3983a98.tar.lz craftbukkit-af0018a962b1e7aa48c86ed4d7bb4599a3983a98.tar.xz craftbukkit-af0018a962b1e7aa48c86ed4d7bb4599a3983a98.zip |
Mark entities as dead when spawning fails. Treat as canceled if entity is dead.
-rw-r--r-- | src/main/java/net/minecraft/server/World.java | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java index 5eaebac0..74269285 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -23,9 +23,7 @@ import org.bukkit.craftbukkit.event.CraftEventFactory; import org.bukkit.event.block.BlockCanBuildEvent; import org.bukkit.event.block.BlockPhysicsEvent; import org.bukkit.event.block.BlockFormEvent; -import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; -import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.weather.WeatherChangeEvent; import org.bukkit.event.weather.ThunderChangeEvent; import org.bukkit.block.BlockState; @@ -879,33 +877,34 @@ public class World implements IBlockAccess { } // CraftBukkit start + org.bukkit.event.Cancellable event = null; if (entity instanceof EntityLiving && !(entity instanceof EntityPlayer)) { boolean isAnimal = entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal || entity instanceof EntityGolem; boolean isMonster = entity instanceof EntityMonster || entity instanceof EntityGhast || entity instanceof EntitySlime; if (spawnReason == SpawnReason.NATURAL || spawnReason == SpawnReason.CHUNK_GEN || spawnReason == SpawnReason.JOCKEY || spawnReason == SpawnReason.SPAWNER || spawnReason == SpawnReason.BED || spawnReason == SpawnReason.EGG || spawnReason == SpawnReason.VILLAGE_INVASION || spawnReason == SpawnReason.VILLAGE_DEFENSE || spawnReason == SpawnReason.BUILD_SNOWMAN || spawnReason == SpawnReason.BUILD_IRONGOLEM) { - if (isAnimal && !allowAnimals || isMonster && !allowMonsters) return false; + if (isAnimal && !allowAnimals || isMonster && !allowMonsters) { + entity.dead = true; + return false; + } } - CreatureSpawnEvent event = CraftEventFactory.callCreatureSpawnEvent((EntityLiving) entity, spawnReason); - - if (event.isCancelled()) { - return false; - } + event = CraftEventFactory.callCreatureSpawnEvent((EntityLiving) entity, spawnReason); } else if (entity instanceof EntityItem) { - ItemSpawnEvent event = CraftEventFactory.callItemSpawnEvent((EntityItem) entity); - if (event.isCancelled()) { - return false; - } + event = CraftEventFactory.callItemSpawnEvent((EntityItem) entity); } else if (entity.getBukkitEntity() instanceof org.bukkit.entity.Projectile) { // Not all projectiles extend EntityProjectile, so check for Bukkit interface instead - if (CraftEventFactory.callProjectileLaunchEvent(entity).isCancelled()) { - return false; - } + event = CraftEventFactory.callProjectileLaunchEvent(entity); + } + + if (event != null && (event.isCancelled() || entity.dead)) { + entity.dead = true; + return false; } // CraftBukkit end if (!flag && !this.isChunkLoaded(i, j)) { + entity.dead = true; // CraftBukkit return false; } else { if (entity instanceof EntityHuman) { |