From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: BillyGalbreath 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 0b971ad8addd65850162e46707c15fbc1ba9b8b9..7c6bf0b91cdf59f6dcf155ee8abfbab61938cc8b 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -188,6 +188,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke public final org.spigotmc.ActivationRange.ActivationType activationType = org.spigotmc.ActivationRange.initializeEntityActivationType(this); public final boolean defaultActivationState; public long activatedTick = Integer.MIN_VALUE; + 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 @@ -1622,6 +1623,10 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke if (this.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) { @@ -1742,6 +1747,8 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke 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 b249af20c4712a89e5f340eb922291557099058a..ab5d83d34d9314a253353d6d01fdcd2bed964933 100644 --- a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java +++ b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java @@ -140,6 +140,7 @@ public abstract class MobSpawnerAbstract { } // Spigot End } + entity.spawnedViaMobSpawner = true; // Paper // Spigot Start if (org.bukkit.craftbukkit.event.CraftEventFactory.callSpawnerSpawnEvent(entity, blockposition).isCancelled()) { Entity vehicle = entity.getVehicle(); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index 1d02e9acb94c972f3dc178a15ed0963a9c80539e..440bc4513b91c72e01bdd2a106a84e82ab72ac97 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -1047,5 +1047,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 }