SPIGOT-6224: EntityBreedEvent getEntity location inaccuracy

By: Martoph <sager1018@gmail.com>
This commit is contained in:
CraftBukkit/Spigot
2021-05-11 18:33:28 +10:00
parent c3777ce7e7
commit dfc592aec5
3 changed files with 27 additions and 20 deletions

View File

@@ -55,7 +55,7 @@
this.world.broadcastEntityEffect(this, (byte) 18);
}
@@ -209,11 +227,24 @@
@@ -209,11 +227,26 @@
EntityAgeable entityageable = this.createChild(worldserver, entityanimal);
if (entityageable != null) {
@@ -70,6 +70,8 @@
entityplayer = entityanimal.getBreedCause();
}
+ // CraftBukkit start - call EntityBreedEvent
+ entityageable.setBaby(true);
+ entityageable.setPositionRotation(this.locX(), this.locY(), this.locZ(), 0.0F, 0.0F);
+ int experience = this.getRandom().nextInt(7) + 1;
+ org.bukkit.event.entity.EntityBreedEvent entityBreedEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(entityageable, this, entityanimal, entityplayer, this.breedItem, experience);
+ if (entityBreedEvent.isCancelled()) {
@@ -80,10 +82,12 @@
if (entityplayer != null) {
entityplayer.a(StatisticList.ANIMALS_BRED);
@@ -226,10 +257,14 @@
@@ -224,12 +257,14 @@
entityanimal.setAgeRaw(6000);
this.resetLove();
entityanimal.resetLove();
entityageable.setBaby(true);
entityageable.setPositionRotation(this.locX(), this.locY(), this.locZ(), 0.0F, 0.0F);
- entityageable.setBaby(true);
- entityageable.setPositionRotation(this.locX(), this.locY(), this.locZ(), 0.0F, 0.0F);
- worldserver.addAllEntities(entityageable);
+ worldserver.addAllEntities(entityageable, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason
worldserver.broadcastEntityEffect(this, (byte) 18);