2021-06-11 14:02:28 +02:00
|
|
|
From 0000000000000000000000000000000000000000 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/world/entity/monster/Phantom.java b/src/main/java/net/minecraft/world/entity/monster/Phantom.java
|
2024-10-23 12:32:08 +02:00
|
|
|
index d9d374e18b1cacf0b04e6e02f3a94b145f4052fb..748f07c7036fe5955d76e28c4e7d23f8c0235d5f 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/monster/Phantom.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/monster/Phantom.java
|
2024-10-23 12:32:08 +02:00
|
|
|
@@ -161,6 +161,11 @@ public class Phantom extends FlyingMob implements Enemy {
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
|
2021-06-13 01:45:00 +02:00
|
|
|
this.setPhantomSize(nbt.getInt("Size"));
|
2021-06-11 14:02:28 +02:00
|
|
|
+ // Paper start
|
2021-06-13 01:45:00 +02:00
|
|
|
+ if (nbt.hasUUID("Paper.SpawningEntity")) {
|
|
|
|
+ this.spawningEntity = nbt.getUUID("Paper.SpawningEntity");
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2024-10-23 12:32:08 +02:00
|
|
|
@@ -170,6 +175,11 @@ public class Phantom extends FlyingMob implements Enemy {
|
2021-06-13 01:45:00 +02:00
|
|
|
nbt.putInt("AY", this.anchorPoint.getY());
|
|
|
|
nbt.putInt("AZ", this.anchorPoint.getZ());
|
|
|
|
nbt.putInt("Size", this.getPhantomSize());
|
2021-06-11 14:02:28 +02:00
|
|
|
+ // Paper start
|
|
|
|
+ if (this.spawningEntity != null) {
|
2021-06-17 23:39:36 +02:00
|
|
|
+ nbt.putUUID("Paper.SpawningEntity", this.spawningEntity);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2024-04-24 04:46:06 +02:00
|
|
|
@@ -219,6 +229,17 @@ public class Phantom extends FlyingMob implements Enemy {
|
2024-10-23 12:32:08 +02:00
|
|
|
return predicate.test(world, this, target);
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start
|
2024-04-24 04:46:06 +02:00
|
|
|
+ @Nullable
|
2021-06-11 14:02:28 +02:00
|
|
|
+ java.util.UUID spawningEntity;
|
|
|
|
+
|
2024-04-24 04:46:06 +02:00
|
|
|
+ @Nullable
|
2021-06-11 14:02:28 +02:00
|
|
|
+ public java.util.UUID getSpawningEntity() {
|
2024-04-24 04:46:06 +02:00
|
|
|
+ return this.spawningEntity;
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
|
|
|
+ public void setSpawningEntity(java.util.UUID entity) { this.spawningEntity = entity; }
|
|
|
|
+ // Paper end
|
2024-04-24 04:46:06 +02:00
|
|
|
+
|
2021-06-13 01:45:00 +02:00
|
|
|
private static enum AttackPhase {
|
2021-06-11 14:02:28 +02:00
|
|
|
|
2021-06-13 01:45:00 +02:00
|
|
|
CIRCLE, SWOOP;
|
2021-06-11 14:02:28 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java b/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java
|
2024-10-23 12:32:08 +02:00
|
|
|
index 1ef81620541c97dce0fca4d85951202e9532e733..499b124f905ffa8e375efa354a3f2240997ddea5 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java
|
2024-04-24 04:46:06 +02:00
|
|
|
@@ -69,9 +69,19 @@ public class PhantomSpawner implements CustomSpawner {
|
2022-06-07 23:45:11 +02:00
|
|
|
int k = 1 + randomsource.nextInt(difficultydamagescaler.getDifficulty().getId() + 1);
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
for (int l = 0; l < k; ++l) {
|
2024-01-21 17:39:05 +01:00
|
|
|
+ // Paper start - PhantomPreSpawnEvent
|
2023-06-08 00:28:06 +02:00
|
|
|
+ com.destroystokyo.paper.event.entity.PhantomPreSpawnEvent event = new com.destroystokyo.paper.event.entity.PhantomPreSpawnEvent(io.papermc.paper.util.MCUtil.toLocation(world, blockposition1), entityplayer.getBukkitEntity(), org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ if (!event.callEvent()) {
|
|
|
|
+ if (event.shouldAbortSpawn()) {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ continue;
|
|
|
|
+ }
|
2024-01-21 17:39:05 +01:00
|
|
|
+ // Paper end - PhantomPreSpawnEvent
|
2024-10-23 12:32:08 +02:00
|
|
|
Phantom entityphantom = (Phantom) EntityType.PHANTOM.create(world, EntitySpawnReason.NATURAL);
|
2022-12-07 20:22:28 +01:00
|
|
|
|
|
|
|
if (entityphantom != null) {
|
2024-01-21 17:39:05 +01:00
|
|
|
+ entityphantom.setSpawningEntity(entityplayer.getUUID()); // Paper - PhantomPreSpawnEvent
|
2022-12-07 20:22:28 +01:00
|
|
|
entityphantom.moveTo(blockposition1, 0.0F, 0.0F);
|
2024-10-23 12:32:08 +02:00
|
|
|
groupdataentity = entityphantom.finalizeSpawn(world, difficultydamagescaler, EntitySpawnReason.NATURAL, groupdataentity);
|
2022-12-07 20:22:28 +01:00
|
|
|
world.addFreshEntityWithPassengers(entityphantom, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit
|
2021-06-11 14:02:28 +02:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java
|
2023-08-14 01:32:51 +02:00
|
|
|
index 0359c161448941f1b9fdac545a5c47a68f19b760..305a635b049741ac5e2670060c6818cb2c07e5ab 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java
|
2023-08-14 01:32:51 +02:00
|
|
|
@@ -28,4 +28,11 @@ public class CraftPhantom extends CraftFlying implements Phantom, CraftEnemy {
|
|
|
|
public String toString() {
|
|
|
|
return "CraftPhantom";
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // Paper start
|
2021-06-13 01:45:00 +02:00
|
|
|
+ @Override
|
2021-06-11 14:02:28 +02:00
|
|
|
+ public java.util.UUID getSpawningEntity() {
|
|
|
|
+ return getHandle().getSpawningEntity();
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|