From 245e1303b1d29ca373509d8190ae20366d5cf2ff Mon Sep 17 00:00:00 2001 From: Lorenz Date: Fri, 15 Jul 2022 23:59:52 +0200 Subject: added /ii item info command --- .../skyhanni/config/commands/Commands.java | 44 +++++++----- .../java/at/hannibal2/skyhanni/test/LorenzTest.kt | 78 +++++++++++++++++++++- .../java/at/hannibal2/skyhanni/utils/ItemUtils.kt | 3 +- 3 files changed, 106 insertions(+), 19 deletions(-) (limited to 'src/main/java/at') diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.java b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.java index c2b60515f..4de83ad8a 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.java +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.java @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.config.commands; import at.hannibal2.skyhanni.SkyHanniMod; import at.hannibal2.skyhanni.config.config.ConfigEditor; import at.hannibal2.skyhanni.config.core.GuiScreenElementWrapper; +import at.hannibal2.skyhanni.test.LorenzTest; import net.minecraft.command.ICommandSender; import net.minecraftforge.client.ClientCommandHandler; import org.apache.commons.lang3.StringUtils; @@ -24,25 +25,36 @@ public class Commands { ClientCommandHandler.instance.registerCommand(new SimpleCommand("skyhanni", mainMenu)); ClientCommandHandler.instance.registerCommand( - new SimpleCommand( - "shreloadlocalrepo", - new SimpleCommand.ProcessCommandRunnable() { - public void processCommand(ICommandSender sender, String[] args) { - SkyHanniMod.repo.reloadLocalRepo(); - } - } - ) + new SimpleCommand( + "shreloadlocalrepo", + new SimpleCommand.ProcessCommandRunnable() { + public void processCommand(ICommandSender sender, String[] args) { + SkyHanniMod.repo.reloadLocalRepo(); + } + } + ) ); ClientCommandHandler.instance.registerCommand( - new SimpleCommand( - "shupdaterepo", - new SimpleCommand.ProcessCommandRunnable() { - public void processCommand(ICommandSender sender, String[] args) { - SkyHanniMod.repo.updateRepo(); - } - } - ) + new SimpleCommand( + "shupdaterepo", + new SimpleCommand.ProcessCommandRunnable() { + public void processCommand(ICommandSender sender, String[] args) { + SkyHanniMod.repo.updateRepo(); + } + } + ) + ); + + ClientCommandHandler.instance.registerCommand( + new SimpleCommand( + "ii", + new SimpleCommand.ProcessCommandRunnable() { + public void processCommand(ICommandSender sender, String[] args) { + LorenzTest.Companion.printLore(); + } + } + ) ); } } diff --git a/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt b/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt index 9cde01cc6..ad6a29443 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt @@ -1,10 +1,16 @@ package at.hannibal2.skyhanni.test import at.hannibal2.skyhanni.SkyHanniMod -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import at.hannibal2.skyhanni.utils.GuiRender.renderString +import at.hannibal2.skyhanni.utils.ItemUtil +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.minecraftforge.client.event.RenderGameOverlayEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class LorenzTest { @@ -15,6 +21,76 @@ class LorenzTest { var text = "" 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 = ItemUtil.getSkyBlockItemID(itemStack) + print("itemID: '$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) { + val element = compound.getCompoundTag(s) + runn(element, "$text ") + } + } + + private fun print(text: String) { + LorenzDebug.log(text) + } } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt index 6d84c7285..39eefff62 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt @@ -88,8 +88,7 @@ object ItemUtils { if (json.has("attributes")) { return true } - } catch (e: Exception) { - e.printStackTrace() + } catch (_: Exception) { } } } -- cgit