diff options
author | Taylor Kelly <tkelly910@gmail.com> | 2011-01-11 03:44:39 -0500 |
---|---|---|
committer | Taylor Kelly <tkelly910@gmail.com> | 2011-01-11 03:44:39 -0500 |
commit | 6a34f200aea5688fcb974de1513bdf5f0f9d42fe (patch) | |
tree | 6ed885834979ed4dcbacb8fa876251ca290c65bf /src/main/java/net | |
parent | 94bccb6f9261e7be7833119a1abbd56b6fca6473 (diff) | |
download | craftbukkit-6a34f200aea5688fcb974de1513bdf5f0f9d42fe.tar craftbukkit-6a34f200aea5688fcb974de1513bdf5f0f9d42fe.tar.gz craftbukkit-6a34f200aea5688fcb974de1513bdf5f0f9d42fe.tar.lz craftbukkit-6a34f200aea5688fcb974de1513bdf5f0f9d42fe.tar.xz craftbukkit-6a34f200aea5688fcb974de1513bdf5f0f9d42fe.zip |
updated EntityEgg
Diffstat (limited to 'src/main/java/net')
-rw-r--r-- | src/main/java/net/minecraft/server/EntityEgg.java | 79 |
1 files changed, 65 insertions, 14 deletions
diff --git a/src/main/java/net/minecraft/server/EntityEgg.java b/src/main/java/net/minecraft/server/EntityEgg.java index c0f5c32c..7723190b 100644 --- a/src/main/java/net/minecraft/server/EntityEgg.java +++ b/src/main/java/net/minecraft/server/EntityEgg.java @@ -1,9 +1,12 @@ package net.minecraft.server; - import java.util.List; import java.util.Random; - +import org.bukkit.MobType; +import org.bukkit.craftbukkit.CraftPlayer; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.event.Event.Type; +import org.bukkit.event.player.PlayerEggThrowEvent; public class EntityEgg extends Entity { @@ -54,7 +57,7 @@ public class EntityEgg extends Entity { a(s, t, u, 1.5F, 1.0F); } - public void a(double d1, double d2, double d3, float f1, + public void a(double d1, double d2, double d3, float f1, float f2) { float f3 = MathHelper.a(d1 * d1 + d2 * d2 + d3 * d3); @@ -150,20 +153,69 @@ public class EntityEgg extends Entity { ; } } - if (!this.l.z && W.nextInt(8) == 0) { - byte byte0 = 1; - if (W.nextInt(32) == 0) { - byte0 = 4; - } - for (int k = 0; k < byte0; k++) { - EntityChicken entitychicken = new EntityChicken(this.l); + // Craftbukkit start + boolean hatching = !this.l.z && W.nextInt(8) == 0; + byte numHatching = (hatching && W.nextInt(32) == 0) ? (byte) 4 : (byte) 1; + if (!hatching) { + numHatching = 0; + } + MobType type = MobType.CHICKEN; - entitychicken.c(p, q, r, v, 0.0F); - this.l.a(entitychicken); - } + if (aj instanceof EntityPlayerMP) { + CraftServer server = ((WorldServer) l).getServer(); + CraftPlayer player = new CraftPlayer(server, (EntityPlayerMP) aj); + PlayerEggThrowEvent event = new PlayerEggThrowEvent(Type.PLAYER_EGG_THROW, player, hatching, numHatching, type); + server.getPluginManager().callEvent(event); + hatching = event.isHatching(); + numHatching = event.getNumHatches(); + type = event.getHatchType(); + } + if (hatching) { + for (int k = 0; k < numHatching; k++) { + Entity entity = null; + switch (type) { + case CHICKEN: + entity = new EntityChicken(this.l); + break; + case COW: + entity = new EntityCow(this.l); + break; + case CREEPER: + entity = new EntityCreeper(this.l); + break; + case GHAST: + entity = new EntityGhast(this.l); + break; + case PIG: + entity = new EntityPig(this.l); + break; + case PIG_ZOMBIE: + entity = new EntityPigZombie(this.l); + break; + case SHEEP: + entity = new EntitySheep(this.l); + break; + case SKELETON: + entity = new EntitySkeleton(this.l); + break; + case SPIDER: + entity = new EntitySpider(this.l); + break; + case ZOMBIE: + entity = new EntityZombie(this.l); + break; + default: + entity = new EntityChicken(this.l); + break; + } + entity.c(p, q, r, v, 0.0F); + this.l.a(entity); + } } + // Craftbukkit stop + for (int j = 0; j < 8; j++) { this.l.a("snowballpoof", p, q, r, 0.0D, 0.0D, 0.0D); } @@ -235,4 +287,3 @@ public class EntityEgg extends Entity { } } } - |