2020-05-06 11:48:49 +02:00
|
|
|
From 0000000000000000000000000000000000000000 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
|
2020-08-25 04:22:08 +02:00
|
|
|
index 84edac9e18e4beab31c12e74e5e1ad51d3eae579..0605cb3e9873f92835e9f121b18c35e8eca5ccbb 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
|
2020-06-25 16:09:55 +02:00
|
|
|
@@ -125,6 +125,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
|
|
|
}
|
|
|
|
|
2019-05-05 10:33:44 +02:00
|
|
|
@Override
|
2020-06-25 16:09:55 +02:00
|
|
|
@@ -134,6 +139,11 @@ public class EntityPhantom extends EntityFlying implements IMonster {
|
2019-05-05 10:33:44 +02:00
|
|
|
nbttagcompound.setInt("AY", this.d.getY());
|
|
|
|
nbttagcompound.setInt("AZ", this.d.getZ());
|
2018-08-27 08:51:20 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-05-05 10:33:44 +02:00
|
|
|
@Override
|
2020-06-25 16:09:55 +02:00
|
|
|
@@ -180,6 +190,14 @@ public class EntityPhantom extends EntityFlying implements IMonster {
|
2019-05-05 10:33:44 +02:00
|
|
|
return entitysize.a(f);
|
2018-08-27 08:51:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start
|
|
|
|
+ java.util.UUID spawningEntity;
|
|
|
|
+
|
|
|
|
+ public java.util.UUID getSpawningEntity() {
|
|
|
|
+ return spawningEntity;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
class b extends PathfinderGoal {
|
|
|
|
|
2019-05-05 10:33:44 +02:00
|
|
|
private final PathfinderTargetCondition b;
|
2018-08-27 08:51:20 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/MobSpawnerPhantom.java b/src/main/java/net/minecraft/server/MobSpawnerPhantom.java
|
2020-08-25 04:22:08 +02:00
|
|
|
index 8947c7dfb0d7520b6a8fb0a75ddaf8163fd4baa5..2e3d8d78c7a2b6c9a76c3446f8532137c537c79c 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
|
2020-06-25 16:09:55 +02:00
|
|
|
@@ -53,8 +53,17 @@ public class MobSpawnerPhantom implements MobSpawner {
|
2018-08-27 08:51:20 +02:00
|
|
|
int k = 1 + random.nextInt(difficultydamagescaler.a().a() + 1);
|
|
|
|
|
|
|
|
for (int l = 0; l < k; ++l) {
|
|
|
|
+ // Paper start
|
2019-05-06 09:20:16 +02:00
|
|
|
+ com.destroystokyo.paper.event.entity.PhantomPreSpawnEvent event = new com.destroystokyo.paper.event.entity.PhantomPreSpawnEvent(MCUtil.toLocation(worldserver, blockposition1), ((EntityPlayer) entityhuman).getBukkitEntity(), org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL);
|
2018-08-27 08:51:20 +02:00
|
|
|
+ if (!event.callEvent()) {
|
|
|
|
+ if (event.shouldAbortSpawn()) {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
2019-05-05 10:33:44 +02:00
|
|
|
EntityPhantom entityphantom = (EntityPhantom) EntityTypes.PHANTOM.a((World) worldserver);
|
2018-08-27 08:51:20 +02:00
|
|
|
-
|
|
|
|
+ entityphantom.spawningEntity = entityhuman.uniqueID; // Paper
|
|
|
|
entityphantom.setPositionRotation(blockposition1, 0.0F, 0.0F);
|
2019-05-05 10:33:44 +02:00
|
|
|
groupdataentity = entityphantom.prepare(worldserver, difficultydamagescaler, EnumMobSpawn.NATURAL, groupdataentity, (NBTTagCompound) null);
|
2020-08-25 04:22:08 +02:00
|
|
|
worldserver.addAllEntities(entityphantom, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit
|
2018-08-27 08:51:20 +02:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java
|
2020-05-06 11:48:49 +02:00
|
|
|
index 9f9ee9239037acced498bbebe0ea396473b487ec..2b97313694605171ea4627edde036e3754b5e03b 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
|
|
|
|
}
|