blob: 0401746c4edb1562a91650319ff92e27db36d67f (
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
|
package at.hannibal2.skyhanni.data
import at.hannibal2.skyhanni.data.mob.Mob
import at.hannibal2.skyhanni.events.MobEvent
import at.hannibal2.skyhanni.events.entity.slayer.SlayerDeathEvent
import at.hannibal2.skyhanni.features.slayer.SlayerType
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.test.command.ErrorManager
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@SkyHanniModule
object OtherPlayersSlayerAPI {
@SubscribeEvent
fun onMobDespawn(event: MobEvent.DeSpawn.SkyblockMob) {
val mob = event.mob
// no death, rather despawn because too far away
if (mob.baseEntity.health != 0f) return
if (mob.mobType != Mob.Type.SLAYER) return
val owner = mob.owner?.ownerName
val tier = mob.levelOrTier
val name = mob.name
val slayerType = SlayerType.getByName(name) ?: run {
ErrorManager.logErrorStateWithData(
"Unknown slayer type found", "unknown slayer",
"name" to name,
)
return
}
SlayerDeathEvent(slayerType, tier, owner).post()
}
}
|