mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-24 01:47:42 +01:00
2adb879802
This fixes a CRITICAL missing part of the Bukkit API due to mistakes on upstream refusing to implement the Sentient NPC baseclass of all NPC's. Until now, the Bukkit API has not provided a way for accessing and setting a non creature entities target. Although Flying, Slime, Ambient, and Water mobs all supported targets internally, you were unable to get/set it. Now with the SentientNPC API and these API's moved down, every sentient NPC has access to target data.
169 lines
7.3 KiB
Diff
169 lines
7.3 KiB
Diff
From 80cc0c18e993c665f6aaf581b65e6c627a4a5805 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Sat, 16 Jun 2018 13:41:00 -0400
|
|
Subject: [PATCH] Add SentientNPC Interface to Entities
|
|
|
|
Used to determine ACTUAL Living NPC's. Spigot mistakenly inversed the conditions for LivingEntity, and
|
|
used LivingEntity for Insentient Entities, and named the actual EntityLiving class EntityInsentient.
|
|
|
|
This should of all been inversed on the implementation side. To make matters worse, Spigot never
|
|
exposed the differentiator that there are entities with AI that are not sentient/alive such as
|
|
Armor stands and Players are the only things that do not implement the REAL EntityLiving class (named Insentient internally)
|
|
|
|
This interface lets you identify NPC entities capable of sentience, and able to move about and react to the world.
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/entity/SentientNPC.java b/src/main/java/com/destroystokyo/paper/entity/SentientNPC.java
|
|
new file mode 100644
|
|
index 00000000..7e393254
|
|
--- /dev/null
|
|
+++ b/src/main/java/com/destroystokyo/paper/entity/SentientNPC.java
|
|
@@ -0,0 +1,57 @@
|
|
+/*
|
|
+ * Copyright (c) 2018 Daniel Ennis (Aikar) MIT License
|
|
+ *
|
|
+ * Permission is hereby granted, free of charge, to any person obtaining
|
|
+ * a copy of this software and associated documentation files (the
|
|
+ * "Software"), to deal in the Software without restriction, including
|
|
+ * without limitation the rights to use, copy, modify, merge, publish,
|
|
+ * distribute, sublicense, and/or sell copies of the Software, and to
|
|
+ * permit persons to whom the Software is furnished to do so, subject to
|
|
+ * the following conditions:
|
|
+ *
|
|
+ * The above copyright notice and this permission notice shall be
|
|
+ * included in all copies or substantial portions of the Software.
|
|
+ *
|
|
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
+ */
|
|
+
|
|
+package com.destroystokyo.paper.entity;
|
|
+
|
|
+import org.bukkit.entity.LivingEntity;
|
|
+
|
|
+/**
|
|
+ * Used to determine ACTUAL Living NPC's. Spigot mistakenly inversed the conditions for LivingEntity, and
|
|
+ * used LivingEntity for Insentient Entities, and named the actual EntityLiving class EntityInsentient.
|
|
+ *
|
|
+ * This should of all been inversed on the implementation side. To make matters worse, Spigot never
|
|
+ * exposed the differentiator that there are entities with AI that are not sentient/alive such as
|
|
+ * Armor stands and Players are the only things that do not implement the REAL EntityLiving class (named Insentient internally)
|
|
+ *
|
|
+ * This interface lets you identify NPC entities capable of sentience, and able to move about and react to the world.
|
|
+ */
|
|
+public interface SentientNPC extends LivingEntity {
|
|
+
|
|
+ /**
|
|
+ * Instructs this Creature to set the specified LivingEntity as its
|
|
+ * target.
|
|
+ * <p>
|
|
+ * Hostile creatures may attack their target, and friendly creatures may
|
|
+ * follow their target.
|
|
+ *
|
|
+ * @param target New LivingEntity to target, or null to clear the target
|
|
+ */
|
|
+ public void setTarget(LivingEntity target);
|
|
+
|
|
+ /**
|
|
+ * Gets the current target of this Creature
|
|
+ *
|
|
+ * @return Current target of this creature, or null if none exists
|
|
+ */
|
|
+ public LivingEntity getTarget();
|
|
+}
|
|
diff --git a/src/main/java/org/bukkit/entity/Ambient.java b/src/main/java/org/bukkit/entity/Ambient.java
|
|
index 779e3897..ef548fb4 100644
|
|
--- a/src/main/java/org/bukkit/entity/Ambient.java
|
|
+++ b/src/main/java/org/bukkit/entity/Ambient.java
|
|
@@ -3,4 +3,5 @@ package org.bukkit.entity;
|
|
/**
|
|
* Represents an ambient mob
|
|
*/
|
|
-public interface Ambient extends LivingEntity {}
|
|
+public interface Ambient extends LivingEntity, com.destroystokyo.paper.entity.SentientNPC { // Paper
|
|
+}
|
|
diff --git a/src/main/java/org/bukkit/entity/ComplexLivingEntity.java b/src/main/java/org/bukkit/entity/ComplexLivingEntity.java
|
|
index f74411c3..1f00923e 100644
|
|
--- a/src/main/java/org/bukkit/entity/ComplexLivingEntity.java
|
|
+++ b/src/main/java/org/bukkit/entity/ComplexLivingEntity.java
|
|
@@ -6,7 +6,7 @@ import java.util.Set;
|
|
* Represents a complex living entity - one that is made up of various smaller
|
|
* parts
|
|
*/
|
|
-public interface ComplexLivingEntity extends LivingEntity {
|
|
+public interface ComplexLivingEntity extends LivingEntity, com.destroystokyo.paper.entity.SentientNPC { // Paper
|
|
/**
|
|
* Gets a list of parts that belong to this complex entity
|
|
*
|
|
diff --git a/src/main/java/org/bukkit/entity/Creature.java b/src/main/java/org/bukkit/entity/Creature.java
|
|
index f223f55b..bbfb248e 100644
|
|
--- a/src/main/java/org/bukkit/entity/Creature.java
|
|
+++ b/src/main/java/org/bukkit/entity/Creature.java
|
|
@@ -4,7 +4,7 @@ package org.bukkit.entity;
|
|
* Represents a Creature. Creatures are non-intelligent monsters or animals
|
|
* which have very simple abilities.
|
|
*/
|
|
-public interface Creature extends LivingEntity {
|
|
+public interface Creature extends LivingEntity, com.destroystokyo.paper.entity.SentientNPC { // Paper
|
|
|
|
/**
|
|
* Instructs this Creature to set the specified LivingEntity as its
|
|
@@ -15,12 +15,12 @@ public interface Creature extends LivingEntity {
|
|
*
|
|
* @param target New LivingEntity to target, or null to clear the target
|
|
*/
|
|
- public void setTarget(LivingEntity target);
|
|
+ //public void setTarget(LivingEntity target); // Paper - moved to SentientNPC
|
|
|
|
/**
|
|
* Gets the current target of this Creature
|
|
*
|
|
* @return Current target of this creature, or null if none exists
|
|
*/
|
|
- public LivingEntity getTarget();
|
|
+ //public LivingEntity getTarget(); // Paper - moved to SentientNPC
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/entity/Flying.java b/src/main/java/org/bukkit/entity/Flying.java
|
|
index 4f16a26c..207e9922 100644
|
|
--- a/src/main/java/org/bukkit/entity/Flying.java
|
|
+++ b/src/main/java/org/bukkit/entity/Flying.java
|
|
@@ -3,4 +3,6 @@ package org.bukkit.entity;
|
|
/**
|
|
* Represents a Flying Entity.
|
|
*/
|
|
-public interface Flying extends LivingEntity {}
|
|
+public interface Flying extends LivingEntity, com.destroystokyo.paper.entity.SentientNPC { // Paper
|
|
+
|
|
+}
|
|
diff --git a/src/main/java/org/bukkit/entity/Slime.java b/src/main/java/org/bukkit/entity/Slime.java
|
|
index 0d87d203..d4eee19c 100644
|
|
--- a/src/main/java/org/bukkit/entity/Slime.java
|
|
+++ b/src/main/java/org/bukkit/entity/Slime.java
|
|
@@ -3,7 +3,7 @@ package org.bukkit.entity;
|
|
/**
|
|
* Represents a Slime.
|
|
*/
|
|
-public interface Slime extends LivingEntity {
|
|
+public interface Slime extends LivingEntity, com.destroystokyo.paper.entity.SentientNPC { // Paper
|
|
|
|
/**
|
|
* @return The size of the slime
|
|
diff --git a/src/main/java/org/bukkit/entity/WaterMob.java b/src/main/java/org/bukkit/entity/WaterMob.java
|
|
index 3e89ca0c..8d105e72 100644
|
|
--- a/src/main/java/org/bukkit/entity/WaterMob.java
|
|
+++ b/src/main/java/org/bukkit/entity/WaterMob.java
|
|
@@ -3,4 +3,5 @@ package org.bukkit.entity;
|
|
/**
|
|
* Represents a Water Mob
|
|
*/
|
|
-public interface WaterMob extends LivingEntity {}
|
|
+public interface WaterMob extends LivingEntity, com.destroystokyo.paper.entity.SentientNPC { // Paper
|
|
+}
|
|
--
|
|
2.18.0
|
|
|