mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-01 04:31:58 +01:00
96 lines
5.1 KiB
Diff
96 lines
5.1 KiB
Diff
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/EntityPhantom.java b/src/main/java/net/minecraft/world/entity/monster/EntityPhantom.java
|
|
index 6053894c5250e9a1a0c4aa2d681127dfd652b34f..6c498d4345df35a411d155799ac56e47c9c48114 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/monster/EntityPhantom.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/monster/EntityPhantom.java
|
|
@@ -161,6 +161,11 @@ public class EntityPhantom extends EntityFlying implements IMonster {
|
|
}
|
|
|
|
this.setSize(nbttagcompound.getInt("Size"));
|
|
+ // Paper start
|
|
+ if (nbttagcompound.hasUUID("Paper.SpawningEntity")) {
|
|
+ this.spawningEntity = nbttagcompound.getUUID("Paper.SpawningEntity");
|
|
+ }
|
|
+ // Paper end
|
|
}
|
|
|
|
@Override
|
|
@@ -170,6 +175,11 @@ public class EntityPhantom extends EntityFlying implements IMonster {
|
|
nbttagcompound.setInt("AY", this.d.getY());
|
|
nbttagcompound.setInt("AZ", this.d.getZ());
|
|
nbttagcompound.setInt("Size", this.getSize());
|
|
+ // Paper start
|
|
+ if (this.spawningEntity != null) {
|
|
+ nbttagcompound.setUUID("Paper.SpawningEntity", this.spawningEntity);
|
|
+ }
|
|
+ // Paper end
|
|
}
|
|
|
|
@Override
|
|
@@ -216,6 +226,15 @@ public class EntityPhantom extends EntityFlying implements IMonster {
|
|
return entitysize.a(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
|
|
+
|
|
class b extends PathfinderGoal {
|
|
|
|
private final PathfinderTargetCondition b;
|
|
diff --git a/src/main/java/net/minecraft/world/level/levelgen/MobSpawnerPhantom.java b/src/main/java/net/minecraft/world/level/levelgen/MobSpawnerPhantom.java
|
|
index cfc32acee1e456a0fda12a5faa4035e29d0c3d5e..96a5a6569387a25b15a06aaab3bd9d033547e875 100644
|
|
--- a/src/main/java/net/minecraft/world/level/levelgen/MobSpawnerPhantom.java
|
|
+++ b/src/main/java/net/minecraft/world/level/levelgen/MobSpawnerPhantom.java
|
|
@@ -4,6 +4,7 @@ import java.util.Iterator;
|
|
import java.util.Random;
|
|
import net.minecraft.core.BlockPosition;
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
+import net.minecraft.server.MCUtil;
|
|
import net.minecraft.server.level.EntityPlayer;
|
|
import net.minecraft.server.level.WorldServer;
|
|
import net.minecraft.stats.ServerStatisticManager;
|
|
@@ -73,8 +74,17 @@ public class MobSpawnerPhantom implements MobSpawner {
|
|
int k = 1 + random.nextInt(difficultydamagescaler.a().a() + 1);
|
|
|
|
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(worldserver, blockposition1), ((EntityPlayer) entityhuman).getBukkitEntity(), org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL);
|
|
+ if (!event.callEvent()) {
|
|
+ if (event.shouldAbortSpawn()) {
|
|
+ break;
|
|
+ }
|
|
+ continue;
|
|
+ }
|
|
+ // Paper end
|
|
EntityPhantom entityphantom = (EntityPhantom) EntityTypes.PHANTOM.a((World) worldserver);
|
|
-
|
|
+ entityphantom.setSpawningEntity(entityhuman.getUniqueID()); // Paper
|
|
entityphantom.setPositionRotation(blockposition1, 0.0F, 0.0F);
|
|
groupdataentity = entityphantom.prepare(worldserver, difficultydamagescaler, EnumMobSpawn.NATURAL, groupdataentity, (NBTTagCompound) null);
|
|
worldserver.addAllEntities(entityphantom, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java
|
|
index 6ec7cf434b6586342da3f351466f5c7d72df290d..0cea1d8e23da3a79ef06e43752665a5401b01b4b 100644
|
|
--- 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
|
|
}
|