Add PhantomPreSpawnEvent
This commit is contained in:
@@ -1,6 +1,48 @@
|
|||||||
--- a/net/minecraft/world/entity/monster/Phantom.java
|
--- a/net/minecraft/world/entity/monster/Phantom.java
|
||||||
+++ b/net/minecraft/world/entity/monster/Phantom.java
|
+++ b/net/minecraft/world/entity/monster/Phantom.java
|
||||||
@@ -522,14 +522,14 @@
|
@@ -161,6 +161,11 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setPhantomSize(nbt.getInt("Size"));
|
||||||
|
+ // Paper start
|
||||||
|
+ if (nbt.hasUUID("Paper.SpawningEntity")) {
|
||||||
|
+ this.spawningEntity = nbt.getUUID("Paper.SpawningEntity");
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@@ -170,6 +175,11 @@
|
||||||
|
nbt.putInt("AY", this.anchorPoint.getY());
|
||||||
|
nbt.putInt("AZ", this.anchorPoint.getZ());
|
||||||
|
nbt.putInt("Size", this.getPhantomSize());
|
||||||
|
+ // Paper start
|
||||||
|
+ if (this.spawningEntity != null) {
|
||||||
|
+ nbt.putUUID("Paper.SpawningEntity", this.spawningEntity);
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@@ -219,6 +229,17 @@
|
||||||
|
return predicate.test(world, this, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Paper start
|
||||||
|
+ @Nullable
|
||||||
|
+ java.util.UUID spawningEntity;
|
||||||
|
+
|
||||||
|
+ @Nullable
|
||||||
|
+ public java.util.UUID getSpawningEntity() {
|
||||||
|
+ return this.spawningEntity;
|
||||||
|
+ }
|
||||||
|
+ public void setSpawningEntity(java.util.UUID entity) { this.spawningEntity = entity; }
|
||||||
|
+ // Paper end
|
||||||
|
+
|
||||||
|
private static enum AttackPhase {
|
||||||
|
|
||||||
|
CIRCLE, SWOOP;
|
||||||
|
@@ -522,14 +543,14 @@
|
||||||
List<Player> list = worldserver.getNearbyPlayers(this.attackTargeting, Phantom.this, Phantom.this.getBoundingBox().inflate(16.0D, 64.0D, 16.0D));
|
List<Player> list = worldserver.getNearbyPlayers(this.attackTargeting, Phantom.this, Phantom.this.getBoundingBox().inflate(16.0D, 64.0D, 16.0D));
|
||||||
|
|
||||||
if (!list.isEmpty()) {
|
if (!list.isEmpty()) {
|
||||||
|
|||||||
@@ -1,7 +1,22 @@
|
|||||||
--- a/net/minecraft/world/level/levelgen/PhantomSpawner.java
|
--- a/net/minecraft/world/level/levelgen/PhantomSpawner.java
|
||||||
+++ b/net/minecraft/world/level/levelgen/PhantomSpawner.java
|
+++ b/net/minecraft/world/level/levelgen/PhantomSpawner.java
|
||||||
@@ -74,7 +74,7 @@
|
@@ -69,12 +69,22 @@
|
||||||
|
int k = 1 + randomsource.nextInt(difficultydamagescaler.getDifficulty().getId() + 1);
|
||||||
|
|
||||||
|
for (int l = 0; l < k; ++l) {
|
||||||
|
+ // Paper start - PhantomPreSpawnEvent
|
||||||
|
+ 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);
|
||||||
|
+ if (!event.callEvent()) {
|
||||||
|
+ if (event.shouldAbortSpawn()) {
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+ // Paper end - PhantomPreSpawnEvent
|
||||||
|
Phantom entityphantom = (Phantom) EntityType.PHANTOM.create(world, EntitySpawnReason.NATURAL);
|
||||||
|
|
||||||
if (entityphantom != null) {
|
if (entityphantom != null) {
|
||||||
|
+ entityphantom.setSpawningEntity(entityplayer.getUUID()); // Paper - PhantomPreSpawnEvent
|
||||||
entityphantom.moveTo(blockposition1, 0.0F, 0.0F);
|
entityphantom.moveTo(blockposition1, 0.0F, 0.0F);
|
||||||
groupdataentity = entityphantom.finalizeSpawn(world, difficultydamagescaler, EntitySpawnReason.NATURAL, groupdataentity);
|
groupdataentity = entityphantom.finalizeSpawn(world, difficultydamagescaler, EntitySpawnReason.NATURAL, groupdataentity);
|
||||||
- world.addFreshEntityWithPassengers(entityphantom);
|
- world.addFreshEntityWithPassengers(entityphantom);
|
||||||
|
|||||||
@@ -28,4 +28,11 @@ public class CraftPhantom extends CraftFlying implements Phantom, CraftEnemy {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return "CraftPhantom";
|
return "CraftPhantom";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Paper start
|
||||||
|
@Override
|
||||||
|
public java.util.UUID getSpawningEntity() {
|
||||||
|
return getHandle().getSpawningEntity();
|
||||||
|
}
|
||||||
|
// Paper end
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user