aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/features/debug/AnimatedClothingScanner.kt
blob: 11b47a97136f3ac8531426f42473bcdb35cc266f (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
package moe.nea.firmament.features.debug

import net.minecraft.component.DataComponentTypes
import net.minecraft.entity.Entity
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.commands.thenExecute
import moe.nea.firmament.commands.thenLiteral
import moe.nea.firmament.events.CommandEvent
import moe.nea.firmament.events.EntityUpdateEvent
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.skyBlockId
import moe.nea.firmament.util.tr

object AnimatedClothingScanner {

	var observedEntity: Entity? = null

	@OptIn(ExperimentalStdlibApi::class)
	@Subscribe
	fun onUpdate(event: EntityUpdateEvent) {
		if (event.entity != observedEntity) return
		if (event is EntityUpdateEvent.EquipmentUpdate) {
			event.newEquipment.forEach {
				val id = it.second.skyBlockId?.neuItem
				val colour = it.second.get(DataComponentTypes.DYED_COLOR)
					?.rgb?.toHexString(HexFormat.UpperCase)
					?.let { " #$it" } ?: ""
				MC.sendChat(tr("firmament.fitstealer.update",
				               "[FIT CHECK][${MC.currentTick}] ${it.first.asString()} => ${id}${colour}"))
			}
		}
	}

	@Subscribe
	fun onSubCommand(event: CommandEvent.SubCommand) {
		event.subcommand("dev") {
			thenLiteral("stealthisfit") {
				thenExecute {
					observedEntity =
						if (observedEntity == null) MC.instance.targetedEntity else null

					MC.sendChat(
						observedEntity?.let {
							tr("firmament.fitstealer.targeted", "Observing the equipment of ${it.name}.")
						} ?: tr("firmament.fitstealer.targetlost", "No longer logging equipment."),
					)
				}
			}
		}
	}
}