summaryrefslogtreecommitdiffstats
path: root/nms-patches/EntityEgg.patch
diff options
context:
space:
mode:
authorThinkofdeath <thinkofdeath@spigotmc.org>2014-11-26 08:32:16 +1100
committermd_5 <git@md-5.net>2014-11-28 17:16:30 +1100
commit24557bc2b37deb6a0edf497d547471832457b1dd (patch)
treec560572889a3b0b34964a0cddb35dc87fda3c914 /nms-patches/EntityEgg.patch
parenta4805dbd77da057cc1ea0bf344379bc6e53ca1f6 (diff)
downloadcraftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.tar
craftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.tar.gz
craftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.tar.lz
craftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.tar.xz
craftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.zip
Update to Minecraft 1.8
For more information please see http://www.spigotmc.org/
Diffstat (limited to 'nms-patches/EntityEgg.patch')
-rw-r--r--nms-patches/EntityEgg.patch65
1 files changed, 65 insertions, 0 deletions
diff --git a/nms-patches/EntityEgg.patch b/nms-patches/EntityEgg.patch
new file mode 100644
index 00000000..9b51e766
--- /dev/null
+++ b/nms-patches/EntityEgg.patch
@@ -0,0 +1,65 @@
+--- ../work/decompile-bb26c12b/net/minecraft/server/EntityEgg.java 2014-11-27 08:59:46.665422005 +1100
++++ src/main/java/net/minecraft/server/EntityEgg.java 2014-11-27 08:42:10.112850989 +1100
+@@ -1,5 +1,12 @@
+ package net.minecraft.server;
+
++// CraftBukkit start
++import org.bukkit.entity.Ageable;
++import org.bukkit.entity.EntityType;
++import org.bukkit.entity.Player;
++import org.bukkit.event.player.PlayerEggThrowEvent;
++// CraftBukkit end
++
+ public class EntityEgg extends EntityProjectile {
+
+ public EntityEgg(World world) {
+@@ -19,21 +26,36 @@
+ movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.getShooter()), 0.0F);
+ }
+
+- if (!this.world.isStatic && this.random.nextInt(8) == 0) {
+- byte b0 = 1;
++ // CraftBukkit start - Fire PlayerEggThrowEvent
++ boolean hatching = !this.world.isStatic && this.random.nextInt(8) == 0;
++ int numHatching = (this.random.nextInt(32) == 0) ? 4 : 1;
++ if (!hatching) {
++ numHatching = 0;
++ }
++
++ EntityType hatchingType = EntityType.CHICKEN;
+
+- if (this.random.nextInt(32) == 0) {
+- b0 = 4;
+- }
+-
+- for (int i = 0; i < b0; ++i) {
+- EntityChicken entitychicken = new EntityChicken(this.world);
+-
+- entitychicken.setAgeRaw(-24000);
+- entitychicken.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F);
+- this.world.addEntity(entitychicken);
+- }
++ Entity shooter = this.getShooter();
++ if (shooter instanceof EntityPlayer) {
++ Player player = (shooter == null) ? null : (Player) shooter.getBukkitEntity();
++
++ PlayerEggThrowEvent event = new PlayerEggThrowEvent(player, (org.bukkit.entity.Egg) this.getBukkitEntity(), hatching, (byte) numHatching, hatchingType);
++ this.world.getServer().getPluginManager().callEvent(event);
++
++ hatching = event.isHatching();
++ numHatching = event.getNumHatches();
++ hatchingType = event.getHatchingType();
++ }
++
++ if (hatching) {
++ for (int k = 0; k < numHatching; k++) {
++ org.bukkit.entity.Entity entity = world.getWorld().spawn(new org.bukkit.Location(world.getWorld(), this.locX, this.locY, this.locZ, this.yaw, 0.0F), hatchingType.getEntityClass(), org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG);
++ if (entity instanceof Ageable) {
++ ((Ageable) entity).setBaby();
++ }
++ }
+ }
++ // CraftBukkit end
+
+ double d0 = 0.08D;
+