aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0310-Add-ThrownEggHatchEvent.patch
blob: 4f5c62f3e6787f298e29c8c58926024d36f76aef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <blake.galbreath@gmail.com>
Date: Sun, 9 Feb 2020 00:19:05 -0600
Subject: [PATCH] Add ThrownEggHatchEvent

Adds a new event similar to PlayerEggThrowEvent, but without the Player requirement
(dispensers can throw eggs to hatch them, too).

diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrownEgg.java b/src/main/java/net/minecraft/world/entity/projectile/ThrownEgg.java
index eb197a719177dcc1605ee0ff3c471ba91783f040..155c2bbd35adacb7c3668fbe81a7c454e5102c8b 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/ThrownEgg.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownEgg.java
@@ -88,6 +88,13 @@ public class ThrownEgg extends ThrowableItemProjectile {
                     }
                 }
                 // CraftBukkit end
+                // Paper start - Add ThrownEggHatchEvent
+                com.destroystokyo.paper.event.entity.ThrownEggHatchEvent event = new com.destroystokyo.paper.event.entity.ThrownEggHatchEvent((org.bukkit.entity.Egg) getBukkitEntity(), hatching, b0, hatchingType);
+                event.callEvent();
+                hatching = event.isHatching();
+                b0 = hatching ? event.getNumHatches() : 0; // If hatching is set to false, ensure child count is 0
+                hatchingType = event.getHatchingType();
+                // Paper end - Add ThrownEggHatchEvent
 
                 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