blob: 276e5477ab585181b90e97ada5a3c633df6e4eea (
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
|
package at.hannibal2.skyhanni.test.command
import at.hannibal2.skyhanni.data.mob.Mob
import at.hannibal2.skyhanni.data.mob.MobData
import at.hannibal2.skyhanni.data.mob.MobFilter.isDisplayNPC
import at.hannibal2.skyhanni.data.mob.MobFilter.isRealPlayer
import at.hannibal2.skyhanni.data.mob.MobFilter.isSkyBlockMob
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.EntityUtils.cleanName
import at.hannibal2.skyhanni.utils.EntityUtils.getBlockInHand
import at.hannibal2.skyhanni.utils.EntityUtils.getSkinTexture
import at.hannibal2.skyhanni.utils.EntityUtils.isNPC
import at.hannibal2.skyhanni.utils.ItemUtils.cleanName
import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture
import at.hannibal2.skyhanni.utils.ItemUtils.isEnchanted
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LocationUtils
import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth
import at.hannibal2.skyhanni.utils.OSUtils
import at.hannibal2.skyhanni.utils.toLorenzVec
import net.minecraft.client.entity.EntityOtherPlayerMP
import net.minecraft.entity.Entity
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.boss.EntityWither
import net.minecraft.entity.item.EntityArmorStand
import net.minecraft.entity.item.EntityItem
import net.minecraft.entity.monster.EntityCreeper
import net.minecraft.entity.monster.EntityEnderman
import net.minecraft.entity.monster.EntityMagmaCube
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.ItemStack
object CopyNearbyEntitiesCommand {
fun command(args: Array<String>) {
var searchRadius = 10
if (args.size == 1) {
searchRadius = args[0].toInt()
}
val start = LocationUtils.playerLocation()
val resultList = mutableListOf<String>()
var counter = 0
for (entity in EntityUtils.getAllEntities().sortedBy { it.entityId }) {
val position = entity.position
val vec = position.toLorenzVec()
val distance = start.distance(vec)
val mob = MobData.entityToMob[entity]
if (distance < searchRadius) {
val simpleName = entity.javaClass.simpleName
resultList.add("entity: $simpleName")
val displayName = entity.displayName
resultList.add("name: '" + entity.name + "'")
if (entity is EntityArmorStand) resultList.add("cleanName: '" + entity.cleanName() + "'")
resultList.add("displayName: '${displayName.formattedText}'")
resultList.add("entityId: ${entity.entityId}")
resultList.add("Type of Mob: ${getType(entity, mob)}")
resultList.add("uuid version: ${entity.uniqueID.version()} (${entity.uniqueID})")
resultList.add("location data:")
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 EntityLivingBase) {
resultList.add("EntityLivingBase:")
val baseMaxHealth = entity.baseMaxHealth
val health = entity.health.toInt()
resultList.add("- baseMaxHealth: $baseMaxHealth")
resultList.add("- health: $health")
}
if (entity is EntityPlayer) {
val inventory = entity.inventory
if (inventory != null) {
resultList.add("armor:")
for ((i, itemStack) in inventory.armorInventory.withIndex()) {
val name = itemStack?.name ?: "null"
resultList.add("- at: $i: $name")
}
}
}
when (entity) {
is EntityArmorStand -> {
resultList.add("EntityArmorStand:")
val headRotation = entity.headRotation.toLorenzVec()
val bodyRotation = entity.bodyRotation.toLorenzVec()
resultList.add("- headRotation: $headRotation")
resultList.add("- bodyRotation: $bodyRotation")
resultList.add("- inventory:")
for ((id, stack) in entity.inventory.withIndex()) {
resultList.add("- id $id ($stack)")
printItemStackData(stack, resultList)
}
}
is EntityEnderman -> {
resultList.add("EntityEnderman:")
val heldBlockState = entity.getBlockInHand()
resultList.add("- heldBlockState: $heldBlockState")
if (heldBlockState != null) {
val block = heldBlockState.block
resultList.add("- block: $block")
}
}
is EntityMagmaCube -> {
resultList.add("EntityMagmaCube:")
val squishFactor = entity.squishFactor
val slimeSize = entity.slimeSize
resultList.add("- factor: $squishFactor")
resultList.add("- slimeSize: $slimeSize")
}
is EntityItem -> {
resultList.add("EntityItem:")
val stack = entity.entityItem
val stackName = stack.name
val stackDisplayName = stack.displayName
val cleanName = stack.cleanName()
val itemEnchanted = stack.isEnchanted()
val itemDamage = stack.itemDamage
val stackSize = stack.stackSize
val maxStackSize = stack.maxStackSize
resultList.add("- name: '$stackName'")
resultList.add("- stackDisplayName: '$stackDisplayName'")
resultList.add("- cleanName: '$cleanName'")
resultList.add("- itemEnchanted: '$itemEnchanted'")
resultList.add("- itemDamage: '$itemDamage'")
resultList.add("- stackSize: '$stackSize'")
resultList.add("- maxStackSize: '$maxStackSize'")
}
is EntityOtherPlayerMP -> {
resultList.add("EntityOtherPlayerMP:")
val skinTexture = entity.getSkinTexture()
resultList.add("- skin texture: $skinTexture")
}
is EntityCreeper -> {
resultList.add("EntityCreeper:")
val creeperState = entity.creeperState
val ignite = entity.hasIgnited()
val powered = entity.powered
resultList.add("- creeperState: '$creeperState'")
resultList.add("- ignite: '$ignite'")
resultList.add("- powered: '$powered'")
}
is EntityWither -> {
resultList.add("EntityWither:")
val invulTime = entity.invulTime
resultList.add("- invulTime: '$invulTime'")
}
}
if (mob != null && mob.mobType != Mob.Type.PLAYER) {
resultList.add("MobInfo: ")
resultList.addAll(getMobInfo(mob).map { "- $it" })
}
resultList.add("")
resultList.add("")
counter++
}
}
if (counter != 0) {
val string = resultList.joinToString("\n")
OSUtils.copyToClipboard(string)
ChatUtils.chat("$counter entities copied into the clipboard!")
} else {
ChatUtils.chat("No entities found in a search radius of $searchRadius!")
}
}
private fun printItemStackData(stack: ItemStack?, resultList: MutableList<String>) {
if (stack != null) {
val skullTexture = stack.getSkullTexture()
if (skullTexture != null) {
resultList.add("- skullTexture:")
resultList.add("- $skullTexture")
}
val cleanName = stack.cleanName()
val stackName = stack.name
val type = stack.javaClass.name
resultList.add("- name: '$stackName'")
resultList.add("- cleanName: '$cleanName'")
resultList.add("- type: $type")
}
|