diff options
author | Lorenz <lo.scherf@gmail.com> | 2022-08-07 11:35:32 +0200 |
---|---|---|
committer | Lorenz <lo.scherf@gmail.com> | 2022-08-07 11:35:32 +0200 |
commit | 6d4812dd42cf79d5e39fab37851ef1b633176eda (patch) | |
tree | 43a2866dc3c09d7be91d4979960d9d98927c7300 /src/main/java/at/hannibal2/skyhanni/test/CopyNearbyEntitiesCommand.kt | |
parent | 554d2d2a0b43036d807bcee45ded670a23c4a333 (diff) | |
download | skyhanni-6d4812dd42cf79d5e39fab37851ef1b633176eda.tar.gz skyhanni-6d4812dd42cf79d5e39fab37851ef1b633176eda.tar.bz2 skyhanni-6d4812dd42cf79d5e39fab37851ef1b633176eda.zip |
moved copy nearby entity command into single class
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/test/CopyNearbyEntitiesCommand.kt')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/test/CopyNearbyEntitiesCommand.kt | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/test/CopyNearbyEntitiesCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/CopyNearbyEntitiesCommand.kt new file mode 100644 index 000000000..c8126e05d --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/test/CopyNearbyEntitiesCommand.kt @@ -0,0 +1,101 @@ +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.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 = minecraft.thePlayer.position.toLorenzVec() + 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 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!") + } + } + } +}
\ No newline at end of file |