From 1021280302d684071a9bde3cf274a16913eb48ec Mon Sep 17 00:00:00 2001 From: Lorenz Date: Mon, 22 Aug 2022 02:32:27 +0200 Subject: removed /ii and created /copyitem --- .../skyhanni/config/gui/commands/Commands.java | 16 ++-- .../hannibal2/skyhanni/config/gui/utils/Utils.java | 71 ++------------ .../skyhanni/test/CopyNearbyEntitiesCommand.kt | 104 --------------------- .../java/at/hannibal2/skyhanni/test/LorenzTest.kt | 62 ------------ .../skyhanni/test/command/CopyItemCommand.kt | 48 ++++++++++ .../test/command/CopyNearbyEntitiesCommand.kt | 104 +++++++++++++++++++++ 6 files changed, 169 insertions(+), 236 deletions(-) delete mode 100644 src/main/java/at/hannibal2/skyhanni/test/CopyNearbyEntitiesCommand.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/test/command/CopyItemCommand.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/test/command/CopyNearbyEntitiesCommand.kt (limited to 'src/main/java/at/hannibal2') 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 cf2271eb9..17609296e 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,8 +3,9 @@ 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 at.hannibal2.skyhanni.test.command.CopyItemCommand; +import at.hannibal2.skyhanni.test.command.CopyNearbyEntitiesCommand; import net.minecraft.command.ICommandSender; import net.minecraftforge.client.ClientCommandHandler; import org.apache.commons.lang3.StringUtils; @@ -46,33 +47,32 @@ public class Commands { } ) ); - ClientCommandHandler.instance.registerCommand( new SimpleCommand( - "ii", + "testhanni", new SimpleCommand.ProcessCommandRunnable() { public void processCommand(ICommandSender sender, String[] args) { - LorenzTest.Companion.printLore(); + LorenzTest.Companion.testCommand(args); } } ) ); ClientCommandHandler.instance.registerCommand( new SimpleCommand( - "testhanni", + "copyentities", new SimpleCommand.ProcessCommandRunnable() { public void processCommand(ICommandSender sender, String[] args) { - LorenzTest.Companion.testCommand(args); + CopyNearbyEntitiesCommand.INSTANCE.command(args); } } ) ); ClientCommandHandler.instance.registerCommand( new SimpleCommand( - "copyentities", + "copyitem", new SimpleCommand.ProcessCommandRunnable() { public void processCommand(ICommandSender sender, String[] args) { - CopyNearbyEntitiesCommand.INSTANCE.command(args); + CopyItemCommand.INSTANCE.command(args); } } ) diff --git a/src/main/java/at/hannibal2/skyhanni/config/gui/utils/Utils.java b/src/main/java/at/hannibal2/skyhanni/config/gui/utils/Utils.java index 6b5bb8097..51ffd0c8d 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/gui/utils/Utils.java +++ b/src/main/java/at/hannibal2/skyhanni/config/gui/utils/Utils.java @@ -1,13 +1,5 @@ package at.hannibal2.skyhanni.config.gui.utils; -import java.awt.*; -import java.awt.datatransfer.StringSelection; -import java.math.RoundingMode; -import java.nio.FloatBuffer; -import java.text.DecimalFormat; -import java.text.DecimalFormatSymbols; -import java.util.LinkedList; -import java.util.Locale; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.ScaledResolution; @@ -26,6 +18,15 @@ import org.lwjgl.BufferUtils; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL14; +import java.awt.*; +import java.awt.datatransfer.StringSelection; +import java.math.RoundingMode; +import java.nio.FloatBuffer; +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; +import java.util.LinkedList; +import java.util.Locale; + public class Utils { private static final LinkedList guiScales = new LinkedList<>(); @@ -70,60 +71,6 @@ public class Utils { return tag != null && tag.hasKey("drill_fuel"); } - public static int whatRomanNumeral(String roman) { - switch (roman.toLowerCase()) { - case "i": - return 1; - case "ii": - return 2; - case "iii": - return 3; - case "iv": - return 4; - case "v": - return 5; - case "vi": - return 6; - case "vii": - return 7; - case "viii": - return 8; - case "ix": - return 9; - case "x": - return 10; - default: - return 0; - } - } - - public static String intToRomanNumeral(int i) { - switch (i) { - case 1: - return "I"; - case 2: - return "II"; - case 3: - return "III"; - case 4: - return "IV"; - case 5: - return "V"; - case 6: - return "VI"; - case 7: - return "VII"; - case 8: - return "VIII"; - case 9: - return "IX"; - case 10: - return "X"; - default: - return ""; - } - } - public static boolean overlayShouldRender(RenderGameOverlayEvent.ElementType type, boolean... booleans) { return overlayShouldRender(false, type, RenderGameOverlayEvent.ElementType.HOTBAR, booleans); } diff --git a/src/main/java/at/hannibal2/skyhanni/test/CopyNearbyEntitiesCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/CopyNearbyEntitiesCommand.kt deleted file mode 100644 index 262d5892e..000000000 --- a/src/main/java/at/hannibal2/skyhanni/test/CopyNearbyEntitiesCommand.kt +++ /dev/null @@ -1,104 +0,0 @@ -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 - -object CopyNearbyEntitiesCommand { - - fun command(args: Array) { - 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() - 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!") - } - } -} \ 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 d6f90d7b0..e628ec124 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt @@ -3,12 +3,8 @@ package at.hannibal2.skyhanni.test import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.PacketEvent import at.hannibal2.skyhanni.utils.GuiRender.renderString -import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName -import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzDebug import at.hannibal2.skyhanni.utils.LorenzLogger -import at.hannibal2.skyhanni.utils.LorenzUtils -import net.minecraft.client.Minecraft import net.minecraft.nbt.NBTTagCompound import net.minecraft.network.play.server.S0EPacketSpawnObject import net.minecraft.network.play.server.S0FPacketSpawnMob @@ -28,64 +24,6 @@ class LorenzTest { val debugLogger = LorenzLogger("debug/test") - fun printLore() { - try { - val itemStack = Minecraft.getMinecraft().thePlayer.inventory.getCurrentItem()!! - print("===") - print("ITEM LORE") - print("display name: '" + itemStack.displayName.toString() + "'") - val itemID = itemStack.getInternalName() - print("internalName: '$itemID'") -// val rarity: ItemRarityOld = ItemUtils.getRarity(itemStack) -// print("rarity: '$rarity'") - print("") - for (line in itemStack.getLore()) { - print("'$line'") - println(line) - } - print("") - print("getTagCompound") - if (itemStack.hasTagCompound()) { - val tagCompound = itemStack.tagCompound - for (s in tagCompound.keySet) { - print(" '$s'") - } - if (tagCompound.hasKey("ExtraAttributes")) { - print("") - print("ExtraAttributes") - val extraAttributes = tagCompound.getCompoundTag("ExtraAttributes") -// for (s in extraAttributes.keySet) { -// print(" '$s'") -// } -// if (extraAttributes.hasKey("enchantments")) { -// print("") -// print("enchantments") -// val enchantments = extraAttributes.getCompoundTag("enchantments") -// for (s in enchantments.keySet) { -// val level = enchantments.getInteger(s) -// print(" '$s' = $level") -// } -// } -// if (extraAttributes.hasKey("modifier")) { -// print("") -// print("modifier") -// val enchantments = extraAttributes.getCompoundTag("modifier") -// for (s in enchantments.keySet) { -// print(" '$s'") -// } -// } - - runn(extraAttributes, " . ") - } - } - print("") - print("===") - LorenzUtils.debug("item info printed!") - } catch (_: Throwable) { - LorenzUtils.error("Hold an item in the hand to see its item infos!") - } - } - fun runn(compound: NBTTagCompound, text: String) { print("$text'$compound'") for (s in compound.keySet) { diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/CopyItemCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/command/CopyItemCommand.kt new file mode 100644 index 000000000..854ab26eb --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/test/command/CopyItemCommand.kt @@ -0,0 +1,48 @@ +package at.hannibal2.skyhanni.test.command + +import at.hannibal2.skyhanni.config.gui.utils.Utils +import at.hannibal2.skyhanni.test.LorenzTest +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName +import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.LorenzUtils +import net.minecraft.client.Minecraft + +object CopyItemCommand { + + fun command(args: Array) { + try { + val resultList = mutableListOf() + val itemStack = Minecraft.getMinecraft().thePlayer.inventory.getCurrentItem()!! + resultList.add("ITEM LORE") + resultList.add("display name: '" + itemStack.displayName.toString() + "'") + val itemID = itemStack.getInternalName() + resultList.add("internalName: '$itemID'") + resultList.add("") + for (line in itemStack.getLore()) { + resultList.add("'$line'") + println(line) + } + resultList.add("") + resultList.add("getTagCompound") + if (itemStack.hasTagCompound()) { + val tagCompound = itemStack.tagCompound + for (s in tagCompound.keySet) { + resultList.add(" '$s'") + } + if (tagCompound.hasKey("ExtraAttributes")) { + resultList.add("") + resultList.add("ExtraAttributes") + val extraAttributes = tagCompound.getCompoundTag("ExtraAttributes") + LorenzTest.runn(extraAttributes, " . ") + } + } + + val string = resultList.joinToString("\n") + Utils.copyToClipboard(string) + LorenzUtils.debug("item info printed!") + LorenzUtils.chat("§e[SkyHanni] item info copied into the clipboard!") + } catch (_: Throwable) { + LorenzUtils.chat("§c[SkyHanni] No item in hand!") + } + } +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/CopyNearbyEntitiesCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/command/CopyNearbyEntitiesCommand.kt new file mode 100644 index 000000000..c5a05d94a --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/test/command/CopyNearbyEntitiesCommand.kt @@ -0,0 +1,104 @@ +package at.hannibal2.skyhanni.test.command + +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 + +object CopyNearbyEntitiesCommand { + + fun command(args: Array) { + 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() + 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[SkyHanni] $counter entities copied into the clipboard!") + } else { + LorenzUtils.chat("§e[SkyHanni] No entities found in a search radius of $searchRadius!") + } + } +} \ No newline at end of file -- cgit