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 | |
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')
3 files changed, 112 insertions, 75 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/gui/commands/Commands.java b/src/main/java/at/hannibal2/skyhanni/config/gui/commands/Commands.java index 72e6c0ea1..fe3a6f791 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/gui/commands/Commands.java +++ b/src/main/java/at/hannibal2/skyhanni/config/gui/commands/Commands.java @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.config.gui.commands; import at.hannibal2.skyhanni.SkyHanniMod; import at.hannibal2.skyhanni.config.gui.config.ConfigEditor; import at.hannibal2.skyhanni.config.gui.core.GuiScreenElementWrapper; +import at.hannibal2.skyhanni.test.CopyNearbyEntitiesCommand; import at.hannibal2.skyhanni.test.LorenzTest; import net.minecraft.command.ICommandSender; import net.minecraftforge.client.ClientCommandHandler; @@ -66,5 +67,15 @@ public class Commands { } ) ); + ClientCommandHandler.instance.registerCommand( + new SimpleCommand( + "copyentities", + new SimpleCommand.ProcessCommandRunnable() { + public void processCommand(ICommandSender sender, String[] args) { + CopyNearbyEntitiesCommand.Companion.testCommand(args); + } + } + ) + ); } } 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 diff --git a/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt b/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt index 54aa15534..428a86d9f 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt @@ -99,82 +99,7 @@ class LorenzTest { } fun testCommand() { - 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 < 10) { - 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 to clipboard!") - } else { - LorenzUtils.chat("§eNo entities in radius from 10 found!") - } } } |