mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-23 11:06:29 +01:00
Add Entity#fromMobSpawner API
Merges and closes GH-752
This commit is contained in:
parent
014578a73b
commit
e0e23db485
26
Spigot-API-Patches/0060-Entity-fromMobSpawner.patch
Normal file
26
Spigot-API-Patches/0060-Entity-fromMobSpawner.patch
Normal file
@ -0,0 +1,26 @@
|
||||
From e694e778d2f5ac074f8e76ae11fb181d762d8c32 Mon Sep 17 00:00:00 2001
|
||||
From: BillyGalbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Sun, 18 Jun 2017 18:17:05 -0500
|
||||
Subject: [PATCH] Entity#fromMobSpawner()
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java
|
||||
index c86c1c5f..b3d59a39 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Entity.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Entity.java
|
||||
@@ -505,5 +505,12 @@ public interface Entity extends Metadatable, CommandSender, Nameable {
|
||||
* @return Location where entity originates or null if not yet added
|
||||
*/
|
||||
Location getOrigin();
|
||||
+
|
||||
+ /**
|
||||
+ * Returns whether this entity was spawned from a mob spawner.
|
||||
+ *
|
||||
+ * @return True if entity spawned from a mob spawner
|
||||
+ */
|
||||
+ boolean fromMobSpawner();
|
||||
// Paper end
|
||||
}
|
||||
--
|
||||
2.13.2.windows.1
|
||||
|
68
Spigot-Server-Patches/0221-Entity-fromMobSpawner.patch
Normal file
68
Spigot-Server-Patches/0221-Entity-fromMobSpawner.patch
Normal file
@ -0,0 +1,68 @@
|
||||
From 1b9e03fd489394f2f426ae65854e6c4ae2cd1932 Mon Sep 17 00:00:00 2001
|
||||
From: BillyGalbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Sun, 18 Jun 2017 18:17:05 -0500
|
||||
Subject: [PATCH] Entity#fromMobSpawner()
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
||||
index d34ec4ff..65d7e1a1 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -169,6 +169,7 @@ public abstract class Entity implements ICommandListener {
|
||||
public final boolean defaultActivationState;
|
||||
public long activatedTick = Integer.MIN_VALUE;
|
||||
public boolean fromMobSpawner;
|
||||
+ public boolean spawnedViaMobSpawner; // Paper - Yes this name is similar to above, upstream took the better one
|
||||
protected int numCollisions = 0; // Paper
|
||||
public void inactiveTick() { }
|
||||
// Spigot end
|
||||
@@ -1584,6 +1585,10 @@ public abstract class Entity implements ICommandListener {
|
||||
if (origin != null) {
|
||||
nbttagcompound.set("Paper.Origin", this.createList(origin.getX(), origin.getY(), origin.getZ()));
|
||||
}
|
||||
+ // Save entity's from mob spawner status
|
||||
+ if (spawnedViaMobSpawner) {
|
||||
+ nbttagcompound.setBoolean("Paper.FromMobSpawner", true);
|
||||
+ }
|
||||
// Paper end
|
||||
return nbttagcompound;
|
||||
} catch (Throwable throwable) {
|
||||
@@ -1734,6 +1739,8 @@ public abstract class Entity implements ICommandListener {
|
||||
if (!originTag.isEmpty()) {
|
||||
origin = new Location(world.getWorld(), originTag.getDoubleAt(0), originTag.getDoubleAt(1), originTag.getDoubleAt(2));
|
||||
}
|
||||
+
|
||||
+ spawnedViaMobSpawner = nbttagcompound.getBoolean("Paper.FromMobSpawner"); // Restore entity's from mob spawner status
|
||||
// Paper end
|
||||
|
||||
} catch (Throwable throwable) {
|
||||
diff --git a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
|
||||
index dd740276..a5b5ef0f 100644
|
||||
--- a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
|
||||
+++ b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
|
||||
@@ -106,6 +106,7 @@ public abstract class MobSpawnerAbstract {
|
||||
if (this.spawnData.b().d() == 1 && this.spawnData.b().hasKeyOfType("id", 8) && entity instanceof EntityInsentient) {
|
||||
((EntityInsentient) entity).prepare(world.D(new BlockPosition(entity)), (GroupDataEntity) null);
|
||||
}
|
||||
+ entity.spawnedViaMobSpawner = true; // Paper
|
||||
// Spigot Start
|
||||
if ( entity.world.spigotConfig.nerfSpawnerMobs )
|
||||
{
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
index 05f3df4e..d23a72d6 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
@@ -788,5 +788,10 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
Location origin = getHandle().origin;
|
||||
return origin == null ? null : origin.clone();
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean fromMobSpawner() {
|
||||
+ return getHandle().spawnedViaMobSpawner;
|
||||
+ }
|
||||
// Paper end
|
||||
}
|
||||
--
|
||||
2.13.2.windows.1
|
||||
|
Loading…
Reference in New Issue
Block a user