diff options
Diffstat (limited to 'patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/projectile/ThrownEgg.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/projectile/ThrownEgg.java.patch | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/projectile/ThrownEgg.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/projectile/ThrownEgg.java.patch new file mode 100644 index 0000000000..00e2f8f468 --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/projectile/ThrownEgg.java.patch @@ -0,0 +1,77 @@ +--- a/net/minecraft/world/entity/projectile/ThrownEgg.java ++++ b/net/minecraft/world/entity/projectile/ThrownEgg.java +@@ -10,6 +5,16 @@ + import net.minecraft.world.level.Level; + import net.minecraft.world.phys.EntityHitResult; + import net.minecraft.world.phys.HitResult; ++import net.minecraft.core.particles.ItemParticleOption; ++import net.minecraft.core.particles.ParticleTypes; ++import net.minecraft.server.level.ServerPlayer; ++import net.minecraft.world.entity.Entity; ++import net.minecraft.world.entity.LivingEntity; ++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 ThrownEgg extends ThrowableItemProjectile { + public ThrownEgg(EntityType<? extends ThrownEgg> entityType, Level level) { +@@ -54,20 +52,49 @@ + protected void onHit(HitResult result) { + super.onHit(result); + if (!this.level().isClientSide) { +- if (this.random.nextInt(8) == 0) { +- int i = 1; ++ // CraftBukkit start ++ boolean hatching = this.random.nextInt(8) == 0; ++ if (true) { ++ // CraftBukkit end ++ byte b0 = 1; ++ + if (this.random.nextInt(32) == 0) { + i = 4; + } + +- for (int i1 = 0; i1 < i; i1++) { +- Chicken chicken = EntityType.CHICKEN.create(this.level()); +- if (chicken != null) { +- chicken.setAge(-24000); +- chicken.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F); +- this.level().addFreshEntity(chicken); ++ // CraftBukkit start ++ EntityType hatchingType = EntityType.CHICKEN; ++ ++ Entity shooter = this.getOwner(); ++ if (!hatching) { ++ b0 = 0; ++ } ++ if (shooter instanceof ServerPlayer) { ++ PlayerEggThrowEvent event = new PlayerEggThrowEvent((Player) shooter.getBukkitEntity(), (org.bukkit.entity.Egg) this.getBukkitEntity(), hatching, b0, hatchingType); ++ this.level().getCraftServer().getPluginManager().callEvent(event); ++ ++ b0 = event.getNumHatches(); ++ hatching = event.isHatching(); ++ hatchingType = event.getHatchingType(); ++ // If hatching is set to false, ensure child count is 0 ++ if (!hatching) { ++ b0 = 0; + } + } ++ // CraftBukkit end ++ ++ for (int i = 0; i < b0; ++i) { ++ Entity entitychicken = this.level().getWorld().makeEntity(new org.bukkit.Location(this.level().getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F), hatchingType.getEntityClass()); // CraftBukkit ++ ++ if (entitychicken != null) { ++ // CraftBukkit start ++ if (entitychicken.getBukkitEntity() instanceof Ageable) { ++ ((Ageable) entitychicken.getBukkitEntity()).setBaby(); ++ } ++ this.level().addFreshEntity(entitychicken, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG); ++ // CraftBukkit end ++ } ++ } + } + + this.level().broadcastEntityEvent(this, (byte)3); |