diff options
author | md_5 <git@md-5.net> | 2016-11-17 12:41:03 +1100 |
---|---|---|
committer | md_5 <git@md-5.net> | 2016-11-17 12:41:03 +1100 |
commit | c25ddf063a808e3adb749e22017661f403c5fb7e (patch) | |
tree | b2efcff512be12fd3e38cf8c36386148ce6ab4ae /nms-patches/EntityEgg.patch | |
parent | 51263e97187a84338f89698eef187284055a682a (diff) | |
download | craftbukkit-c25ddf063a808e3adb749e22017661f403c5fb7e.tar craftbukkit-c25ddf063a808e3adb749e22017661f403c5fb7e.tar.gz craftbukkit-c25ddf063a808e3adb749e22017661f403c5fb7e.tar.lz craftbukkit-c25ddf063a808e3adb749e22017661f403c5fb7e.tar.xz craftbukkit-c25ddf063a808e3adb749e22017661f403c5fb7e.zip |
Update to Minecraft 1.11
Diffstat (limited to 'nms-patches/EntityEgg.patch')
-rw-r--r-- | nms-patches/EntityEgg.patch | 84 |
1 files changed, 40 insertions, 44 deletions
diff --git a/nms-patches/EntityEgg.patch b/nms-patches/EntityEgg.patch index de818824..314bd2fe 100644 --- a/nms-patches/EntityEgg.patch +++ b/nms-patches/EntityEgg.patch @@ -13,54 +13,50 @@ public class EntityEgg extends EntityProjectile { public EntityEgg(World world) { -@@ -23,21 +30,37 @@ - movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.getShooter()), 0.0F); +@@ -24,20 +31,40 @@ } -- if (!this.world.isClientSide && this.random.nextInt(8) == 0) { -- byte b0 = 1; -+ // CraftBukkit start - Fire PlayerEggThrowEvent -+ boolean hatching = !this.world.isClientSide && this.random.nextInt(8) == 0; -+ int numHatching = (this.random.nextInt(32) == 0) ? 4 : 1; -+ if (!hatching) { -+ numHatching = 0; -+ } -+ -+ EntityType hatchingType = EntityType.CHICKEN; -+ -+ Entity shooter = this.getShooter(); -+ if (shooter instanceof EntityPlayer) { -+ Player player = (shooter == null) ? null : (Player) shooter.getBukkitEntity(); + if (!this.world.isClientSide) { +- if (this.random.nextInt(8) == 0) { ++ boolean hatching = this.random.nextInt(8) == 0; // CraftBukkit ++ if (true) { + byte b0 = 1; + + if (this.random.nextInt(32) == 0) { + b0 = 4; + } + +- for (int i = 0; i < b0; ++i) { +- EntityChicken entitychicken = new EntityChicken(this.world); ++ // CraftBukkit start ++ if (!hatching) { ++ b0 = 0; ++ } ++ EntityType hatchingType = EntityType.CHICKEN; + -+ PlayerEggThrowEvent event = new PlayerEggThrowEvent(player, (org.bukkit.entity.Egg) this.getBukkitEntity(), hatching, (byte) numHatching, hatchingType); -+ this.world.getServer().getPluginManager().callEvent(event); ++ Entity shooter = this.getShooter(); ++ if (shooter instanceof EntityPlayer) { ++ PlayerEggThrowEvent event = new PlayerEggThrowEvent((Player) shooter.getBukkitEntity(), (org.bukkit.entity.Egg) this.getBukkitEntity(), hatching, b0, hatchingType); ++ this.world.getServer().getPluginManager().callEvent(event); + -+ hatching = event.isHatching(); -+ numHatching = event.getNumHatches(); -+ hatchingType = event.getHatchingType(); -+ } - -- 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); -- } -+ if (hatching) { -+ for (int k = 0; k < numHatching; k++) { -+ Entity entity = world.getWorld().createEntity(new org.bukkit.Location(world.getWorld(), this.locX, this.locY, this.locZ, this.yaw, 0.0F), hatchingType.getEntityClass()); -+ if (entity.getBukkitEntity() instanceof Ageable) { -+ ((Ageable) entity.getBukkitEntity()).setBaby(); ++ b0 = event.getNumHatches(); ++ hatching = event.isHatching(); ++ hatchingType = event.getHatchingType(); + } -+ world.getWorld().addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG); -+ } - } -+ // CraftBukkit end - double d0 = 0.08D; +- entitychicken.setAgeRaw(-24000); +- entitychicken.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F); +- this.world.addEntity(entitychicken); ++ if (hatching) { ++ for (int i = 0; i < b0; ++i) { ++ Entity entity = world.getWorld().createEntity(new org.bukkit.Location(world.getWorld(), this.locX, this.locY, this.locZ, this.yaw, 0.0F), hatchingType.getEntityClass()); ++ if (entity.getBukkitEntity() instanceof Ageable) { ++ ((Ageable) entity.getBukkitEntity()).setBaby(); ++ } ++ world.getWorld().addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG); ++ } + } ++ // CraftBukkit end + } + this.world.broadcastEntityEffect(this, (byte) 3); |