mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-06 02:35:49 +01:00
SPIGOT-6224: EntityBreedEvent getEntity location inaccuracy
By: Martoph <sager1018@gmail.com>
This commit is contained in:
parent
c3777ce7e7
commit
dfc592aec5
3 changed files with 27 additions and 20 deletions
|
@ -1,22 +1,21 @@
|
|||
--- a/net/minecraft/world/entity/ai/behavior/BehaviorMakeLove.java
|
||||
+++ b/net/minecraft/world/entity/ai/behavior/BehaviorMakeLove.java
|
||||
@@ -106,6 +106,11 @@
|
||||
|
||||
private Optional<EntityVillager> b(WorldServer worldserver, EntityVillager entityvillager, EntityVillager entityvillager1) {
|
||||
EntityVillager entityvillager2 = entityvillager.createChild(worldserver, entityvillager1);
|
||||
+ // CraftBukkit start - call EntityBreedEvent
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(entityvillager2, entityvillager, entityvillager1, null, null, 0).isCancelled()) {
|
||||
+ return Optional.empty();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
@@ -110,11 +110,16 @@
|
||||
if (entityvillager2 == null) {
|
||||
return Optional.empty();
|
||||
@@ -114,7 +119,7 @@
|
||||
entityvillager1.setAgeRaw(6000);
|
||||
} else {
|
||||
- entityvillager.setAgeRaw(6000);
|
||||
- entityvillager1.setAgeRaw(6000);
|
||||
+ // CraftBukkit start - call EntityBreedEvent
|
||||
entityvillager2.setAgeRaw(-24000);
|
||||
entityvillager2.setPositionRotation(entityvillager.locX(), entityvillager.locY(), entityvillager.locZ(), 0.0F, 0.0F);
|
||||
- worldserver.addAllEntities(entityvillager2);
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(entityvillager2, entityvillager, entityvillager1, null, null, 0).isCancelled()) {
|
||||
+ return Optional.empty();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+ entityvillager.setAgeRaw(6000);
|
||||
+ entityvillager1.setAgeRaw(6000);
|
||||
+ worldserver.addAllEntities(entityvillager2, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason
|
||||
worldserver.broadcastEntityEffect(entityvillager2, (byte) 12);
|
||||
return Optional.of(entityvillager2);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue