Paper/patches/server/0139-Entity-fromMobSpawner.patch

66 lines
3.4 KiB
Diff
Raw Normal View History

2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 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/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index c261971ab482abfa5a1ca51abd189eff16421534..fe314015f8cbc44e29a8ec73ecca4eeadd1da39f 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -395,6 +395,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
public void inactiveTick() { }
2021-06-11 14:02:28 +02:00
// Spigot end
protected int numCollisions = 0; // Paper - Cap entity collisions
+ public boolean spawnedViaMobSpawner; // Paper - Yes this name is similar to above, upstream took the better one
// Paper start - Entity origin API
@javax.annotation.Nullable
private org.bukkit.util.Vector origin;
@@ -2162,6 +2163,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
}
2023-12-05 23:12:48 +01:00
nbttagcompound.put("Paper.Origin", this.newDoubleList(origin.getX(), origin.getY(), origin.getZ()));
2021-06-11 14:02:28 +02:00
}
+ // Save entity's from mob spawner status
+ if (spawnedViaMobSpawner) {
2023-12-06 19:36:49 +01:00
+ nbttagcompound.putBoolean("Paper.FromMobSpawner", true);
2021-06-11 14:02:28 +02:00
+ }
// Paper end
2023-12-05 23:12:48 +01:00
return nbttagcompound;
2021-06-11 14:02:28 +02:00
} catch (Throwable throwable) {
@@ -2302,6 +2307,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
this.originWorld = originWorld;
2021-06-17 19:11:00 +02:00
origin = new org.bukkit.util.Vector(originTag.getDouble(0), originTag.getDouble(1), originTag.getDouble(2));
2021-06-11 14:02:28 +02:00
}
+
2021-06-12 13:18:01 +02:00
+ spawnedViaMobSpawner = nbt.getBoolean("Paper.FromMobSpawner"); // Restore entity's from mob spawner status
2021-06-11 14:02:28 +02:00
// Paper end
} catch (Throwable throwable) {
diff --git a/src/main/java/net/minecraft/world/level/BaseSpawner.java b/src/main/java/net/minecraft/world/level/BaseSpawner.java
index a46293dafeb73f9206b92a2850df18a6a5f688b4..487e4211d6486d2b3052c931c27cee9729e7841b 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/level/BaseSpawner.java
+++ b/src/main/java/net/minecraft/world/level/BaseSpawner.java
2023-12-05 23:12:48 +01:00
@@ -167,6 +167,7 @@ public abstract class BaseSpawner {
// Spigot End
}
+ entity.spawnedViaMobSpawner = true; // Paper
// CraftBukkit start
if (org.bukkit.craftbukkit.event.CraftEventFactory.callSpawnerSpawnEvent(entity, pos).isCancelled()) {
continue;
2021-06-11 14:02:28 +02:00
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
index 4a875d038f1ab7f2bdc5f290a6ad71e4b61c6822..d715dcc9155ad9938bd4fbe0cde43079f614f203 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -1013,5 +1013,10 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
//noinspection ConstantConditions
return originVector.toLocation(world);
2021-06-11 14:02:28 +02:00
}
+
+ @Override
+ public boolean fromMobSpawner() {
+ return getHandle().spawnedViaMobSpawner;
+ }
// Paper end
}