From 1078df493e6473f0b5cfa0409857c16e6fd60f53 Mon Sep 17 00:00:00 2001 From: ronald Date: Sun, 30 Jul 2023 17:51:53 -0500 Subject: Added fallback for players lobbyswapping to flee slayer boss to event system --- src/main/kotlin/com/dulkirfabric/util/Utils.kt | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/main/kotlin/com/dulkirfabric/util/Utils.kt') diff --git a/src/main/kotlin/com/dulkirfabric/util/Utils.kt b/src/main/kotlin/com/dulkirfabric/util/Utils.kt index 18a442e..a0fec78 100644 --- a/src/main/kotlin/com/dulkirfabric/util/Utils.kt +++ b/src/main/kotlin/com/dulkirfabric/util/Utils.kt @@ -2,6 +2,7 @@ package com.dulkirfabric.util import com.dulkirfabric.events.PlaySoundEvent import com.dulkirfabric.events.SlayerBossEvents +import com.dulkirfabric.events.WorldLoadEvent import com.dulkirfabric.events.chat.ChatEvents import meteordevelopment.orbit.EventHandler import net.minecraft.block.entity.SkullBlockEntity @@ -12,6 +13,9 @@ import net.minecraft.nbt.NbtHelper import net.minecraft.util.math.Vec3d object Utils { + + private var inSlayerBoss = false + fun isInSkyblock(): Boolean { return ScoreBoardUtils.getLines() != null } @@ -47,6 +51,27 @@ object Utils { } } + @EventHandler + fun onSpawn(event: SlayerBossEvents.Spawn) { + inSlayerBoss = true + } + + @EventHandler + fun onSwap(event: WorldLoadEvent) { + if (inSlayerBoss) + SlayerBossEvents.Fail(ScoreBoardUtils.slayerType).post() + } + + @EventHandler + fun onKill(event: SlayerBossEvents.Kill) { + inSlayerBoss = false + } + + @EventHandler + fun onFail(event: SlayerBossEvents.Fail) { + inSlayerBoss = false + } + fun getSkullTexture(itemStack: ItemStack): String? { return itemStack.getSubNbt(SkullBlockEntity.SKULL_OWNER_KEY)?.let(NbtHelper::toGameProfile)?.properties?.get( PlayerSkinProvider.TEXTURES)?.first()?.value -- cgit