diff options
author | ronald <inglettronald@gmail.com> | 2023-07-30 17:51:53 -0500 |
---|---|---|
committer | ronald <inglettronald@gmail.com> | 2023-07-30 17:51:53 -0500 |
commit | 1078df493e6473f0b5cfa0409857c16e6fd60f53 (patch) | |
tree | 6f335b70aa60dbb7ab0ffa81ffffcd12f3aebcef /src | |
parent | cb1c7a0db3ba8990c65dce812a435bc1abadd369 (diff) | |
download | DulkirMod-Fabric-1078df493e6473f0b5cfa0409857c16e6fd60f53.tar.gz DulkirMod-Fabric-1078df493e6473f0b5cfa0409857c16e6fd60f53.tar.bz2 DulkirMod-Fabric-1078df493e6473f0b5cfa0409857c16e6fd60f53.zip |
Added fallback for players lobbyswapping to flee slayer boss to event system
Diffstat (limited to 'src')
-rw-r--r-- | src/main/kotlin/com/dulkirfabric/events/SlayerBossEvents.kt | 2 | ||||
-rw-r--r-- | src/main/kotlin/com/dulkirfabric/util/Utils.kt | 25 |
2 files changed, 26 insertions, 1 deletions
diff --git a/src/main/kotlin/com/dulkirfabric/events/SlayerBossEvents.kt b/src/main/kotlin/com/dulkirfabric/events/SlayerBossEvents.kt index 7097ccb..e1138fb 100644 --- a/src/main/kotlin/com/dulkirfabric/events/SlayerBossEvents.kt +++ b/src/main/kotlin/com/dulkirfabric/events/SlayerBossEvents.kt @@ -14,7 +14,7 @@ class SlayerBossEvents { ): Event() data class Fail( - val type: String, + val type: String?, var timestamp: Long = System.currentTimeMillis() ): Event() } 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 |