aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/animal/Animal.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/animal/Animal.java.patch')
-rw-r--r--patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/animal/Animal.java.patch121
1 files changed, 121 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/animal/Animal.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/animal/Animal.java.patch
new file mode 100644
index 0000000000..f5e68c0a52
--- /dev/null
+++ b/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/animal/Animal.java.patch
@@ -0,0 +1,121 @@
+--- a/net/minecraft/world/entity/animal/Animal.java
++++ b/net/minecraft/world/entity/animal/Animal.java
+@@ -29,12 +29,18 @@
+ import net.minecraft.world.level.LevelReader;
+ import net.minecraft.world.level.block.Blocks;
+ import net.minecraft.world.level.pathfinder.BlockPathTypes;
++// 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 Animal extends AgeableMob {
+ protected static final int PARENT_AGE_AFTER_BREEDING = 6000;
+ private int inLove;
+ @Nullable
+- private UUID loveCause;
++ public UUID loveCause;
++ public ItemStack breedItem; // CraftBukkit - Add breedItem variable
+
+ protected Animal(EntityType<? extends Animal> entityType, Level level) {
+ super(entityType, level);
+@@ -74,8 +83,13 @@
+ if (this.isInvulnerableTo(source)) {
+ return false;
+ } else {
++ // CraftBukkit start
++ boolean result = super.hurt(source, amount);
++ if (result) {
+ this.inLove = 0;
+- return super.hurt(source, amount);
++ }
++ return result;
++ // CraftBukkit end
+ }
+ }
+
+@@ -166,10 +183,17 @@
+ }
+
+ public void setInLove(@Nullable Player player) {
+- this.inLove = 600;
++ // CraftBukkit start
++ EntityEnterLoveModeEvent entityEnterLoveModeEvent = CraftEventFactory.callEntityEnterLoveModeEvent(player, this, 600);
++ if (entityEnterLoveModeEvent.isCancelled()) {
++ return;
++ }
++ this.inLove = entityEnterLoveModeEvent.getTicksInLove();
++ // CraftBukkit end
+ if (player != null) {
+ this.loveCause = player.getUUID();
+ }
++ this.breedItem = player.getInventory().getSelected(); // CraftBukkit
+
+ this.level().broadcastEntityEvent(this, (byte)18);
+ }
+@@ -205,27 +230,51 @@
+ }
+
+ public void spawnChildFromBreeding(ServerLevel level, Animal mate) {
+- AgeableMob breedOffspring = this.getBreedOffspring(level, mate);
+- if (breedOffspring != null) {
+- breedOffspring.setBaby(true);
+- breedOffspring.moveTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F);
+- this.finalizeSpawnChildFromBreeding(level, mate, breedOffspring);
+- level.addFreshEntityWithPassengers(breedOffspring);
++ AgeableMob entityageable = this.getBreedOffspring(level, mate);
++
++ if (entityageable != null) {
++ entityageable.setBaby(true);
++ entityageable.moveTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F);
++ // CraftBukkit start - call EntityBreedEvent
++ ServerPlayer breeder = Optional.ofNullable(this.getLoveCause()).or(() -> {
++ return Optional.ofNullable(mate.getLoveCause());
++ }).orElse(null);
++ int experience = this.getRandom().nextInt(7) + 1;
++ EntityBreedEvent entityBreedEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(entityageable, this, mate, breeder, this.breedItem, experience);
++ if (entityBreedEvent.isCancelled()) {
++ return;
++ }
++ experience = entityBreedEvent.getExperience();
++ this.finalizeSpawnChildFromBreeding(level, mate, entityageable, experience);
++ level.addFreshEntityWithPassengers(entityageable, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING);
++ // CraftBukkit end
+ }
+ }
+
+ public void finalizeSpawnChildFromBreeding(ServerLevel level, Animal animal, @Nullable AgeableMob baby) {
+- Optional.ofNullable(this.getLoveCause()).or(() -> Optional.ofNullable(animal.getLoveCause())).ifPresent(player -> {
+- player.awardStat(Stats.ANIMALS_BRED);
+- CriteriaTriggers.BRED_ANIMALS.trigger(player, this, animal, baby);
++ // CraftBukkit start
++ this.finalizeSpawnChildFromBreeding(level, animal, baby, this.getRandom().nextInt(7) + 1);
++ }
++
++ public void finalizeSpawnChildFromBreeding(ServerLevel worldserver, Animal entityanimal, @Nullable AgeableMob entityageable, int experience) {
++ // CraftBukkit end
++ Optional.ofNullable(this.getLoveCause()).or(() -> {
++ return Optional.ofNullable(entityanimal.getLoveCause());
++ }).ifPresent((entityplayer) -> {
++ entityplayer.awardStat(Stats.ANIMALS_BRED);
++ CriteriaTriggers.BRED_ANIMALS.trigger(entityplayer, this, entityanimal, entityageable);
+ });
+ this.setAge(6000);
+ animal.setAge(6000);
+ this.resetLove();
+- animal.resetLove();
+- level.broadcastEntityEvent(this, (byte)18);
+- if (level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
+- level.addFreshEntity(new ExperienceOrb(level, this.getX(), this.getY(), this.getZ(), this.getRandom().nextInt(7) + 1));
++ entityanimal.resetLove();
++ worldserver.broadcastEntityEvent(this, (byte) 18);
++ if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
++ // CraftBukkit start - use event experience
++ if (experience > 0) {
++ worldserver.addFreshEntity(new ExperienceOrb(worldserver, this.getX(), this.getY(), this.getZ(), experience));
++ }
++ // CraftBukkit end
+ }
+ }
+