2018-10-05 05:18:46 +02:00
|
|
|
From 99fc8d9cadca3916a3c8d17df85d0030b95af22f Mon Sep 17 00:00:00 2001
|
2018-08-27 08:51:20 +02:00
|
|
|
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
|
2018-09-27 04:35:42 +02:00
|
|
|
index 2429644e99..e276001094 100644
|
2018-08-27 08:51:20 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityPhantom.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityPhantom.java
|
2018-09-03 21:22:41 +02:00
|
|
|
@@ -128,6 +128,11 @@ public class EntityPhantom extends EntityFlying implements IMonster {
|
2018-08-27 08:51:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
this.setSize(nbttagcompound.getInt("Size"));
|
2018-09-03 21:22:41 +02:00
|
|
|
+ // Paper start
|
|
|
|
+ if (nbttagcompound.hasUUID("Paper.SpawningEntity")) {
|
|
|
|
+ this.spawningEntity = nbttagcompound.getUUID("Paper.SpawningEntity");
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
2018-08-27 08:51:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void b(NBTTagCompound nbttagcompound) {
|
2018-09-03 21:22:41 +02:00
|
|
|
@@ -136,6 +141,11 @@ public class EntityPhantom extends EntityFlying implements IMonster {
|
2018-08-27 08:51:20 +02:00
|
|
|
nbttagcompound.setInt("AY", this.c.getY());
|
|
|
|
nbttagcompound.setInt("AZ", this.c.getZ());
|
|
|
|
nbttagcompound.setInt("Size", this.getSize());
|
2018-09-03 21:22:41 +02:00
|
|
|
+ // Paper start
|
|
|
|
+ if (this.spawningEntity != null) {
|
|
|
|
+ nbttagcompound.setUUID("Paper.SpawningEntity", this.spawningEntity);
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
2018-08-27 08:51:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public SoundCategory bV() {
|
2018-09-03 21:22:41 +02:00
|
|
|
@@ -171,6 +181,14 @@ public class EntityPhantom extends EntityFlying implements IMonster {
|
2018-08-27 08:51:20 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start
|
|
|
|
+ java.util.UUID spawningEntity;
|
|
|
|
+
|
|
|
|
+ public java.util.UUID getSpawningEntity() {
|
|
|
|
+ return spawningEntity;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
class b extends PathfinderGoal {
|
|
|
|
|
|
|
|
private int b;
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/MobSpawnerPhantom.java b/src/main/java/net/minecraft/server/MobSpawnerPhantom.java
|
2018-09-27 04:35:42 +02:00
|
|
|
index 0626b77904..413188e970 100644
|
2018-08-27 08:51:20 +02:00
|
|
|
--- 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 {
|
|
|
|
int k = 1 + random.nextInt(difficultydamagescaler.a().a() + 1);
|
|
|
|
|
|
|
|
for (int l = 0; l < k; ++l) {
|
|
|
|
+ // Paper start
|
|
|
|
+ com.destroystokyo.paper.event.entity.PhantomPreSpawnEvent event = new com.destroystokyo.paper.event.entity.PhantomPreSpawnEvent(MCUtil.toLocation(world, blockposition1), ((EntityPlayer) entityhuman).getBukkitEntity(), org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL);
|
|
|
|
+ if (!event.callEvent()) {
|
|
|
|
+ if (event.shouldAbortSpawn()) {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
EntityPhantom entityphantom = new EntityPhantom(world);
|
|
|
|
-
|
|
|
|
+ entityphantom.spawningEntity = entityhuman.uniqueID; // Paper
|
|
|
|
entityphantom.setPositionRotation(blockposition1, 0.0F, 0.0F);
|
|
|
|
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
|
2018-09-27 04:35:42 +02:00
|
|
|
index 9f9ee92390..2b97313694 100644
|
2018-08-27 08:51:20 +02:00
|
|
|
--- 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 {
|
|
|
|
public EntityType getType() {
|
|
|
|
return EntityType.PHANTOM;
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // Paper start
|
|
|
|
+ public java.util.UUID getSpawningEntity() {
|
|
|
|
+ return getHandle().getSpawningEntity();
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
--
|
2018-09-27 04:35:42 +02:00
|
|
|
2.19.0
|
2018-08-27 08:51:20 +02:00
|
|
|
|