diff options
author | Max Lee <[email protected]> | 2018-09-19 01:34:11 +0200 |
---|---|---|
committer | Daniel Ennis <[email protected]> | 2018-09-18 19:34:11 -0400 |
commit | 1e66b061fa57d947e3ba12717475c7ccac47905e (patch) | |
tree | 78322ac16a94f6c37c8e14c0372aba205ee7f224 /Spigot-API-Patches | |
parent | 0d54dc2025705e400dd831ac617a1f45d5fbba18 (diff) | |
download | Paper-1e66b061fa57d947e3ba12717475c7ccac47905e.tar.gz Paper-1e66b061fa57d947e3ba12717475c7ccac47905e.zip |
Add a separate PreSpawnerSpawnEvent (#1455)
This event extends the PreCreatureSpawnEvent and includes the position
of the spawner that spawned the entitiy. (similarly to how the
SpawnerSpawnEvent contains the spawner's BlockState).
This one doesn't include the state though as getting the block and
generating that snapshot is a bit wasteful.
Diffstat (limited to 'Spigot-API-Patches')
-rw-r--r-- | Spigot-API-Patches/0153-PreSpawnerSpawnEvent.patch | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/Spigot-API-Patches/0153-PreSpawnerSpawnEvent.patch b/Spigot-API-Patches/0153-PreSpawnerSpawnEvent.patch new file mode 100644 index 0000000000..5beccdfb36 --- /dev/null +++ b/Spigot-API-Patches/0153-PreSpawnerSpawnEvent.patch @@ -0,0 +1,46 @@ +From d9327f143f54e3033ee83fcda98323416dfc7325 Mon Sep 17 00:00:00 2001 +From: Phoenix616 <[email protected]> +Date: Tue, 18 Sep 2018 23:50:10 +0100 +Subject: [PATCH] PreSpawnerSpawnEvent + +This adds a separate event before an entity is spawned by a spawner +which contains the location of the spawner too similarly to how the +SpawnerSpawnEvent gets called instead of the CreatureSpawnEvent for +spawners. + +diff --git a/src/main/java/com/destroystokyo/paper/event/entity/PreSpawnerSpawnEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/PreSpawnerSpawnEvent.java +new file mode 100644 +index 00000000..d7221210 +--- /dev/null ++++ b/src/main/java/com/destroystokyo/paper/event/entity/PreSpawnerSpawnEvent.java +@@ -0,0 +1,27 @@ ++package com.destroystokyo.paper.event.entity; ++ ++ ++import com.google.common.base.Preconditions; ++import org.bukkit.Location; ++import org.bukkit.entity.EntityType; ++import org.bukkit.event.entity.CreatureSpawnEvent; ++ ++/** ++ * Called before an entity is spawned into a world by a spawner. ++ * ++ * This only includes the spawner's location and not the full BlockState snapshot for performance reasons. ++ * If you really need it you have to get the spawner yourself. ++ */ ++ ++public class PreSpawnerSpawnEvent extends PreCreatureSpawnEvent { ++ private final Location spawnerLocation; ++ ++ public PreSpawnerSpawnEvent(Location location, EntityType type, Location spawnerLocation) { ++ super(location, type, CreatureSpawnEvent.SpawnReason.SPAWNER); ++ this.spawnerLocation = Preconditions.checkNotNull(spawnerLocation, "Spawner location may not be null"); ++ } ++ ++ public Location getSpawnerLocation() { ++ return spawnerLocation; ++ } ++} +-- +2.18.0.windows.1 + |