3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-15 19:10:09 +01:00
Paper/patches/api/0133-Slime-Pathfinder-Events.patch

229 Zeilen
7.1 KiB
Diff

2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: BillyGalbreath <Blake.Galbreath@GMail.com>
Date: Fri, 24 Aug 2018 08:18:27 -0500
Subject: [PATCH] Slime Pathfinder Events
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/SlimeChangeDirectionEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/SlimeChangeDirectionEvent.java
new file mode 100644
2024-02-01 10:15:57 +01:00
index 0000000000000000000000000000000000000000..30864539574e23bbe9e4c5dc73ad6614de782ac2
2021-06-11 14:02:28 +02:00
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/SlimeChangeDirectionEvent.java
2024-02-01 10:15:57 +01:00
@@ -0,0 +1,40 @@
2021-06-11 14:02:28 +02:00
+package com.destroystokyo.paper.event.entity;
+
+import org.bukkit.entity.Slime;
2024-02-01 10:15:57 +01:00
+import org.jetbrains.annotations.ApiStatus;
2021-06-11 14:02:28 +02:00
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Fired when a Slime decides to change its facing direction.
2021-06-11 14:02:28 +02:00
+ * <p>
+ * This event does not fire for the entity's actual movement. Only when it
+ * is choosing to change direction.
+ */
2024-02-01 10:15:57 +01:00
+public class SlimeChangeDirectionEvent extends SlimePathfindEvent {
+
2021-06-11 14:02:28 +02:00
+ private float yaw;
+
2024-02-01 10:15:57 +01:00
+ @ApiStatus.Internal
2021-06-11 14:02:28 +02:00
+ public SlimeChangeDirectionEvent(@NotNull Slime slime, float yaw) {
+ super(slime);
+ this.yaw = yaw;
+ }
+
+ /**
+ * Get the new chosen yaw
+ *
+ * @return Chosen yaw
+ */
+ public float getNewYaw() {
2024-02-01 10:15:57 +01:00
+ return this.yaw;
2021-06-11 14:02:28 +02:00
+ }
+
+ /**
+ * Set the new chosen yaw
+ *
+ * @param yaw Chosen yaw
+ */
+ public void setNewYaw(float yaw) {
+ this.yaw = yaw;
+ }
+}
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/SlimePathfindEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/SlimePathfindEvent.java
new file mode 100644
2024-02-01 10:15:57 +01:00
index 0000000000000000000000000000000000000000..706ed85a5415d688aaa5f138cbf583b9e2bab27d
2021-06-11 14:02:28 +02:00
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/SlimePathfindEvent.java
2024-02-01 10:15:57 +01:00
@@ -0,0 +1,56 @@
2021-06-11 14:02:28 +02:00
+package com.destroystokyo.paper.event.entity;
+
+import org.bukkit.entity.Slime;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent;
2024-02-01 10:15:57 +01:00
+import org.jetbrains.annotations.ApiStatus;
2021-06-11 14:02:28 +02:00
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Fired when a Slime decides to start pathfinding.
+ * <p>
+ * This event does not fire for the entity's actual movement. Only when it
+ * is choosing to start moving.
+ */
+public class SlimePathfindEvent extends EntityEvent implements Cancellable {
2024-02-01 10:15:57 +01:00
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private boolean cancelled;
+
+ @ApiStatus.Internal
2021-06-11 14:02:28 +02:00
+ public SlimePathfindEvent(@NotNull Slime slime) {
+ super(slime);
+ }
+
+ /**
+ * The Slime that is pathfinding.
+ *
+ * @return The Slime that is pathfinding.
+ */
+ @NotNull
+ public Slime getEntity() {
2024-02-01 10:15:57 +01:00
+ return (Slime) super.getEntity();
+ }
+
+ @Override
+ public boolean isCancelled() {
+ return this.cancelled;
2021-06-11 14:02:28 +02:00
+ }
+
2024-02-01 10:15:57 +01:00
+ @Override
+ public void setCancelled(boolean cancel) {
+ this.cancelled = cancel;
+ }
2021-06-11 14:02:28 +02:00
+
+ @NotNull
+ public HandlerList getHandlers() {
2024-02-01 10:15:57 +01:00
+ return HANDLER_LIST;
2021-06-11 14:02:28 +02:00
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
2024-02-01 10:15:57 +01:00
+ return HANDLER_LIST;
2021-06-11 14:02:28 +02:00
+ }
+}
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/SlimeSwimEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/SlimeSwimEvent.java
new file mode 100644
2024-02-01 10:15:57 +01:00
index 0000000000000000000000000000000000000000..65e8a29751e338b0f0acda7bef9e014852a73e6e
2021-06-11 14:02:28 +02:00
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/SlimeSwimEvent.java
2024-02-01 10:15:57 +01:00
@@ -0,0 +1,19 @@
2021-06-11 14:02:28 +02:00
+package com.destroystokyo.paper.event.entity;
+
+import org.bukkit.entity.Slime;
2024-02-01 10:15:57 +01:00
+import org.jetbrains.annotations.ApiStatus;
2021-06-11 14:02:28 +02:00
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Fired when a Slime decides to start jumping while swimming in water/lava.
+ * <p>
+ * This event does not fire for the entity's actual movement. Only when it
+ * is choosing to start jumping.
+ */
2024-02-01 10:15:57 +01:00
+public class SlimeSwimEvent extends SlimeWanderEvent {
+
+ @ApiStatus.Internal
2021-06-11 14:02:28 +02:00
+ public SlimeSwimEvent(@NotNull Slime slime) {
+ super(slime);
+ }
+}
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/SlimeTargetLivingEntityEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/SlimeTargetLivingEntityEvent.java
new file mode 100644
2024-02-01 10:15:57 +01:00
index 0000000000000000000000000000000000000000..87c64b04dfec232e98361c3ec29da7664498c65b
2021-06-11 14:02:28 +02:00
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/SlimeTargetLivingEntityEvent.java
2024-02-01 10:15:57 +01:00
@@ -0,0 +1,33 @@
2021-06-11 14:02:28 +02:00
+package com.destroystokyo.paper.event.entity;
+
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.entity.Slime;
2024-02-01 10:15:57 +01:00
+import org.jetbrains.annotations.ApiStatus;
2021-06-11 14:02:28 +02:00
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Fired when a Slime decides to change direction to target a LivingEntity.
+ * <p>
+ * This event does not fire for the entity's actual movement. Only when it
+ * is choosing to start moving.
+ */
2024-02-01 10:15:57 +01:00
+public class SlimeTargetLivingEntityEvent extends SlimePathfindEvent {
+
2021-06-11 14:02:28 +02:00
+ @NotNull private final LivingEntity target;
+
2024-02-01 10:15:57 +01:00
+ @ApiStatus.Internal
2021-06-11 14:02:28 +02:00
+ public SlimeTargetLivingEntityEvent(@NotNull Slime slime, @NotNull LivingEntity target) {
+ super(slime);
+ this.target = target;
+ }
+
+ /**
+ * Get the targeted entity
+ *
+ * @return Targeted entity
+ */
+ @NotNull
+ public LivingEntity getTarget() {
2024-02-01 10:15:57 +01:00
+ return this.target;
2021-06-11 14:02:28 +02:00
+ }
+}
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/SlimeWanderEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/SlimeWanderEvent.java
new file mode 100644
2024-02-01 10:15:57 +01:00
index 0000000000000000000000000000000000000000..2ad9cc1673ffbb8b48349e461d1154d1d4ec2874
2021-06-11 14:02:28 +02:00
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/SlimeWanderEvent.java
2024-02-01 10:15:57 +01:00
@@ -0,0 +1,19 @@
2021-06-11 14:02:28 +02:00
+package com.destroystokyo.paper.event.entity;
+
+import org.bukkit.entity.Slime;
2024-02-01 10:15:57 +01:00
+import org.jetbrains.annotations.ApiStatus;
2021-06-11 14:02:28 +02:00
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Fired when a Slime decides to start wandering.
+ * <p>
+ * This event does not fire for the entity's actual movement. Only when it
+ * is choosing to start moving.
+ */
2024-02-01 10:15:57 +01:00
+public class SlimeWanderEvent extends SlimePathfindEvent {
+
+ @ApiStatus.Internal
2021-06-11 14:02:28 +02:00
+ public SlimeWanderEvent(@NotNull Slime slime) {
+ super(slime);
+ }
+}
diff --git a/src/main/java/org/bukkit/entity/Slime.java b/src/main/java/org/bukkit/entity/Slime.java
index bfac874840cf1f36afba16ae4d176c5821a68cfb..335b92e7be49ae13b2a1140183650642063a4219 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/entity/Slime.java
+++ b/src/main/java/org/bukkit/entity/Slime.java
@@ -24,4 +24,20 @@ public interface Slime extends Mob, Enemy {
2021-06-11 14:02:28 +02:00
* @param sz The new size of the slime.
*/
public void setSize(int sz);
+
+ // Paper start
+ /**
+ * Get whether this slime can randomly wander/jump around on its own
+ *
+ * @return true if can wander
+ */
+ public boolean canWander();
+
+ /**
+ * Set whether this slime can randomly wander/jump around on its own
+ *
+ * @param canWander true if can wander
+ */
+ public void setWander(boolean canWander);
+ // Paper end
}