blob: a0fec78db5e0e87a24706565cc0d68e2a461685f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
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
import net.minecraft.client.texture.PlayerSkinProvider
import net.minecraft.entity.Entity
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NbtHelper
import net.minecraft.util.math.Vec3d
object Utils {
private var inSlayerBoss = false
fun isInSkyblock(): Boolean {
return ScoreBoardUtils.getLines() != null
}
/**
* Prints relevant information about a sound that is being displayed
*/
fun debugSound(event: PlaySoundEvent) {
if (event.sound.id.path == "entity.player.hurt") return
println("Path: ${event.sound.id.path}")
println("Pitch: ${event.sound.pitch}")
println("Volume: ${event.sound.volume}")
}
private fun lerp(prev: Vec3d, cur: Vec3d, tickDelta: Float): Vec3d {
return Vec3d(
prev.x + (cur.x - prev.x) * tickDelta,
prev.y + (cur.y - prev.y) * tickDelta,
prev.z + (cur.z - prev.z) * tickDelta,
)
}
fun Entity.getInterpolatedPos(tickDelta: Float): Vec3d {
val prevPos = Vec3d(this.prevX, this.prevY, this.prevZ)
return lerp(prevPos, this.pos, tickDelta)
}
@EventHandler
fun detectSlayerEvents(event: ChatEvents.AllowChat) {
if (event.message.string.trim() == "SLAYER QUEST COMPLETE!") {
SlayerBossEvents.Kill(ScoreBoardUtils.slayerType ?: return ScoreBoardUtils.err()).post()
} else if (event.message.string.trim() == "SLAYER QUEST FAILED!") {
SlayerBossEvents.Fail(ScoreBoardUtils.slayerType ?: return ScoreBoardUtils.err()).post()
}
}
@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
}
}
|