Paper/nms-patches/PathfinderGoalBreed.patch

50 lines
2.4 KiB
Diff
Raw Normal View History

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/PathfinderGoalBreed.java
+++ b/net/minecraft/server/PathfinderGoalBreed.java
@@ -75,11 +75,24 @@
2016-02-29 22:32:46 +01:00
EntityAgeable entityageable = this.animal.createChild(this.partner);
if (entityageable != null) {
+ // CraftBukkit start - set persistence for tame animals
+ if (entityageable instanceof EntityTameableAnimal && ((EntityTameableAnimal) entityageable).isTamed()) {
+ entityageable.persistent = true;
+ }
+ // CraftBukkit end
2017-05-14 04:00:00 +02:00
EntityPlayer entityplayer = this.animal.getBreedCause();
2017-05-14 04:00:00 +02:00
if (entityplayer == null && this.partner.getBreedCause() != null) {
entityplayer = this.partner.getBreedCause();
2016-06-19 07:00:39 +02:00
}
+ // CraftBukkit start - call EntityBreedEvent
+ int experience = this.animal.getRandom().nextInt(7) + 1;
2017-05-14 04:00:00 +02:00
+ org.bukkit.event.entity.EntityBreedEvent entityBreedEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(entityageable, animal, partner, entityplayer, this.animal.breedItem, experience);
2016-06-19 07:00:39 +02:00
+ if (entityBreedEvent.isCancelled()) {
+ return;
+ }
+ experience = entityBreedEvent.getExperience();
2016-06-19 07:00:39 +02:00
+ // CraftBukkit end
2017-05-14 04:00:00 +02:00
if (entityplayer != null) {
entityplayer.b(StatisticList.C);
@@ -92,7 +105,7 @@
2016-02-29 22:32:46 +01:00
this.partner.resetLove();
entityageable.setAgeRaw(-24000);
2016-02-29 22:32:46 +01:00
entityageable.setPositionRotation(this.animal.locX, this.animal.locY, this.animal.locZ, 0.0F, 0.0F);
- this.a.addEntity(entityageable);
+ this.a.addEntity(entityageable, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason
2016-02-29 22:32:46 +01:00
Random random = this.animal.getRandom();
for (int i = 0; i < 7; ++i) {
2017-05-14 04:00:00 +02:00
@@ -107,7 +120,11 @@
2016-06-19 07:00:39 +02:00
}
if (this.a.getGameRules().getBoolean("doMobLoot")) {
- this.a.addEntity(new EntityExperienceOrb(this.a, this.animal.locX, this.animal.locY, this.animal.locZ, random.nextInt(7) + 1));
+ // CraftBukkit start - use event experience
+ if (experience > 0) {
+ this.a.addEntity(new EntityExperienceOrb(this.a, this.animal.locX, this.animal.locY, this.animal.locZ, experience));
+ }
+ // CraftBukkit end
2016-06-19 07:00:39 +02:00
}
}