Add ThrownEggHatchEvent

Adds a new event similar to PlayerEggThrowEvent, but without the Player requirement
(dispensers can throw eggs to hatch them, too).
This commit is contained in:
William Blake Galbreath 2020-02-09 00:19:05 -06:00
parent a92909cfd7
commit 4e20691d59

View file

@ -48,7 +48,7 @@
}
@Override
@@ -52,30 +58,58 @@
@@ -52,30 +58,65 @@
protected void onHit(HitResult hitResult) {
super.onHit(hitResult);
if (!this.level().isClientSide) {
@ -83,6 +83,13 @@
+ }
+ }
+ // 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) {
- Chicken entitychicken = (Chicken) EntityType.CHICKEN.create(this.level(), EntitySpawnReason.TRIGGERED);