mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-22 10:35:38 +01:00
0e7361704a
Updated Upstream (Bukkit/CraftBukkit/Spigot) Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 4068c6aa PR-1053: Change docs for max power in FireworkMeta 6b3c241b SPIGOT-7783, SPIGOT-7784, PR-1051: Add Trial Vault & Spawner event API 5fe300ec PR-1052: Fix broken links and minor improvement for checkstyle.xml CraftBukkit Changes: 7548afcf2 SPIGOT-7872: Fix crash with event-modified teleports 93480d5d6 SPIGOT-7868, PR-1463: Fix default and max power in FireworkMeta 5060d1a84 SPIGOT-7783, SPIGOT-7784, PR-1460: Add Trial Vault & Spawner event API 11dfcae71 PR-1462: Fix broken links and minor improvement for checkstyle.xml Spigot Changes: ca581228 Rebuild patches
104 lines
6.7 KiB
Diff
104 lines
6.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com>
|
|
Date: Fri, 24 Jun 2022 12:39:34 +0200
|
|
Subject: [PATCH] Add EntityFertilizeEggEvent
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/Turtle.java b/src/main/java/net/minecraft/world/entity/animal/Turtle.java
|
|
index 34e6bf677a9f4548f3febe6d57e6af9602530271..2e5ef2a680e294b49f29e8d7ba8bd0ed023c393c 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/animal/Turtle.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/animal/Turtle.java
|
|
@@ -441,6 +441,10 @@ public class Turtle extends Animal {
|
|
if (entityplayer == null && this.partner.getLoveCause() != null) {
|
|
entityplayer = this.partner.getLoveCause();
|
|
}
|
|
+ // Paper start - Add EntityFertilizeEggEvent event
|
|
+ io.papermc.paper.event.entity.EntityFertilizeEggEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityFertilizeEggEvent(this.animal, this.partner);
|
|
+ if (event.isCancelled()) return;
|
|
+ // Paper end - Add EntityFertilizeEggEvent event
|
|
|
|
if (entityplayer != null) {
|
|
entityplayer.awardStat(Stats.ANIMALS_BRED);
|
|
@@ -455,7 +459,7 @@ public class Turtle extends Animal {
|
|
RandomSource randomsource = this.animal.getRandom();
|
|
|
|
if (this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
|
|
- this.level.addFreshEntity(new ExperienceOrb(this.level, this.animal.getX(), this.animal.getY(), this.animal.getZ(), randomsource.nextInt(7) + 1, org.bukkit.entity.ExperienceOrb.SpawnReason.BREED, entityplayer)); // Paper;
|
|
+ if (event.getExperience() > 0) this.level.addFreshEntity(new ExperienceOrb(this.level, this.animal.getX(), this.animal.getY(), this.animal.getZ(), event.getExperience(), org.bukkit.entity.ExperienceOrb.SpawnReason.BREED, entityplayer)); // Paper - Add EntityFertilizeEggEvent event
|
|
}
|
|
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java b/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java
|
|
index a7af50ebc17abd829a7254c03785206da9624060..816977990639ec0559b652fc9666afd5046f0a5d 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java
|
|
@@ -261,7 +261,12 @@ public class Frog extends Animal implements VariantHolder<Holder<FrogVariant>> {
|
|
|
|
@Override
|
|
public void spawnChildFromBreeding(ServerLevel world, Animal other) {
|
|
- this.finalizeSpawnChildFromBreeding(world, other, null);
|
|
+ // Paper start - Add EntityFertilizeEggEvent event
|
|
+ final io.papermc.paper.event.entity.EntityFertilizeEggEvent result = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityFertilizeEggEvent(this, other);
|
|
+ if (result.isCancelled()) return;
|
|
+
|
|
+ this.finalizeSpawnChildFromBreeding(world, other, null, result.getExperience()); // Paper - use craftbukkit call that takes experience amount
|
|
+ // Paper end - Add EntityFertilizeEggEvent event
|
|
this.getBrain().setMemory(MemoryModuleType.IS_PREGNANT, Unit.INSTANCE);
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java b/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java
|
|
index d34d8fe70379dcad9540739ec0ae1c94f01fc46b..fadd341ff398886a4da102eefa1beb95a63bbd6d 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java
|
|
@@ -345,11 +345,16 @@ public class Sniffer extends Animal {
|
|
|
|
@Override
|
|
public void spawnChildFromBreeding(ServerLevel world, Animal other) {
|
|
+ // Paper start - Add EntityFertilizeEggEvent event
|
|
+ final io.papermc.paper.event.entity.EntityFertilizeEggEvent result = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityFertilizeEggEvent(this, other);
|
|
+ if (result.isCancelled()) return;
|
|
+ // Paper end - Add EntityFertilizeEggEvent event
|
|
+
|
|
ItemStack itemstack = new ItemStack(Items.SNIFFER_EGG);
|
|
ItemEntity entityitem = new ItemEntity(world, this.position().x(), this.position().y(), this.position().z(), itemstack);
|
|
|
|
entityitem.setDefaultPickUpDelay();
|
|
- this.finalizeSpawnChildFromBreeding(world, other, (AgeableMob) null);
|
|
+ this.finalizeSpawnChildFromBreeding(world, other, (AgeableMob) null, result.getExperience()); // Paper - Add EntityFertilizeEggEvent event
|
|
if (this.spawnAtLocation(entityitem) != null) { // Paper - Call EntityDropItemEvent
|
|
this.playSound(SoundEvents.SNIFFER_EGG_PLOP, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 0.5F);
|
|
} // Paper - Call EntityDropItemEvent
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
index e1e5a195c2a415d214c5bf8a2364835f7332751b..2eb6080c92b2557c77d826300db5104db830bc7f 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
@@ -2197,4 +2197,28 @@ public class CraftEventFactory {
|
|
return event.callEvent();
|
|
}
|
|
// Paper end
|
|
+
|
|
+ // Paper start - add EntityFertilizeEggEvent
|
|
+ /**
|
|
+ * Calls the {@link io.papermc.paper.event.entity.EntityFertilizeEggEvent}.
|
|
+ * If the event is cancelled, this method also resets the love on both the {@code breeding} and {@code other} entity.
|
|
+ *
|
|
+ * @param breeding the entity on which #spawnChildFromBreeding was called.
|
|
+ * @param other the partner of the entity.
|
|
+ * @return the event after it was called. The instance may be used to retrieve the experience of the event.
|
|
+ */
|
|
+ public static io.papermc.paper.event.entity.EntityFertilizeEggEvent callEntityFertilizeEggEvent(Animal breeding, Animal other) {
|
|
+ ServerPlayer serverPlayer = breeding.getLoveCause();
|
|
+ if (serverPlayer == null) serverPlayer = other.getLoveCause();
|
|
+ final int experience = breeding.getRandom().nextInt(7) + 1; // From Animal#spawnChildFromBreeding(ServerLevel, Animal)
|
|
+
|
|
+ final io.papermc.paper.event.entity.EntityFertilizeEggEvent event = new io.papermc.paper.event.entity.EntityFertilizeEggEvent((LivingEntity) breeding.getBukkitEntity(), (LivingEntity) other.getBukkitEntity(), serverPlayer == null ? null : serverPlayer.getBukkitEntity(), breeding.breedItem == null ? null : CraftItemStack.asCraftMirror(breeding.breedItem).clone(), experience);
|
|
+ if (!event.callEvent()) {
|
|
+ breeding.resetLove();
|
|
+ other.resetLove(); // stop the pathfinding to avoid infinite loop
|
|
+ }
|
|
+
|
|
+ return event;
|
|
+ }
|
|
+ // Paper end - add EntityFertilizeEggEvent
|
|
}
|