Minimise EntityFertilizeEggEvent and add sniffer (#9280)

This commit is contained in:
Bjarne Koll
2023-06-09 09:01:08 +02:00
parent 0bd83b4c4d
commit 3553730d51
2 changed files with 98 additions and 23 deletions

View File

@@ -23,8 +23,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.
+ * Called when two entities mate and the mating process results in a fertilization.
+ * Fertilization differs from normal breeding, as represented by the {@link org.bukkit.event.entity.EntityBreedEvent}, as
+ * it does not result in the immediate creation of the child entity in the world.
+ * <p>
+ * An example of this would be:
+ * <ul>
+ * <li>A frog being marked as "is_pregnant" and laying {@link org.bukkit.Material#FROGSPAWN} later.</li>
+ * <li>Sniffers producing the {@link org.bukkit.Material#SNIFFER_EGG} item, which needs to be placed before it can begin to hatch.</li>
+ * <li>A turtle being marked with "HasEgg" and laying a {@link org.bukkit.Material#TURTLE_EGG} later.</li>
+ * </ul>
+ *
+ * The event hence only exposes the two parent entities in the fertilization process and cannot provide the child entity, as it will only exist at a later point in time.
+ */
+public class EntityFertilizeEggEvent extends EntityEvent implements Cancellable {
+
@@ -58,9 +68,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+
+ /**
+ * Gets the parent creating this entity.
+ * Provides the entity in the fertilization process that will eventually be responsible for "creating" offspring,
+ * may that be by setting a block that later hatches or dropping an egg that has to be placed.
+ *
+ * @return The "birth" parent
+ * @return The "mother" entity.
+ */
+ @NotNull
+ public LivingEntity getMother() {
@@ -68,7 +79,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+
+ /**
+ * Gets the other parent of the newly born entity.
+ * Provides the "father" entity in the fertilization process that is not responsible for initiating the offspring
+ * creation.
+ *
+ * @return the other parent
+ */