summaryrefslogtreecommitdiffstats
path: root/nms-patches/EntityEgg.patch
diff options
context:
space:
mode:
Diffstat (limited to 'nms-patches/EntityEgg.patch')
-rw-r--r--nms-patches/EntityEgg.patch84
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);