From 54f4e7f95884a9666b3eb5d5f5415cdd2eea89a8 Mon Sep 17 00:00:00 2001 From: Brokkonaut Date: Fri, 9 Aug 2019 04:34:33 +0200 Subject: [PATCH] SPIGOT-5257: Call EntityBreedEvent for foxes and set the child's spawn reason to BREEDING --- nms-patches/EntityFox.patch | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/nms-patches/EntityFox.patch b/nms-patches/EntityFox.patch index 34ed37a107..d96d9e3156 100644 --- a/nms-patches/EntityFox.patch +++ b/nms-patches/EntityFox.patch @@ -68,3 +68,35 @@ this.c = this.j; if (this.k != null) { this.l = this.k.ct(); +@@ -1225,6 +1230,14 @@ + if (entityplayer1 != null && entityplayer != entityplayer1) { + entityfox.b(entityplayer1.getUniqueID()); + } ++ // CraftBukkit start - call EntityBreedEvent ++ int experience = this.animal.getRandom().nextInt(7) + 1; ++ org.bukkit.event.entity.EntityBreedEvent entityBreedEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(entityfox, animal, partner, entityplayer, this.animal.breedItem, experience); ++ if (entityBreedEvent.isCancelled()) { ++ return; ++ } ++ experience = entityBreedEvent.getExperience(); ++ // CraftBukkit end + + if (entityplayer2 != null) { + entityplayer2.a(StatisticList.ANIMALS_BRED); +@@ -1239,10 +1252,14 @@ + this.partner.resetLove(); + entityfox.setAgeRaw(-24000); + entityfox.setPositionRotation(this.animal.locX, this.animal.locY, this.animal.locZ, 0.0F, 0.0F); +- this.b.addEntity(entityfox); ++ this.b.addEntity(entityfox, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason + this.b.broadcastEntityEffect(this.animal, (byte) 18); + if (this.b.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) { +- this.b.addEntity(new EntityExperienceOrb(this.b, this.animal.locX, this.animal.locY, this.animal.locZ, this.animal.getRandom().nextInt(7) + 1)); ++ // CraftBukkit start - use event experience ++ if (experience > 0) { ++ this.b.addEntity(new EntityExperienceOrb(this.b, this.animal.locX, this.animal.locY, this.animal.locZ, experience)); ++ } ++ // CraftBukkit end + } + + }