aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/og/net/minecraft/world/entity/animal/EntityAnimal.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/og/net/minecraft/world/entity/animal/EntityAnimal.patch')
-rw-r--r--patch-remap/og/net/minecraft/world/entity/animal/EntityAnimal.patch101
1 files changed, 101 insertions, 0 deletions
diff --git a/patch-remap/og/net/minecraft/world/entity/animal/EntityAnimal.patch b/patch-remap/og/net/minecraft/world/entity/animal/EntityAnimal.patch
new file mode 100644
index 0000000000..f9b7960cb5
--- /dev/null
+++ b/patch-remap/og/net/minecraft/world/entity/animal/EntityAnimal.patch
@@ -0,0 +1,101 @@
+--- a/net/minecraft/world/entity/animal/EntityAnimal.java
++++ b/net/minecraft/world/entity/animal/EntityAnimal.java
+@@ -30,12 +30,19 @@
+ import net.minecraft.world.level.block.Blocks;
+ import net.minecraft.world.level.pathfinder.PathType;
+
++// CraftBukkit start
++import org.bukkit.craftbukkit.event.CraftEventFactory;
++import org.bukkit.event.entity.EntityBreedEvent;
++import org.bukkit.event.entity.EntityEnterLoveModeEvent;
++// CraftBukkit end
++
+ public abstract class EntityAnimal extends EntityAgeable {
+
+ protected static final int PARENT_AGE_AFTER_BREEDING = 6000;
+ public int inLove;
+ @Nullable
+ public UUID loveCause;
++ public ItemStack breedItem; // CraftBukkit - Add breedItem variable
+
+ protected EntityAnimal(EntityTypes<? extends EntityAnimal> entitytypes, World world) {
+ super(entitytypes, world);
+@@ -77,8 +84,13 @@
+ if (this.isInvulnerableTo(damagesource)) {
+ return false;
+ } else {
++ // CraftBukkit start
++ boolean result = super.hurt(damagesource, f);
++ if (result) {
+ this.inLove = 0;
+- return super.hurt(damagesource, f);
++ }
++ return result;
++ // CraftBukkit end
+ }
+ }
+
+@@ -172,10 +184,17 @@
+ }
+
+ public void setInLove(@Nullable EntityHuman entityhuman) {
+- this.inLove = 600;
++ // CraftBukkit start
++ EntityEnterLoveModeEvent entityEnterLoveModeEvent = CraftEventFactory.callEntityEnterLoveModeEvent(entityhuman, this, 600);
++ if (entityEnterLoveModeEvent.isCancelled()) {
++ return;
++ }
++ this.inLove = entityEnterLoveModeEvent.getTicksInLove();
++ // CraftBukkit end
+ if (entityhuman != null) {
+ this.loveCause = entityhuman.getUUID();
+ }
++ this.breedItem = entityhuman.getInventory().getSelected(); // CraftBukkit
+
+ this.level().broadcastEntityEvent(this, (byte) 18);
+ }
+@@ -217,12 +236,29 @@
+ if (entityageable != null) {
+ entityageable.setBaby(true);
+ entityageable.moveTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F);
+- this.finalizeSpawnChildFromBreeding(worldserver, entityanimal, entityageable);
+- worldserver.addFreshEntityWithPassengers(entityageable);
++ // CraftBukkit start - call EntityBreedEvent
++ EntityPlayer breeder = Optional.ofNullable(this.getLoveCause()).or(() -> {
++ return Optional.ofNullable(entityanimal.getLoveCause());
++ }).orElse(null);
++ int experience = this.getRandom().nextInt(7) + 1;
++ EntityBreedEvent entityBreedEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(entityageable, this, entityanimal, breeder, this.breedItem, experience);
++ if (entityBreedEvent.isCancelled()) {
++ return;
++ }
++ experience = entityBreedEvent.getExperience();
++ this.finalizeSpawnChildFromBreeding(worldserver, entityanimal, entityageable, experience);
++ worldserver.addFreshEntityWithPassengers(entityageable, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING);
++ // CraftBukkit end
+ }
+ }
+
+ public void finalizeSpawnChildFromBreeding(WorldServer worldserver, EntityAnimal entityanimal, @Nullable EntityAgeable entityageable) {
++ // CraftBukkit start
++ this.finalizeSpawnChildFromBreeding(worldserver, entityanimal, entityageable, this.getRandom().nextInt(7) + 1);
++ }
++
++ public void finalizeSpawnChildFromBreeding(WorldServer worldserver, EntityAnimal entityanimal, @Nullable EntityAgeable entityageable, int experience) {
++ // CraftBukkit end
+ Optional.ofNullable(this.getLoveCause()).or(() -> {
+ return Optional.ofNullable(entityanimal.getLoveCause());
+ }).ifPresent((entityplayer) -> {
+@@ -235,7 +271,11 @@
+ entityanimal.resetLove();
+ worldserver.broadcastEntityEvent(this, (byte) 18);
+ if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
+- worldserver.addFreshEntity(new EntityExperienceOrb(worldserver, this.getX(), this.getY(), this.getZ(), this.getRandom().nextInt(7) + 1));
++ // CraftBukkit start - use event experience
++ if (experience > 0) {
++ worldserver.addFreshEntity(new EntityExperienceOrb(worldserver, this.getX(), this.getY(), this.getZ(), experience));
++ }
++ // CraftBukkit end
+ }
+
+ }