2015-05-25 12:37:24 +02:00
|
|
|
--- a/net/minecraft/server/EntityAnimal.java
|
|
|
|
+++ b/net/minecraft/server/EntityAnimal.java
|
2019-04-23 04:00:00 +02:00
|
|
|
@@ -8,6 +8,7 @@
|
2019-06-21 12:00:00 +02:00
|
|
|
|
2019-04-23 04:00:00 +02:00
|
|
|
public int loveTicks;
|
2018-10-22 21:00:00 +02:00
|
|
|
public UUID breedCause;
|
2016-06-19 07:00:39 +02:00
|
|
|
+ public ItemStack breedItem; // CraftBukkit - Add breedItem variable
|
|
|
|
|
2019-04-23 04:00:00 +02:00
|
|
|
protected EntityAnimal(EntityTypes<? extends EntityAnimal> entitytypes, World world) {
|
2018-07-15 02:00:00 +02:00
|
|
|
super(entitytypes, world);
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -44,6 +45,9 @@
|
2014-12-09 15:40:38 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
+ /* CraftBukkit start
|
|
|
|
+ // Function disabled as it has no special function anymore after
|
|
|
|
+ // setSitting is disabled.
|
2019-04-23 04:00:00 +02:00
|
|
|
@Override
|
2014-12-09 15:40:38 +01:00
|
|
|
public boolean damageEntity(DamageSource damagesource, float f) {
|
|
|
|
if (this.isInvulnerable(damagesource)) {
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -53,6 +57,7 @@
|
2014-12-09 15:40:38 +01:00
|
|
|
return super.damageEntity(damagesource, f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+ // CraftBukkit end */
|
|
|
|
|
2019-04-23 04:00:00 +02:00
|
|
|
@Override
|
2018-07-15 02:00:00 +02:00
|
|
|
public float a(BlockPosition blockposition, IWorldReader iworldreader) {
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -147,6 +152,7 @@
|
2017-05-14 04:00:00 +02:00
|
|
|
if (entityhuman != null) {
|
2018-10-22 21:00:00 +02:00
|
|
|
this.breedCause = entityhuman.getUniqueID();
|
2017-05-14 04:00:00 +02:00
|
|
|
}
|
2016-06-19 07:00:39 +02:00
|
|
|
+ this.breedItem = entityhuman.inventory.getItemInHand(); // CraftBukkit
|
2017-05-14 04:00:00 +02:00
|
|
|
|
2016-06-19 07:00:39 +02:00
|
|
|
this.world.broadcastEntityEffect(this, (byte) 18);
|
|
|
|
}
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -186,11 +192,24 @@
|
|
|
|
EntityAgeable entityageable = this.createChild(entityanimal);
|
|
|
|
|
|
|
|
if (entityageable != null) {
|
|
|
|
+ // CraftBukkit start - set persistence for tame animals
|
|
|
|
+ if (entityageable instanceof EntityTameableAnimal && ((EntityTameableAnimal) entityageable).isTamed()) {
|
|
|
|
+ entityageable.persistent = true;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
EntityPlayer entityplayer = this.getBreedCause();
|
|
|
|
|
|
|
|
if (entityplayer == null && entityanimal.getBreedCause() != null) {
|
|
|
|
entityplayer = entityanimal.getBreedCause();
|
|
|
|
}
|
|
|
|
+ // CraftBukkit start - call EntityBreedEvent
|
|
|
|
+ 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()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ experience = entityBreedEvent.getExperience();
|
|
|
|
+ // CraftBukkit end
|
|
|
|
|
|
|
|
if (entityplayer != null) {
|
|
|
|
entityplayer.a(StatisticList.ANIMALS_BRED);
|
|
|
|
@@ -203,10 +222,14 @@
|
|
|
|
entityanimal.resetLove();
|
|
|
|
entityageable.a(true);
|
|
|
|
entityageable.setPositionRotation(this.locX(), this.locY(), this.locZ(), 0.0F, 0.0F);
|
|
|
|
- world.addEntity(entityageable);
|
|
|
|
+ world.addEntity(entityageable, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason
|
|
|
|
world.broadcastEntityEffect(this, (byte) 18);
|
|
|
|
if (world.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) {
|
|
|
|
- world.addEntity(new EntityExperienceOrb(world, this.locX(), this.locY(), this.locZ(), this.getRandom().nextInt(7) + 1));
|
|
|
|
+ // CraftBukkit start - use event experience
|
|
|
|
+ if (experience > 0) {
|
|
|
|
+ world.addEntity(new EntityExperienceOrb(world, this.locX(), this.locY(), this.locZ(), experience));
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|