Check that phantom spawned uuid is set for save/load

Fixes #1408

Spawn eggs wont have a player set
This commit is contained in:
Aikar 2018-09-03 15:22:41 -04:00
parent 7cdfd6e538
commit 6a3ee6dd09

View file

@ -1,30 +1,38 @@
From b0103cefc4681ecee343d74439e248db5ed62cbd Mon Sep 17 00:00:00 2001
From a45277ffe97ecfe82bc0ebb7c6ff76e543e72ec2 Mon Sep 17 00:00:00 2001
From: BillyGalbreath <Blake.Galbreath@GMail.com>
Date: Sat, 25 Aug 2018 19:56:51 -0500
Subject: [PATCH] Add PhantomPreSpawnEvent
diff --git a/src/main/java/net/minecraft/server/EntityPhantom.java b/src/main/java/net/minecraft/server/EntityPhantom.java
index 2429644e99..2778660acd 100644
index 2429644e9..e27600109 100644
--- a/src/main/java/net/minecraft/server/EntityPhantom.java
+++ b/src/main/java/net/minecraft/server/EntityPhantom.java
@@ -128,6 +128,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {
@@ -128,6 +128,11 @@ public class EntityPhantom extends EntityFlying implements IMonster {
}
this.setSize(nbttagcompound.getInt("Size"));
+ this.spawningEntity = nbttagcompound.getUUID("Paper.SpawningEntity"); // Paper
+ // Paper start
+ if (nbttagcompound.hasUUID("Paper.SpawningEntity")) {
+ this.spawningEntity = nbttagcompound.getUUID("Paper.SpawningEntity");
+ }
+ // Paper end
}
public void b(NBTTagCompound nbttagcompound) {
@@ -136,6 +137,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {
@@ -136,6 +141,11 @@ public class EntityPhantom extends EntityFlying implements IMonster {
nbttagcompound.setInt("AY", this.c.getY());
nbttagcompound.setInt("AZ", this.c.getZ());
nbttagcompound.setInt("Size", this.getSize());
+ nbttagcompound.setUUID("Paper.SpawningEntity", this.spawningEntity); // Paper
+ // Paper start
+ if (this.spawningEntity != null) {
+ nbttagcompound.setUUID("Paper.SpawningEntity", this.spawningEntity);
+ }
+ // Paper end
}
public SoundCategory bV() {
@@ -171,6 +173,14 @@ public class EntityPhantom extends EntityFlying implements IMonster {
@@ -171,6 +181,14 @@ public class EntityPhantom extends EntityFlying implements IMonster {
return true;
}
@ -40,7 +48,7 @@ index 2429644e99..2778660acd 100644
private int b;
diff --git a/src/main/java/net/minecraft/server/MobSpawnerPhantom.java b/src/main/java/net/minecraft/server/MobSpawnerPhantom.java
index 0626b77904..413188e970 100644
index 0626b7790..413188e97 100644
--- a/src/main/java/net/minecraft/server/MobSpawnerPhantom.java
+++ b/src/main/java/net/minecraft/server/MobSpawnerPhantom.java
@@ -50,8 +50,17 @@ public class MobSpawnerPhantom {
@ -63,7 +71,7 @@ index 0626b77904..413188e970 100644
groupdataentity = entityphantom.prepare(difficultydamagescaler, groupdataentity, (NBTTagCompound) null);
world.addEntity(entityphantom, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java
index 9f9ee92390..2b97313694 100644
index 9f9ee9239..2b9731369 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java
@@ -35,4 +35,10 @@ public class CraftPhantom extends CraftFlying implements Phantom {