Paper/patches/api/0417-Add-EntityFertilizeEggEvent.patch
Jake Potrebic 4e994669d3
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#8874)
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:
6b3c598b PR-814: Add a method to send multiple equipment changes
181a984b Update Maven shade version to align with CraftBukkit
a5a36e32 Revert "Update Maven shade version to align with CraftBukkit"
7a8f4a42 Update Maven shade version to align with CraftBukkit
58327201 Add support for Java 20

CraftBukkit Changes:
b56426c7a PR-1142: Calculate explosion damage separately for each affected EntityComplexPart
fbe3410af PR-1140: Add a method to send multiple equipment changes
8434e3633 Add support for Java 20
c998a1d23 Increase outdated build delay
4a929b5d6 SPIGOT-7267: Fix EntityType#getTranslationKey() and add unit test
086d8dc8a SPIGOT-7268: CraftMetaPotion reads ShowParticles and ShowIcon properties incorrectly
8ba5e399e SPIGOT-7262: Improve visibility API

Spigot Changes:
a2190e30 Rebuild patches
2023-03-10 12:18:50 -08:00

141 Zeilen
3.9 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com>
Date: Fri, 24 Jun 2022 11:56:32 +0200
Subject: [PATCH] Add EntityFertilizeEggEvent
diff --git a/src/main/java/io/papermc/paper/event/entity/EntityFertilizeEggEvent.java b/src/main/java/io/papermc/paper/event/entity/EntityFertilizeEggEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..159b3b541991be34a5db856e3706a97afc8afb3d
--- /dev/null
+++ b/src/main/java/io/papermc/paper/event/entity/EntityFertilizeEggEvent.java
@@ -0,0 +1,128 @@
+package io.papermc.paper.event.entity;
+
+import com.google.common.base.Preconditions;
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent;
+import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Called when a mating occurs that results in a pregnancy.
+ * After a bit of time, the mother will lay an egg.
+ */
+public class EntityFertilizeEggEvent extends EntityEvent implements Cancellable {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private final LivingEntity mother;
+ private final LivingEntity father;
+ private final Player breeder;
+ private final ItemStack bredWith;
+ private int experience;
+
+ private boolean cancel;
+
+ public EntityFertilizeEggEvent(@NotNull LivingEntity mother, @NotNull LivingEntity father, @Nullable Player breeder, @Nullable ItemStack bredWith, int experience) {
+ super(mother);
+ Preconditions.checkArgument(mother != null, "Cannot have null mother");
+ Preconditions.checkArgument(father != null, "Cannot have null father");
+
+ // Breeder can be null in the case of spontaneous conception
+ this.mother = mother;
+ this.father = father;
+ this.breeder = breeder;
+ this.bredWith = bredWith;
+ this.experience = experience;
+ }
+
+ @NotNull
+ @Override
+ public LivingEntity getEntity() {
+ return (LivingEntity) entity;
+ }
+
+ /**
+ * Gets the parent creating this entity.
+ *
+ * @return The "birth" parent
+ */
+ @NotNull
+ public LivingEntity getMother() {
+ return mother;
+ }
+
+ /**
+ * Gets the other parent of the newly born entity.
+ *
+ * @return the other parent
+ */
+ @NotNull
+ public LivingEntity getFather() {
+ return father;
+ }
+
+ /**
+ * Gets the Entity responsible for fertilization. Breeder is null for spontaneous
+ * conception.
+ *
+ * @return The Entity who initiated breeding.
+ */
+ @Nullable
+ public Player getBreeder() {
+ return breeder;
+ }
+
+ /**
+ * The ItemStack that was used to initiate fertilization, if present.
+ *
+ * @return ItemStack used to initiate breeding.
+ */
+ @Nullable
+ public ItemStack getBredWith() {
+ return bredWith;
+ }
+
+ /**
+ * Get the amount of experience granted by fertilization.
+ *
+ * @return experience amount
+ */
+ public int getExperience() {
+ return experience;
+ }
+
+ /**
+ * Set the amount of experience granted by fertilization.
+ * If the amount is negative or zero, no experience will be dropped.
+ *
+ * @param experience experience amount
+ */
+ public void setExperience(int experience) {
+ this.experience = experience;
+ }
+
+ @Override
+ public boolean isCancelled() {
+ return cancel;
+ }
+
+ @Override
+ public void setCancelled(boolean cancel) {
+ this.cancel = cancel;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ }
+}