From 729df1a734053f61459f7abdcc92a892f7eb3aad Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 5 Feb 2014 11:42:44 -0500 Subject: [PATCH] [Bleeding] Add many missing SpawnReasons. Adds BUKKIT-5370, BUKKIT-5377, BUKKIT-5378, BUKKIT-5379, BUKKIT-5380, BUKKIT-5381, BUKKIT-5382. Adds reasons for zombies infecting villagers and zombie villagers being cured. Readds reason for a skeleton being spawned as a spider jockey. Adds reason to distinguish ocelot babies from the parent they spawned with. Adds reasons for chunk generation causing the ender dragon, villagers, and witches to spawn. And finally, adds a reason for spawning a chicken mount for a baby zombie. --- .../java/net/minecraft/server/BiomeTheEndDecorator.java | 2 +- src/main/java/net/minecraft/server/BlockMonsterEggs.java | 6 ++++-- src/main/java/net/minecraft/server/EntityOcelot.java | 2 +- src/main/java/net/minecraft/server/EntitySpider.java | 2 +- src/main/java/net/minecraft/server/EntityZombie.java | 9 +++++---- .../java/net/minecraft/server/WorldGenVillagePiece.java | 2 +- src/main/java/net/minecraft/server/WorldGenWitchHut.java | 2 +- 7 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/main/java/net/minecraft/server/BiomeTheEndDecorator.java b/src/main/java/net/minecraft/server/BiomeTheEndDecorator.java index 8635426ff9..0ba653ce51 100644 --- a/src/main/java/net/minecraft/server/BiomeTheEndDecorator.java +++ b/src/main/java/net/minecraft/server/BiomeTheEndDecorator.java @@ -22,7 +22,7 @@ public class BiomeTheEndDecorator extends BiomeDecorator { EntityEnderDragon entityenderdragon = new EntityEnderDragon(this.a); entityenderdragon.setPositionRotation(0.0D, 128.0D, 0.0D, this.b.nextFloat() * 360.0F, 0.0F); - this.a.addEntity(entityenderdragon); + this.a.addEntity(entityenderdragon, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason } } } diff --git a/src/main/java/net/minecraft/server/BlockMonsterEggs.java b/src/main/java/net/minecraft/server/BlockMonsterEggs.java index 5b08c3d421..d9f874151b 100644 --- a/src/main/java/net/minecraft/server/BlockMonsterEggs.java +++ b/src/main/java/net/minecraft/server/BlockMonsterEggs.java @@ -4,6 +4,8 @@ import java.util.Random; import net.minecraft.util.org.apache.commons.lang3.tuple.ImmutablePair; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; // CraftBukkit + public class BlockMonsterEggs extends Block { public static final String[] a = new String[] { "stone", "cobble", "brick", "mossybrick", "crackedbrick", "chiseledbrick"}; @@ -19,7 +21,7 @@ public class BlockMonsterEggs extends Block { EntitySilverfish entitysilverfish = new EntitySilverfish(world); entitysilverfish.setPositionRotation((double) i + 0.5D, (double) j, (double) k + 0.5D, 0.0F, 0.0F); - world.addEntity(entitysilverfish); + world.addEntity(entitysilverfish, SpawnReason.SILVERFISH_BLOCK); // CraftBukkit - add SpawnReason entitysilverfish.s(); } @@ -108,7 +110,7 @@ public class BlockMonsterEggs extends Block { EntitySilverfish entitysilverfish = new EntitySilverfish(world); entitysilverfish.setPositionRotation((double) i + 0.5D, (double) j, (double) k + 0.5D, 0.0F, 0.0F); - world.addEntity(entitysilverfish); + world.addEntity(entitysilverfish, SpawnReason.SILVERFISH_BLOCK); // CraftBukkit - add SpawnReason entitysilverfish.s(); } } diff --git a/src/main/java/net/minecraft/server/EntityOcelot.java b/src/main/java/net/minecraft/server/EntityOcelot.java index 7f78fa0ae6..603e53daa2 100644 --- a/src/main/java/net/minecraft/server/EntityOcelot.java +++ b/src/main/java/net/minecraft/server/EntityOcelot.java @@ -221,7 +221,7 @@ public class EntityOcelot extends EntityTameableAnimal { entityocelot.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F); entityocelot.setAge(-24000); - this.world.addEntity(entityocelot); + this.world.addEntity(entityocelot, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.OCELOT_BABY); // CraftBukkit - add SpawnReason } } diff --git a/src/main/java/net/minecraft/server/EntitySpider.java b/src/main/java/net/minecraft/server/EntitySpider.java index b151e737fd..67a23f6539 100644 --- a/src/main/java/net/minecraft/server/EntitySpider.java +++ b/src/main/java/net/minecraft/server/EntitySpider.java @@ -156,7 +156,7 @@ public class EntitySpider extends EntityMonster { entityskeleton.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F); entityskeleton.a((GroupDataEntity) null); - this.world.addEntity(entityskeleton); + this.world.addEntity(entityskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.JOCKEY); // CraftBukkit - add SpawnReason entityskeleton.mount(this); } diff --git a/src/main/java/net/minecraft/server/EntityZombie.java b/src/main/java/net/minecraft/server/EntityZombie.java index a0b6f62e8c..66c4c9c449 100644 --- a/src/main/java/net/minecraft/server/EntityZombie.java +++ b/src/main/java/net/minecraft/server/EntityZombie.java @@ -7,6 +7,7 @@ import java.util.UUID; //CraftBukkit start import org.bukkit.craftbukkit.entity.CraftLivingEntity; +import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.EntityCombustByEntityEvent; import org.bukkit.event.entity.EntityCombustEvent; //CraftBukkit end @@ -186,7 +187,7 @@ public class EntityZombie extends EntityMonster { if (World.a((IBlockAccess) this.world, i1, j1 - 1, k1) && this.world.getLightLevel(i1, j1, k1) < 10) { entityzombie.setPosition((double) i1, (double) j1, (double) k1); if (this.world.b(entityzombie.boundingBox) && this.world.getCubes(entityzombie, entityzombie.boundingBox).isEmpty() && !this.world.containsLiquid(entityzombie.boundingBox)) { - this.world.addEntity(entityzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); // CraftBukkit + this.world.addEntity(entityzombie, CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); // CraftBukkit entityzombie.setGoalTarget(entityliving); entityzombie.a((GroupDataEntity) null); this.getAttributeInstance(bp).a(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, 0)); @@ -341,7 +342,7 @@ public class EntityZombie extends EntityMonster { entityzombie.setBaby(true); } - this.world.addEntity(entityzombie); + this.world.addEntity(entityzombie, CreatureSpawnEvent.SpawnReason.INFECTION); // CraftBukkit - add SpawnReason this.world.a((EntityHuman) null, 1016, (int) this.locX, (int) this.locY, (int) this.locZ, 0); } } @@ -379,7 +380,7 @@ public class EntityZombie extends EntityMonster { entitychicken1.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F); entitychicken1.a((GroupDataEntity) null); entitychicken1.i(true); - this.world.addEntity(entitychicken1); + this.world.addEntity(entitychicken1, CreatureSpawnEvent.SpawnReason.MOUNT); this.mount(entitychicken1); } } @@ -462,7 +463,7 @@ public class EntityZombie extends EntityMonster { } this.world.kill(this); - this.world.addEntity(entityvillager); + this.world.addEntity(entityvillager, CreatureSpawnEvent.SpawnReason.CURED); // CraftBukkit - add SpawnReason entityvillager.addEffect(new MobEffect(MobEffectList.CONFUSION.id, 200, 0)); this.world.a((EntityHuman) null, 1017, (int) this.locX, (int) this.locY, (int) this.locZ, 0); } diff --git a/src/main/java/net/minecraft/server/WorldGenVillagePiece.java b/src/main/java/net/minecraft/server/WorldGenVillagePiece.java index 9733b8a85a..dd228e777d 100644 --- a/src/main/java/net/minecraft/server/WorldGenVillagePiece.java +++ b/src/main/java/net/minecraft/server/WorldGenVillagePiece.java @@ -107,7 +107,7 @@ abstract class WorldGenVillagePiece extends StructurePiece { EntityVillager entityvillager = new EntityVillager(world, this.b(i1)); entityvillager.setPositionRotation((double) j1 + 0.5D, (double) k1, (double) l1 + 0.5D, 0.0F, 0.0F); - world.addEntity(entityvillager); + world.addEntity(entityvillager, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason } } } diff --git a/src/main/java/net/minecraft/server/WorldGenWitchHut.java b/src/main/java/net/minecraft/server/WorldGenWitchHut.java index a4d21c22fc..a49a91a8cd 100644 --- a/src/main/java/net/minecraft/server/WorldGenWitchHut.java +++ b/src/main/java/net/minecraft/server/WorldGenWitchHut.java @@ -77,7 +77,7 @@ public class WorldGenWitchHut extends WorldGenScatteredPiece { entitywitch.setPositionRotation((double) i1 + 0.5D, (double) j1, (double) k1 + 0.5D, 0.0F, 0.0F); entitywitch.a((GroupDataEntity) null); - world.addEntity(entitywitch); + world.addEntity(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason } }