2019-06-14 04:27:40 +02:00
|
|
|
From ed6de598138774849832bd9edef9d2a1fc71eab5 Mon Sep 17 00:00:00 2001
|
2018-08-24 16:40:14 +02:00
|
|
|
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
|
2019-06-06 17:36:57 +02:00
|
|
|
index 000000000..2638bbd3e
|
2018-08-24 16:40:14 +02:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/event/entity/SlimeChangeDirectionEvent.java
|
2019-03-20 01:28:15 +01:00
|
|
|
@@ -0,0 +1,38 @@
|
2018-08-24 16:40:14 +02:00
|
|
|
+package com.destroystokyo.paper.event.entity;
|
|
|
|
+
|
|
|
|
+import org.bukkit.entity.Slime;
|
|
|
|
+import org.bukkit.event.Cancellable;
|
2019-03-20 01:28:15 +01:00
|
|
|
+import org.jetbrains.annotations.NotNull;
|
2018-08-24 16:40:14 +02:00
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Fired when a Slime decides to change it's facing direction.
|
|
|
|
+ * <p>
|
|
|
|
+ * This event does not fire for the entity's actual movement. Only when it
|
|
|
|
+ * is choosing to change direction.
|
|
|
|
+ */
|
|
|
|
+public class SlimeChangeDirectionEvent extends SlimePathfindEvent implements Cancellable {
|
|
|
|
+ private float yaw;
|
|
|
|
+
|
2019-03-20 01:28:15 +01:00
|
|
|
+ public SlimeChangeDirectionEvent(@NotNull Slime slime, float yaw) {
|
2018-08-24 16:40:14 +02:00
|
|
|
+ super(slime);
|
|
|
|
+ this.yaw = yaw;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Get the new chosen yaw
|
|
|
|
+ *
|
|
|
|
+ * @return Chosen yaw
|
|
|
|
+ */
|
|
|
|
+ public float getNewYaw() {
|
|
|
|
+ return yaw;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 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
|
2019-06-06 17:36:57 +02:00
|
|
|
index 000000000..14b67da10
|
2018-08-24 16:40:14 +02:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/event/entity/SlimePathfindEvent.java
|
2019-03-20 01:28:15 +01:00
|
|
|
@@ -0,0 +1,53 @@
|
2018-08-24 16:40:14 +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;
|
2019-03-20 01:28:15 +01:00
|
|
|
+import org.jetbrains.annotations.NotNull;
|
2018-08-24 16:40:14 +02:00
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 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 {
|
2019-03-20 01:28:15 +01:00
|
|
|
+ public SlimePathfindEvent(@NotNull Slime slime) {
|
2018-08-24 16:40:14 +02:00
|
|
|
+ super(slime);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * The Slime that is pathfinding.
|
|
|
|
+ *
|
|
|
|
+ * @return The Slime that is pathfinding.
|
|
|
|
+ */
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull
|
2018-08-24 16:40:14 +02:00
|
|
|
+ public Slime getEntity() {
|
|
|
|
+ return (Slime) entity;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static final HandlerList handlers = new HandlerList();
|
|
|
|
+
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull
|
2018-08-24 16:40:14 +02:00
|
|
|
+ public HandlerList getHandlers() {
|
|
|
|
+ return handlers;
|
|
|
|
+ }
|
|
|
|
+
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull
|
2018-08-24 16:40:14 +02:00
|
|
|
+ public static HandlerList getHandlerList() {
|
|
|
|
+ return handlers;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private boolean cancelled = false;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean isCancelled() {
|
|
|
|
+ return cancelled;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void setCancelled(boolean cancel) {
|
|
|
|
+ cancelled = cancel;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
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
|
2019-06-06 17:36:57 +02:00
|
|
|
index 000000000..c8dd49d11
|
2018-08-24 16:40:14 +02:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/event/entity/SlimeSwimEvent.java
|
2019-03-20 01:28:15 +01:00
|
|
|
@@ -0,0 +1,17 @@
|
2018-08-24 16:40:14 +02:00
|
|
|
+package com.destroystokyo.paper.event.entity;
|
|
|
|
+
|
|
|
|
+import org.bukkit.entity.Slime;
|
|
|
|
+import org.bukkit.event.Cancellable;
|
2019-03-20 01:28:15 +01:00
|
|
|
+import org.jetbrains.annotations.NotNull;
|
2018-08-24 16:40:14 +02:00
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 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.
|
|
|
|
+ */
|
|
|
|
+public class SlimeSwimEvent extends SlimeWanderEvent implements Cancellable {
|
2019-03-20 01:28:15 +01:00
|
|
|
+ public SlimeSwimEvent(@NotNull Slime slime) {
|
2018-08-24 16:40:14 +02:00
|
|
|
+ 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
|
2019-06-06 17:36:57 +02:00
|
|
|
index 000000000..e9ba32799
|
2018-08-24 16:40:14 +02:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/event/entity/SlimeTargetLivingEntityEvent.java
|
2019-03-20 01:28:15 +01:00
|
|
|
@@ -0,0 +1,31 @@
|
2018-08-24 16:40:14 +02:00
|
|
|
+package com.destroystokyo.paper.event.entity;
|
|
|
|
+
|
|
|
|
+import org.bukkit.entity.LivingEntity;
|
|
|
|
+import org.bukkit.entity.Slime;
|
|
|
|
+import org.bukkit.event.Cancellable;
|
2019-03-20 01:28:15 +01:00
|
|
|
+import org.jetbrains.annotations.NotNull;
|
2018-08-24 16:40:14 +02:00
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 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.
|
|
|
|
+ */
|
|
|
|
+public class SlimeTargetLivingEntityEvent extends SlimePathfindEvent implements Cancellable {
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull private final LivingEntity target;
|
2018-08-24 16:40:14 +02:00
|
|
|
+
|
2019-03-20 01:28:15 +01:00
|
|
|
+ public SlimeTargetLivingEntityEvent(@NotNull Slime slime, @NotNull LivingEntity target) {
|
2018-08-24 16:40:14 +02:00
|
|
|
+ super(slime);
|
|
|
|
+ this.target = target;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Get the targeted entity
|
|
|
|
+ *
|
|
|
|
+ * @return Targeted entity
|
|
|
|
+ */
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull
|
2018-08-24 16:40:14 +02:00
|
|
|
+ public LivingEntity getTarget() {
|
|
|
|
+ return target;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
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
|
2019-06-06 17:36:57 +02:00
|
|
|
index 000000000..4683a7237
|
2018-08-24 16:40:14 +02:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/event/entity/SlimeWanderEvent.java
|
2019-03-20 01:28:15 +01:00
|
|
|
@@ -0,0 +1,17 @@
|
2018-08-24 16:40:14 +02:00
|
|
|
+package com.destroystokyo.paper.event.entity;
|
|
|
|
+
|
|
|
|
+import org.bukkit.entity.Slime;
|
|
|
|
+import org.bukkit.event.Cancellable;
|
2019-03-20 01:28:15 +01:00
|
|
|
+import org.jetbrains.annotations.NotNull;
|
2018-08-24 16:40:14 +02:00
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 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.
|
|
|
|
+ */
|
|
|
|
+public class SlimeWanderEvent extends SlimePathfindEvent implements Cancellable {
|
2019-03-20 01:28:15 +01:00
|
|
|
+ public SlimeWanderEvent(@NotNull Slime slime) {
|
2018-08-24 16:40:14 +02:00
|
|
|
+ super(slime);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
diff --git a/src/main/java/org/bukkit/entity/Slime.java b/src/main/java/org/bukkit/entity/Slime.java
|
2019-06-06 17:36:57 +02:00
|
|
|
index 1119e26e2..c4791f95d 100644
|
2018-08-24 16:40:14 +02:00
|
|
|
--- a/src/main/java/org/bukkit/entity/Slime.java
|
|
|
|
+++ b/src/main/java/org/bukkit/entity/Slime.java
|
2018-08-26 20:11:49 +02:00
|
|
|
@@ -14,4 +14,20 @@ public interface Slime extends Mob {
|
2018-08-24 16:40:14 +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
|
|
|
|
}
|
|
|
|
--
|
2019-03-20 01:28:15 +01:00
|
|
|
2.21.0
|
2018-08-24 16:40:14 +02:00
|
|
|
|