mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-09 20:30:28 +01:00
90ac03522a
This reverts commit d6e3dff7d8
.
66 lines
2.6 KiB
Diff
66 lines
2.6 KiB
Diff
--- ../work/decompile-8eb82bde//net/minecraft/server/EntityEgg.java 2014-11-28 17:43:43.077707435 +0000
|
|
+++ src/main/java/net/minecraft/server/EntityEgg.java 2014-11-28 17:38:18.000000000 +0000
|
|
@@ -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;
|
|
|