aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/test/CopyNearbyEntitiesCommand.kt
blob: 164e22755c26a35030328d51a7a8800153a7c57a (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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package at.hannibal2.skyhanni.test

import at.hannibal2.skyhanni.config.gui.utils.Utils
import at.hannibal2.skyhanni.utils.ItemUtils.cleanName
import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture
import at.hannibal2.skyhanni.utils.LocationUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth
import at.hannibal2.skyhanni.utils.toLorenzVec
import net.minecraft.client.Minecraft
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.item.EntityArmorStand
import net.minecraft.entity.monster.EntityMagmaCube

class CopyNearbyEntitiesCommand {

    companion object {

        fun testCommand(args: Array<String>) {
            var searchRadius = 10
            if (args.size == 1) {
                searchRadius = args[0].toInt()
            }

            val minecraft = Minecraft.getMinecraft()
            val start = LocationUtils.playerLocation()
            val world = minecraft.theWorld

            val resultList = mutableListOf<String>()
            var counter = 0

            for (entity in world.loadedEntityList) {
                val position = entity.position
                val vec = position.toLorenzVec()
                val distance = start.distance(vec)
                if (distance < searchRadius) {
                    resultList.add("found entity: '" + entity.name + "'")
                    val displayName = entity.displayName
                    resultList.add("displayName: '${displayName.formattedText}'")
                    val simpleName = entity.javaClass.simpleName
                    resultList.add("simpleName: $simpleName")
                    resultList.add("vec: $vec")
                    resultList.add("distance: $distance")

                    val rotationYaw = entity.rotationYaw
                    val rotationPitch = entity.rotationPitch
                    resultList.add("rotationYaw: $rotationYaw")
                    resultList.add("rotationPitch: $rotationPitch")

                    val riddenByEntity = entity.riddenByEntity
                    resultList.add("riddenByEntity: $riddenByEntity")
                    val ridingEntity = entity.ridingEntity
                    resultList.add("ridingEntity: $ridingEntity")


                    if (entity is EntityArmorStand) {
                        resultList.add("armor stand data:")
                        val headRotation = entity.headRotation.toLorenzVec()
                        val bodyRotation = entity.bodyRotation.toLorenzVec()
                        resultList.add("headRotation: $headRotation")
                        resultList.add("bodyRotation: $bodyRotation")

                        for ((id, stack) in entity.inventory.withIndex()) {
                            resultList.add("id $id = $stack")
                            if (stack != null) {
                                val skullTexture = stack.getSkullTexture()
                                if (skullTexture != null) {
                                    resultList.add("skullTexture: $skullTexture")
                                }
                                val cleanName = stack.cleanName()
                                val type = stack.javaClass.name
                                resultList.add("cleanName: $cleanName")
                                resultList.add("type: $type")

                            }
                        }
                    } else {
                        if (entity is EntityLivingBase) {
                            val baseMaxHealth = entity.baseMaxHealth
                            val health = entity.health.toInt()
                            resultList.add("baseMaxHealth: $baseMaxHealth")
                            resultList.add("health: $health")
                        }
                        if (entity is EntityMagmaCube) {
                            val squishFactor = entity.squishFactor
                            val slimeSize = entity.slimeSize
                            resultList.add("factor: $squishFactor")
                            resultList.add("slimeSize: $slimeSize")

                        }
                    }
                    resultList.add("")
                    resultList.add("")
                    counter++
                }
            }

            if (counter != 0) {
                val string = resultList.joinToString("\n")
                Utils.copyToClipboard(string)
                LorenzUtils.chat("§e$counter entities copied into the clipboard!")
            } else {
                LorenzUtils.chat("§eNo entities found in a search radius of $searchRadius!")
            }
        }
    }
}