From 03c118f343f8e559c0573589f4f89e4e2b3d10ad Mon Sep 17 00:00:00 2001 From: EvilSeph Date: Wed, 16 Feb 2011 22:42:41 -0500 Subject: [PATCH] Added CREATURE_SPAWN event per ss2man44 --- src/main/java/net/minecraft/server/World.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java index 02c5be8339..3275e36952 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -17,12 +17,15 @@ import java.util.Set; import java.util.TreeSet; // CraftBukkit start +import org.bukkit.Location; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.event.Event; import org.bukkit.event.Event.Type; import org.bukkit.event.block.BlockCanBuildEvent; import org.bukkit.event.block.BlockPhysicsEvent; +import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.entity.MobType; // CraftBukkit end public class World implements IBlockAccess { @@ -806,6 +809,48 @@ public class World implements IBlockAccess { flag = true; } + //CraftBukkit start + if (entity instanceof EntityLiving) { + + MobType type = null; + + if (entity instanceof EntityChicken) { + type = MobType.CHICKEN; + } else if (entity instanceof EntityCow) { + type = MobType.COW; + } else if (entity instanceof EntityCreeper) { + type = MobType.CREEPER; + } else if (entity instanceof EntityGhast) { + type = MobType.GHAST; + } else if (entity instanceof EntityPig) { + type = MobType.PIG; + } else if (entity instanceof EntityPigZombie) { + type = MobType.PIG_ZOMBIE; + } else if (entity instanceof EntitySheep) { + type = MobType.SHEEP; + } else if (entity instanceof EntitySkeleton) { + type = MobType.SKELETON; + } else if (entity instanceof EntitySpider) { + type = MobType.SPIDER; + } else if (entity instanceof EntityZombie) { + type = MobType.ZOMBIE; + } + + if (type != null) { + CraftServer server = ((WorldServer)this).getServer(); + Location loc = new Location(((WorldServer)this).getWorld(), entity.O, entity.P, entity.Q); + + CreatureSpawnEvent cse; + cse = new CreatureSpawnEvent(entity.getBukkitEntity(), type, loc); + server.getPluginManager().callEvent(cse); + + if (cse.isCancelled()) { + return false; + } + } + } + //CraftBukkit end + if (!flag && !this.f(i, j)) { return false; } else {