Paper/patches/server/0247-Add-PhantomPreSpawnEvent.patch

90 lines
4.7 KiB
Diff
Raw Normal View History

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
2023-09-22 00:01:00 +02:00
index d19bf99d03bf505a1a277b49fba6ee4769802ef2..658393f451e46a93c5665fe3c580aa395ace68d1 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
2023-09-22 00:01:00 +02:00
@@ -172,6 +172,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
2023-09-22 00:01:00 +02:00
@@ -181,6 +186,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
2023-09-22 00:01:00 +02:00
@@ -241,6 +251,14 @@ public class Phantom extends FlyingMob implements Enemy {
return -0.125F;
2021-06-11 14:02:28 +02:00
}
+ // Paper start
+ java.util.UUID spawningEntity;
+
+ public java.util.UUID getSpawningEntity() {
+ return spawningEntity;
+ }
+ public void setSpawningEntity(java.util.UUID entity) { this.spawningEntity = entity; }
+ // Paper end
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
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#9440) Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 01aa02eb PR-858: Add LivingEntity#playHurtAnimation() 9421320f PR-884: Refinements to new ban API for improved compatibility and correctness 37a60b45 SPIGOT-6455, SPIGOT-7030, PR-750: Improve ban API 4eeb174b All smithing inventories are now the new smithing inventory f2bb168e PR-880: Add methods to get/set FallingBlock CancelDrop e7a807fa PR-879: Add Player#sendHealthUpdate() 692b8e96 SPIGOT-7370: Remove float value conversion in plugin.yml 2d033390 SPIGOT-7403: Add direct API for waxed signs 16a08373 PR-876: Add missing Raider API and 'no action ticks' CraftBukkit Changes: b60a95c8c PR-1189: Add LivingEntity#playHurtAnimation() 95c335c63 PR-1226: Fix VehicleEnterEvent not being called for certain entities 0a0fc3bee PR-1227: Refinements to new ban API for improved compatibility and correctness 0d0b1e5dc Revert bad change to PathfinderGoalSit causing all cats to sit 648196070 SPIGOT-6455, SPIGOT-7030, PR-1054: Improve ban API 31fe848d6 All smithing inventories are now the new smithing inventory 9a919a143 SPIGOT-7416: SmithItemEvent not firing in Smithing Table 9f64f0d22 PR-1221: Add methods to get/set FallingBlock CancelDrop 3be9ac171 PR-1220: Add Player#sendHealthUpdate() c1279f775 PR-1209: Clean up various patches c432e4397 Fix Raider#setCelebrating() implementation 504d96665 SPIGOT-7403: Add direct API for waxed signs c68c1f1b3 PR-1216: Add missing Raider API and 'no action ticks' 85b89c3dd Increase outdated build delay Spigot Changes: 9ebce8af Rebuild patches 64b565e6 Rebuild patches
2023-07-04 10:22:56 +02:00
index 61ba99d99cc4e7782450ee6aa8b6c87b1a42cb3a..94ee9c399f59e0198b4d9bc2a4255e8b821bcd36 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
2023-06-08 00:28:06 +02:00
@@ -70,9 +70,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) {
+ // Paper start
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;
+ }
+ // Paper end
Phantom entityphantom = (Phantom) EntityType.PHANTOM.create(world);
2022-12-07 20:22:28 +01:00
if (entityphantom != null) {
+ entityphantom.setSpawningEntity(entityplayer.getUUID()); // Paper
2022-12-07 20:22:28 +01:00
entityphantom.moveTo(blockposition1, 0.0F, 0.0F);
groupdataentity = entityphantom.finalizeSpawn(world, difficultydamagescaler, MobSpawnType.NATURAL, groupdataentity, (CompoundTag) null);
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
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
@@ -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
}