From 60ec9b0ce3081b413034a47b90f8d6ab5a2ed6ca Mon Sep 17 00:00:00 2001 From: Danielle Voznyy Date: Sun, 28 Jan 2024 17:03:44 -0500 Subject: [PATCH] Fix: running spawn checks as target, not source --- .../mineinabyss/mobzy/spawning/SpawnTask.kt | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/mobzy-spawning/src/main/kotlin/com/mineinabyss/mobzy/spawning/SpawnTask.kt b/mobzy-spawning/src/main/kotlin/com/mineinabyss/mobzy/spawning/SpawnTask.kt index 8e02586d..58eff95c 100644 --- a/mobzy-spawning/src/main/kotlin/com/mineinabyss/mobzy/spawning/SpawnTask.kt +++ b/mobzy-spawning/src/main/kotlin/com/mineinabyss/mobzy/spawning/SpawnTask.kt @@ -6,6 +6,7 @@ import com.github.shynixn.mccoroutine.bukkit.minecraftDispatcher import com.mineinabyss.geary.components.RequestCheck import com.mineinabyss.geary.components.events.FailedCheck import com.mineinabyss.geary.datatypes.GearyEntity +import com.mineinabyss.geary.helpers.temporaryEntity import com.mineinabyss.geary.papermc.bridge.config.inputs.Input import com.mineinabyss.geary.papermc.bridge.config.inputs.Variables import com.mineinabyss.idofront.time.inWholeTicks @@ -108,15 +109,17 @@ class SpawnTask { //TODO this should be immutable but bukkit doesn't have an immutable location! val spawnLoc = spawnInfo.getSpawnFor(choice.get() ?: SpawnPosition.GROUND) val spawnCheckLoc = spawnLoc.clone().add(0.0, -1.0, 0.0) - val success = choice.callEvent({ - set(spawnInfo) - set( - Variables.Evaluated( - entries = mapOf("location" to Input.of(spawnCheckLoc)) + val success = temporaryEntity { target -> //TODO should just pass null for target + target.callEvent(init = { + set(spawnInfo) + set( + Variables.Evaluated( + entries = mapOf("location" to Input.of(spawnCheckLoc)) + ) ) - ) - add() - }) { !it.has() } + add() + }, source = choice) { !it.has() } + } if (success) { // Must spawn mobs on main thread if (mobzy.plugin.isEnabled) choice.callEvent(spawnInfo, DoSpawn(spawnLoc))