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

@@ -60,11 +60,13 @@
super(EntityFox.this, oclass, 10, flag, flag1, predicate);
}
@@ -1275,6 +1281,14 @@
@@ -1275,6 +1281,16 @@
if (entityplayer1 != null && entityplayer != entityplayer1) {
entityfox.b(entityplayer1.getUniqueID());
}
+ // CraftBukkit start - call EntityBreedEvent
+ entityfox.setAgeRaw(-24000);
+ entityfox.setPositionRotation(this.animal.locX(), this.animal.locY(), this.animal.locZ(), 0.0F, 0.0F);
+ 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()) {
@@ -75,10 +77,12 @@
if (entityplayer2 != null) {
entityplayer2.a(StatisticList.ANIMALS_BRED);
@@ -1287,10 +1301,14 @@
@@ -1285,12 +1301,14 @@
this.partner.setAgeRaw(6000);
this.animal.resetLove();
this.partner.resetLove();
entityfox.setAgeRaw(-24000);
entityfox.setPositionRotation(this.animal.locX(), this.animal.locY(), this.animal.locZ(), 0.0F, 0.0F);
- entityfox.setAgeRaw(-24000);
- entityfox.setPositionRotation(this.animal.locX(), this.animal.locY(), this.animal.locZ(), 0.0F, 0.0F);
- worldserver.addAllEntities(entityfox);
+ worldserver.addAllEntities(entityfox, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason
this.b.broadcastEntityEffect(this.animal, (byte) 18);