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
|
2022-10-24 21:43:46 +02:00
|
|
|
index c068eddb08898681735e483df5b9c36f5fef3878..0e96e9d7e4d636f4222f60cec556663f506c3906 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
|
2021-11-23 16:50:18 +01:00
|
|
|
@@ -171,6 +171,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
|
2021-11-23 16:50:18 +01:00
|
|
|
@@ -180,6 +185,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
|
2021-11-23 16:50:18 +01:00
|
|
|
@@ -231,6 +241,14 @@ public class Phantom extends FlyingMob implements Enemy {
|
2021-06-11 14:02:28 +02:00
|
|
|
return entitysize.scale(f);
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // 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
|
2022-10-24 21:43:46 +02:00
|
|
|
index 573490a7c95746c3d372d258b2e592241258f6cf..0dbb0c4d038379c6ffdae8528d98431e98faeb93 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
|
2022-06-07 23:45:11 +02:00
|
|
|
@@ -3,6 +3,7 @@ package net.minecraft.world.level.levelgen;
|
|
|
|
import java.util.Iterator;
|
2021-06-11 14:02:28 +02:00
|
|
|
import net.minecraft.core.BlockPos;
|
|
|
|
import net.minecraft.nbt.CompoundTag;
|
2022-10-24 21:43:46 +02:00
|
|
|
+import io.papermc.paper.util.MCUtil;
|
2021-06-11 14:02:28 +02:00
|
|
|
import net.minecraft.server.level.ServerLevel;
|
|
|
|
import net.minecraft.server.level.ServerPlayer;
|
|
|
|
import net.minecraft.stats.ServerStatsCounter;
|
2021-11-23 16:50:18 +01:00
|
|
|
@@ -71,8 +72,17 @@ 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
|
|
|
|
+ com.destroystokyo.paper.event.entity.PhantomPreSpawnEvent event = new com.destroystokyo.paper.event.entity.PhantomPreSpawnEvent(MCUtil.toLocation(world, blockposition1), ((ServerPlayer) entityhuman).getBukkitEntity(), org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL);
|
|
|
|
+ if (!event.callEvent()) {
|
|
|
|
+ if (event.shouldAbortSpawn()) {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
2021-11-23 16:50:18 +01:00
|
|
|
Phantom entityphantom = (Phantom) EntityType.PHANTOM.create(world);
|
2021-06-11 14:02:28 +02:00
|
|
|
-
|
|
|
|
+ entityphantom.setSpawningEntity(entityhuman.getUUID()); // Paper
|
|
|
|
entityphantom.moveTo(blockposition1, 0.0F, 0.0F);
|
|
|
|
groupdataentity = entityphantom.finalizeSpawn(world, difficultydamagescaler, MobSpawnType.NATURAL, groupdataentity, (CompoundTag) null);
|
2021-11-23 16:50:18 +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
|
2021-06-13 01:45:00 +02:00
|
|
|
index f77b83bee6eb739220b55793a0807f0267cfc8a9..c9dab70b0b284fe1c1daafd3c1f5bd08b14fa35d 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
|
2021-06-13 01:45:00 +02:00
|
|
|
@@ -34,4 +34,11 @@ public class CraftPhantom extends CraftFlying implements Phantom {
|
2021-06-11 14:02:28 +02:00
|
|
|
public EntityType getType() {
|
|
|
|
return EntityType.PHANTOM;
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // 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
|
|
|
|
}
|