From 92352ba052c1c3e403ef41493cbf57f8be63639b Mon Sep 17 00:00:00 2001 From: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Date: Sun, 7 May 2023 04:57:12 +1000 Subject: Added a few commands for debugging and testing (#93) --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 4 +- .../hannibal2/skyhanni/config/commands/Commands.kt | 22 +- .../damageindicator/DamageIndicatorManager.kt | 4 +- .../java/at/hannibal2/skyhanni/test/LorenzTest.kt | 394 --------------------- .../hannibal2/skyhanni/test/SkyHanniTestCommand.kt | 394 +++++++++++++++++++++ .../skyhanni/test/command/CopyItemCommand.kt | 4 +- .../skyhanni/test/command/CopyScoreboardCommand.kt | 25 ++ .../skyhanni/test/command/CopyTabListCommand.kt | 25 ++ .../skyhanni/test/command/TestChatCommand.kt | 20 ++ 9 files changed, 482 insertions(+), 410 deletions(-) delete mode 100644 src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/test/SkyHanniTestCommand.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/test/command/CopyScoreboardCommand.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/test/command/CopyTabListCommand.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/test/command/TestChatCommand.kt (limited to 'src/main/java/at/hannibal2') diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 00bd0a802..081e6a5b0 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -66,8 +66,8 @@ import at.hannibal2.skyhanni.features.slayer.blaze.HellionShieldHelper import at.hannibal2.skyhanni.features.summonings.SummoningMobManager import at.hannibal2.skyhanni.features.summonings.SummoningSoulsName import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper -import at.hannibal2.skyhanni.test.LorenzTest import at.hannibal2.skyhanni.test.PacketTest +import at.hannibal2.skyhanni.test.SkyHanniTestCommand import at.hannibal2.skyhanni.test.TestBingo import at.hannibal2.skyhanni.utils.MinecraftConsoleFilter.Companion.initLogging import at.hannibal2.skyhanni.utils.NEUVersionCheck.checkIfNeuIsLoaded @@ -270,7 +270,7 @@ class SkyHanniMod { init() - loadModule(LorenzTest()) + loadModule(SkyHanniTestCommand()) loadModule(ButtonOnPause()) loadModule(PacketTest()) loadModule(TestBingo) diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt index 0981fdaa4..2ecdb2d98 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -15,11 +15,10 @@ import at.hannibal2.skyhanni.features.garden.farming.CropSpeedMeter import at.hannibal2.skyhanni.features.minion.MinionFeatures import at.hannibal2.skyhanni.features.misc.CollectionCounter import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager -import at.hannibal2.skyhanni.test.LorenzTest import at.hannibal2.skyhanni.test.PacketTest +import at.hannibal2.skyhanni.test.SkyHanniTestCommand import at.hannibal2.skyhanni.test.TestBingo -import at.hannibal2.skyhanni.test.command.CopyItemCommand -import at.hannibal2.skyhanni.test.command.CopyNearbyEntitiesCommand +import at.hannibal2.skyhanni.test.command.* import at.hannibal2.skyhanni.utils.APIUtil import net.minecraft.command.ICommandSender import net.minecraftforge.client.ClientCommandHandler @@ -43,21 +42,23 @@ object Commands { registerCommand("skyhanni", openMainMenu) registerCommand("shreloadlocalrepo") { SkyHanniMod.repo.reloadLocalRepo() } registerCommand("shupdaterepo") { SkyHanniMod.repo.updateRepo() } - registerCommand("testhanni") { LorenzTest.testCommand(it) } - registerCommand("copylocation") { LorenzTest.copyLocation() } - registerCommand("copyentities") { CopyNearbyEntitiesCommand.command(it) } - registerCommand("copyitem") { CopyItemCommand.command(it) } + registerCommand("shtest") { SkyHanniTestCommand.testCommand(it) } + registerCommand("shcopylocation") { SkyHanniTestCommand.copyLocation() } + registerCommand("shcopyentities") { CopyNearbyEntitiesCommand.command(it) } + registerCommand("shcopytablist") { CopyTabListCommand.command(it) } + registerCommand("shcopyscoreboard") { CopyScoreboardCommand.command(it) } + registerCommand("shcopyitem") { CopyItemCommand.command(it) } registerCommand("shconfigsave") { SkyHanniMod.configManager.saveConfig("manual-command") } registerCommand("shmarkplayer") { MarkedPlayerManager.command(it) } registerCommand("shtestpacket") { PacketTest.toggle() } - registerCommand("shreloadlisteners") { LorenzTest.reloadListeners() } - registerCommand("shstoplisteners") { LorenzTest.stopListeners() } + registerCommand("shreloadlisteners") { SkyHanniTestCommand.reloadListeners() } + registerCommand("shstoplisteners") { SkyHanniTestCommand.stopListeners() } registerCommand("shresetburrowwarps") { BurrowWarpHelper.resetDisabledWarps() } registerCommand("shtrackcollection") { CollectionCounter.command(it) } registerCommand("shreloadbingodata") { BingoCardDisplay.command() } registerCommand("shprintbingohelper") { BingoNextStepHelper.command() } registerCommand("shsetapikey") { ApiDataLoader.command(it) } - registerCommand("shtestgardenvisitors") { LorenzTest.testGardenVisitors() } + registerCommand("shtestgardenvisitors") { SkyHanniTestCommand.testGardenVisitors() } registerCommand("shtogglehypixelapierrors") { APIUtil.toggleApiErrorMessages() } registerCommand("shcropspeedmeter") { CropSpeedMeter.toggle() } registerCommand("shcroptime") { GardenCropTimeCommand.onCommand(it) } @@ -65,6 +66,7 @@ object Commands { registerCommand("shclearcropspeed") { GardenAPI.clearCropSpeed() } registerCommand("shclearminiondata") { MinionFeatures.clearMinionData() } registerCommand("shtestbingo") { TestBingo.toggle() } + registerCommand("shtestmessage") { TestChatCommand.command(it) } } private fun registerCommand(name: String, function: (Array) -> Unit) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt index af6cfa997..93886069c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt @@ -8,7 +8,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.features.dungeon.DungeonData import at.hannibal2.skyhanni.features.slayer.blaze.HellionShield import at.hannibal2.skyhanni.features.slayer.blaze.setHellionShield -import at.hannibal2.skyhanni.test.LorenzTest +import at.hannibal2.skyhanni.test.SkyHanniTestCommand import at.hannibal2.skyhanni.utils.* import at.hannibal2.skyhanni.utils.EntityUtils.getNameTagWith import at.hannibal2.skyhanni.utils.EntityUtils.hasNameTagWith @@ -668,7 +668,7 @@ class DamageIndicatorManager { 270_000 / 2, 270_000 -> 1 1 -> 0 else -> { - LorenzTest.displayLine = "thorn has ${LorenzUtils.formatDouble(realHealth.toDouble())} hp!" + SkyHanniTestCommand.displayLine = "thorn has ${LorenzUtils.formatDouble(realHealth.toDouble())} hp!" LorenzUtils.error( "Unexpected health of thorn in m4! (${ LorenzUtils.formatDouble( diff --git a/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt b/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt deleted file mode 100644 index 8abe8e474..000000000 --- a/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt +++ /dev/null @@ -1,394 +0,0 @@ -package at.hannibal2.skyhanni.test - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.events.GuiRenderEvent -import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.events.PlaySoundEvent -import at.hannibal2.skyhanni.events.ReceiveParticleEvent -import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorColorNames -import at.hannibal2.skyhanni.utils.* -import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName -import at.hannibal2.skyhanni.utils.RenderUtils.renderString -import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems -import net.minecraft.nbt.NBTTagCompound -import net.minecraftforge.common.MinecraftForge -import net.minecraftforge.event.entity.player.ItemTooltipEvent -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import java.io.File - -class LorenzTest { - - companion object { - var displayLine = "" - var displayList = listOf>() - - var a = 1.0 - var b = 60.0 - var c = 0.0 - - val debugLogger = LorenzLogger("debug/test") - - 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) - } - - fun testCommand(args: Array) { - SoundUtils.playBeepSound() - -// for ((i, s) in ScoreboardData.sidebarLinesFormatted().withIndex()) { -// println("$i: '$s'") -// } - -// val name = args[0] -// val pitch = args[1].toFloat() -// val sound = SoundUtils.createSound("note.harp", 1.35f) -// val sound = SoundUtils.createSound("random.orb", 11.2f) -// SoundUtils.createSound(name, pitch).playSound() - - -// a = args[0].toDouble() -// b = args[1].toDouble() -// c = args[2].toDouble() - -// for (line in (Minecraft.getMinecraft().ingameGUI.tabList as AccessorGuiPlayerTabOverlay).footer.unformattedText -// .split("\n")) { -// println("footer: '$line'") -// } -// -// -// for (line in TabListUtils.getTabList()) { -// println("tablist: '$line'") -// } - } - - fun testGardenVisitors() { - if (displayList.isNotEmpty()) { - displayList = mutableListOf() - return - } - - val bigList = mutableListOf>() - var list = mutableListOf() - var i = 0 - var errors = 0 - for (item in GardenVisitorColorNames.visitorItems) { - val name = item.key - i++ - if (i == 5) { - i = 0 - bigList.add(list) - list = mutableListOf() - } - - val coloredName = GardenVisitorColorNames.getColoredName(name) - list.add("$coloredName§7 (") - for (itemName in item.value) { - try { - val internalName = NEUItems.getInternalName(itemName) - list.add(NEUItems.getItemStack(internalName)) - } catch (e: Error) { - LorenzUtils.debug("itemName '$itemName' is invalid for visitor '$name'") - errors++ - } - } - if (item.value.isEmpty()) { - list.add("Any") - } - list.add("§7) ") - } - bigList.add(list) - displayList = bigList - if (errors == 0) { - LorenzUtils.debug("Test garden visitor renderer: no errors") - } else { - LorenzUtils.debug("Test garden visitor renderer: $errors errors") - } - } - - fun reloadListeners() { - val blockedFeatures = try { - File("config/skyhanni/blocked-features.txt").readLines().toList() - } catch (e: Exception) { - emptyList() - } - - val modules = SkyHanniMod.modules - for (original in modules.toMutableList()) { - val javaClass = original.javaClass - val simpleName = javaClass.simpleName - MinecraftForge.EVENT_BUS.unregister(original) - println("Unregistered listener $simpleName") - - if (simpleName !in blockedFeatures) { - modules.remove(original) - val module = javaClass.newInstance() - modules.add(module) - - MinecraftForge.EVENT_BUS.register(module) - println("Registered listener $simpleName") - } else { - println("Skipped registering listener $simpleName") - } - } - LorenzUtils.chat("§e[SkyHanni] reloaded ${modules.size} listener classes.") - } - - fun stopListeners() { - val modules = SkyHanniMod.modules - for (original in modules.toMutableList()) { - val javaClass = original.javaClass - val simpleName = javaClass.simpleName - MinecraftForge.EVENT_BUS.unregister(original) - println("Unregistered listener $simpleName") - } - LorenzUtils.chat("§e[SkyHanni] stopped ${modules.size} listener classes.") - } - - fun copyLocation() { - val location = LocationUtils.playerLocation() - val x = LorenzUtils.formatDouble(location.x) - val y = LorenzUtils.formatDouble(location.y) - val z = LorenzUtils.formatDouble(location.z) - OSUtils.copyToClipboard("LorenzVec($x, $y, $z)") - } - } - - @SubscribeEvent - fun onItemTooltipLow(event: ItemTooltipEvent) { - if (!SkyHanniMod.feature.dev.debugEnabled) return - val itemStack = event.itemStack - if (itemStack != null) { - val internalName = itemStack.getInternalName() - event.toolTip.add("Internal Name: '$internalName'") - } - } - - @SubscribeEvent - fun onChatMessage(event: LorenzChatEvent) { - - } - - @SubscribeEvent - fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { - if (!LorenzUtils.inSkyBlock) return - if (!SkyHanniMod.feature.dev.debugEnabled) return - - SkyHanniMod.feature.dev.debugPos.renderString(displayLine, posLabel = "Test") - SkyHanniMod.feature.dev.debugPos.renderStringsAndItems(displayList, posLabel = "Test Display") - } - - @SubscribeEvent - fun onSoundPlay(event: PlaySoundEvent) { -// val location = event.location -// val distance = location.distanceToPlayer() -// val soundName = event.soundName -// val pitch = event.pitch -// val volume = event.volume - - //background music -// if (soundName == "note.harp") { -//// if (distance < 2) { -// -// -// //Wilderness -// val list = mutableListOf() -//// list.add(0.4920635) -//// list.add(0.74603176) -//// list.add(0.8888889) -//// list.add(1.1746032) -//// list.add(1.7777778) -//// list.add(0.5873016) -//// list.add(1f) -//// list.add(1.4920635) -//// list.add(0.4920635) -//// list.add(1.8730159) -//// list.add(0.82539684) -//// list.add(1.1111112) -//// list.add(1.6666666) -//// list.add(0.5555556) -//// list.add(0.6984127) -//// list.add(0.93650794) -//// list.add(1.4126984) -//// list.add(1.3333334) -//// list.add(1.5873016) -// -// if (pitch in list) { -// if (Minecraft.getMinecraft().thePlayer.isSneaking) { -// event.isCanceled = true -// } -// return -// } -// } - - - //diana ancestral spade -// if (soundName == "note.harp") { -// val list = mutableListOf() -// list.add(0.52380955f) -// list.add(0.5555556f) -// list.add(0.6031746f) -// list.add(0.63492066f) -// list.add(0.6825397f) -// list.add(0.71428573f) -// list.add(0.7619048f) -// list.add(0.7936508f) -// list.add(0.84126985f) -// list.add(0.8888889f) -// list.add(0.9206349f) -// list.add(0.96825397f) -// list.add(1.476191f) -// list.add(1.476191f) -// list.add(0.50793654f) -// list.add(0.6507937f) -// list.add(0.6984127f) -// list.add(0.74603176f) -// list.add(0.93650794f) -// list.add(0.984127f) -// list.add(1.968254f) -// list.add(0.4920635f) -// list.add(1.1587307f) -// list.add(1.1587301f) -// list.add(1.2857143f) -// list.add(1.4126984f) -// list.add(1.6825397f) -// list.add(1.8095238f) -// list.add(1.9365079f) -// list.add(1.4920635f) -// list.add(1.5396825f) -// list.add(0.8730159f) -// list.add(1.2539682f) -// list.add(1.4285715f) -// list.add(1.6190476f) -// list.add(1.4920635f) -// list.add(0.9047619f) -// list.add(1.1111112f) -// list.add(1.3174603f) -// list.add(1.5238096f) -// list.add(1.7301587f) -// -// list.add(0.5873016f) -// list.add(0.61904764f) -// list.add(0.6666667f) -// list.add(0.73015875f) -// list.add(0.7777778f) -// list.add(0.8095238f) -// list.add(0.8095238f) -// list.add(0.82539684f) -// -// list.add(0.5714286f) -// list.add(0.85714287f) -// list.add(1.3174603f) -// list.add(1.9523809f) -// list.add(1.1428572f) -// list.add(1.2063493f) -// list.add(1.2698413f) -// list.add(1.6349206f) -// list.add(1.2380953f) -// list.add(1.7936507f) -// list.add(1.9841269f) -// list.add(1.1746032f) -// list.add(1.3492063f) -// list.add(1.6984127f) -// list.add(1.8571428f) -// -// if (pitch in list) { -// return -// } -// } - - //use ancestral spade -// if (soundName == "mob.zombie.infect") { -// if (pitch == 1.968254f) { -// if (volume == 0.3f) { -// LorenzUtils.chat("used ancestral spade!") -// return -// } -// } -// } - - //wither shield activated -// if (soundName == "mob.zombie.remedy") { -// if (pitch == 0.6984127f) { -// if (volume == 1f) { -// return -// } -// } -// } - - //wither shield cooldown over -// if (soundName == "random.levelup") { -// if (pitch == 3f) { -// if (volume == 1f) { -// return -// } -// } -// } - - //teleport (hyp or aote) -// if (soundName == "mob.endermen.portal") { -// if (pitch == 1f && volume == 1f) { -// return -// } -// } - - //hyp wither impact -// if (soundName == "random.explode") { -// if (pitch == 1f && volume == 1f) { -// return -// } -// } - - //pick coins up -// if (soundName == "random.orb") { -// if (pitch == 1.4920635f && volume == 1f) { -// return -// } -// } - - -// if (soundName == "game.player.hurt") return -// if (soundName.startsWith("step.")) return - -// if (soundName != "mob.chicken.plop") return - -// println("") -// println("PlaySoundEvent") -// println("soundName: $soundName") -// println("distance: $distance") -// println("pitch: ${pitch}f") -// println("volume: ${volume}f") - } - - @SubscribeEvent - fun onParticlePlay(event: ReceiveParticleEvent) { -// val particleType = event.type -// val distance = LocationUtils.playerLocation().distance(event.location).round(2) -// -// println("") -// println("particleType: $particleType") -// -// val particleCount = event.count -// -// println("distance: $distance") -// -// val particleArgs = event.particleArgs -// println("args: " + particleArgs.size) -// for ((i, particleArg) in particleArgs.withIndex()) { -// println("$i $particleArg") -// } -// -// val particleSpeed = event.speed -// val offset = event.offset -// println("particleCount: $particleCount") -// println("particleSpeed: $particleSpeed") -// println("offset: $offset") - } -} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniTestCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniTestCommand.kt new file mode 100644 index 000000000..a320123a1 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniTestCommand.kt @@ -0,0 +1,394 @@ +package at.hannibal2.skyhanni.test + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.PlaySoundEvent +import at.hannibal2.skyhanni.events.ReceiveParticleEvent +import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorColorNames +import at.hannibal2.skyhanni.utils.* +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName +import at.hannibal2.skyhanni.utils.RenderUtils.renderString +import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems +import net.minecraft.nbt.NBTTagCompound +import net.minecraftforge.common.MinecraftForge +import net.minecraftforge.event.entity.player.ItemTooltipEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.io.File + +class SkyHanniTestCommand { + + companion object { + var displayLine = "" + var displayList = listOf>() + + var a = 1.0 + var b = 60.0 + var c = 0.0 + + val debugLogger = LorenzLogger("debug/test") + + 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) + } + + fun testCommand(args: Array) { + SoundUtils.playBeepSound() + +// for ((i, s) in ScoreboardData.sidebarLinesFormatted().withIndex()) { +// println("$i: '$s'") +// } + +// val name = args[0] +// val pitch = args[1].toFloat() +// val sound = SoundUtils.createSound("note.harp", 1.35f) +// val sound = SoundUtils.createSound("random.orb", 11.2f) +// SoundUtils.createSound(name, pitch).playSound() + + +// a = args[0].toDouble() +// b = args[1].toDouble() +// c = args[2].toDouble() + +// for (line in (Minecraft.getMinecraft().ingameGUI.tabList as AccessorGuiPlayerTabOverlay).footer.unformattedText +// .split("\n")) { +// println("footer: '$line'") +// } +// +// +// for (line in TabListUtils.getTabList()) { +// println("tablist: '$line'") +// } + } + + fun testGardenVisitors() { + if (displayList.isNotEmpty()) { + displayList = mutableListOf() + return + } + + val bigList = mutableListOf>() + var list = mutableListOf() + var i = 0 + var errors = 0 + for (item in GardenVisitorColorNames.visitorItems) { + val name = item.key + i++ + if (i == 5) { + i = 0 + bigList.add(list) + list = mutableListOf() + } + + val coloredName = GardenVisitorColorNames.getColoredName(name) + list.add("$coloredName§7 (") + for (itemName in item.value) { + try { + val internalName = NEUItems.getInternalName(itemName) + list.add(NEUItems.getItemStack(internalName)) + } catch (e: Error) { + LorenzUtils.debug("itemName '$itemName' is invalid for visitor '$name'") + errors++ + } + } + if (item.value.isEmpty()) { + list.add("Any") + } + list.add("§7) ") + } + bigList.add(list) + displayList = bigList + if (errors == 0) { + LorenzUtils.debug("Test garden visitor renderer: no errors") + } else { + LorenzUtils.debug("Test garden visitor renderer: $errors errors") + } + } + + fun reloadListeners() { + val blockedFeatures = try { + File("config/skyhanni/blocked-features.txt").readLines().toList() + } catch (e: Exception) { + emptyList() + } + + val modules = SkyHanniMod.modules + for (original in modules.toMutableList()) { + val javaClass = original.javaClass + val simpleName = javaClass.simpleName + MinecraftForge.EVENT_BUS.unregister(original) + println("Unregistered listener $simpleName") + + if (simpleName !in blockedFeatures) { + modules.remove(original) + val module = javaClass.newInstance() + modules.add(module) + + MinecraftForge.EVENT_BUS.register(module) + println("Registered listener $simpleName") + } else { + println("Skipped registering listener $simpleName") + } + } + LorenzUtils.chat("§e[SkyHanni] reloaded ${modules.size} listener classes.") + } + + fun stopListeners() { + val modules = SkyHanniMod.modules + for (original in modules.toMutableList()) { + val javaClass = original.javaClass + val simpleName = javaClass.simpleName + MinecraftForge.EVENT_BUS.unregister(original) + println("Unregistered listener $simpleName") + } + LorenzUtils.chat("§e[SkyHanni] stopped ${modules.size} listener classes.") + } + + fun copyLocation() { + val location = LocationUtils.playerLocation() + val x = LorenzUtils.formatDouble(location.x) + val y = LorenzUtils.formatDouble(location.y) + val z = LorenzUtils.formatDouble(location.z) + OSUtils.copyToClipboard("LorenzVec($x, $y, $z)") + } + } + + @SubscribeEvent + fun onItemTooltipLow(event: ItemTooltipEvent) { + if (!SkyHanniMod.feature.dev.debugEnabled) return + val itemStack = event.itemStack + if (itemStack != null) { + val internalName = itemStack.getInternalName() + event.toolTip.add("Internal Name: '$internalName'") + } + } + + @SubscribeEvent + fun onChatMessage(event: LorenzChatEvent) { + + } + + @SubscribeEvent + fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { + if (!LorenzUtils.inSkyBlock) return + if (!SkyHanniMod.feature.dev.debugEnabled) return + + SkyHanniMod.feature.dev.debugPos.renderString(displayLine, posLabel = "Test") + SkyHanniMod.feature.dev.debugPos.renderStringsAndItems(displayList, posLabel = "Test Display") + } + + @SubscribeEvent + fun onSoundPlay(event: PlaySoundEvent) { +// val location = event.location +// val distance = location.distanceToPlayer() +// val soundName = event.soundName +// val pitch = event.pitch +// val volume = event.volume + + //background music +// if (soundName == "note.harp") { +//// if (distance < 2) { +// +// +// //Wilderness +// val list = mutableListOf() +//// list.add(0.4920635) +//// list.add(0.74603176) +//// list.add(0.8888889) +//// list.add(1.1746032) +//// list.add(1.7777778) +//// list.add(0.5873016) +//// list.add(1f) +//// list.add(1.4920635) +//// list.add(0.4920635) +//// list.add(1.8730159) +//// list.add(0.82539684) +//// list.add(1.1111112) +//// list.add(1.6666666) +//// list.add(0.5555556) +//// list.add(0.6984127) +//// list.add(0.93650794) +//// list.add(1.4126984) +//// list.add(1.3333334) +//// list.add(1.5873016) +// +// if (pitch in list) { +// if (Minecraft.getMinecraft().thePlayer.isSneaking) { +// event.isCanceled = true +// } +// return +// } +// } + + + //diana ancestral spade +// if (soundName == "note.harp") { +// val list = mutableListOf() +// list.add(0.52380955f) +// list.add(0.5555556f) +// list.add(0.6031746f) +// list.add(0.63492066f) +// list.add(0.6825397f) +// list.add(0.71428573f) +// list.add(0.7619048f) +// list.add(0.7936508f) +// list.add(0.84126985f) +// list.add(0.8888889f) +// list.add(0.9206349f) +// list.add(0.96825397f) +// list.add(1.476191f) +// list.add(1.476191f) +// list.add(0.50793654f) +// list.add(0.6507937f) +// list.add(0.6984127f) +// list.add(0.74603176f) +// list.add(0.93650794f) +// list.add(0.984127f) +// list.add(1.968254f) +// list.add(0.4920635f) +// list.add(1.1587307f) +// list.add(1.1587301f) +// list.add(1.2857143f) +// list.add(1.4126984f) +// list.add(1.6825397f) +// list.add(1.8095238f) +// list.add(1.9365079f) +// list.add(1.4920635f) +// list.add(1.5396825f) +// list.add(0.8730159f) +// list.add(1.2539682f) +// list.add(1.4285715f) +// list.add(1.6190476f) +// list.add(1.4920635f) +// list.add(0.9047619f) +// list.add(1.1111112f) +// list.add(1.3174603f) +// list.add(1.5238096f) +// list.add(1.7301587f) +// +// list.add(0.5873016f) +// list.add(0.61904764f) +// list.add(0.6666667f) +// list.add(0.73015875f) +// list.add(0.7777778f) +// list.add(0.8095238f) +// list.add(0.8095238f) +// list.add(0.82539684f) +// +// list.add(0.5714286f) +// list.add(0.85714287f) +// list.add(1.3174603f) +// list.add(1.9523809f) +// list.add(1.1428572f) +// list.add(1.2063493f) +// list.add(1.2698413f) +// list.add(1.6349206f) +// list.add(1.2380953f) +// list.add(1.7936507f) +// list.add(1.9841269f) +// list.add(1.1746032f) +// list.add(1.3492063f) +// list.add(1.6984127f) +// list.add(1.8571428f) +// +// if (pitch in list) { +// return +// } +// } + + //use ancestral spade +// if (soundName == "mob.zombie.infect") { +// if (pitch == 1.968254f) { +// if (volume == 0.3f) { +// LorenzUtils.chat("used ancestral spade!") +// return +// } +// } +// } + + //wither shield activated +// if (soundName == "mob.zombie.remedy") { +// if (pitch == 0.6984127f) { +// if (volume == 1f) { +// return +// } +// } +// } + + //wither shield cooldown over +// if (soundName == "random.levelup") { +// if (pitch == 3f) { +// if (volume == 1f) { +// return +// } +// } +// } + + //teleport (hyp or aote) +// if (soundName == "mob.endermen.portal") { +// if (pitch == 1f && volume == 1f) { +// return +// } +// } + + //hyp wither impact +// if (soundName == "random.explode") { +// if (pitch == 1f && volume == 1f) { +// return +// } +// } + + //pick coins up +// if (soundName == "random.orb") { +// if (pitch == 1.4920635f && volume == 1f) { +// return +// } +// } + + +// if (soundName == "game.player.hurt") return +// if (soundName.startsWith("step.")) return + +// if (soundName != "mob.chicken.plop") return + +// println("") +// println("PlaySoundEvent") +// println("soundName: $soundName") +// println("distance: $distance") +// println("pitch: ${pitch}f") +// println("volume: ${volume}f") + } + + @SubscribeEvent + fun onParticlePlay(event: ReceiveParticleEvent) { +// val particleType = event.type +// val distance = LocationUtils.playerLocation().distance(event.location).round(2) +// +// println("") +// println("particleType: $particleType") +// +// val particleCount = event.count +// +// println("distance: $distance") +// +// val particleArgs = event.particleArgs +// println("args: " + particleArgs.size) +// for ((i, particleArg) in particleArgs.withIndex()) { +// println("$i $particleArg") +// } +// +// val particleSpeed = event.speed +// val offset = event.offset +// println("particleCount: $particleCount") +// println("particleSpeed: $particleSpeed") +// println("offset: $offset") + } +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/CopyItemCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/command/CopyItemCommand.kt index 92275ed69..10865a213 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/command/CopyItemCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/command/CopyItemCommand.kt @@ -1,6 +1,6 @@ package at.hannibal2.skyhanni.test.command -import at.hannibal2.skyhanni.test.LorenzTest +import at.hannibal2.skyhanni.test.SkyHanniTestCommand import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzUtils @@ -32,7 +32,7 @@ object CopyItemCommand { resultList.add("") resultList.add("ExtraAttributes") val extraAttributes = tagCompound.getCompoundTag("ExtraAttributes") - LorenzTest.runn(extraAttributes, " . ") + SkyHanniTestCommand.runn(extraAttributes, " . ") } } diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/CopyScoreboardCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/command/CopyScoreboardCommand.kt new file mode 100644 index 000000000..b53b2af19 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/test/command/CopyScoreboardCommand.kt @@ -0,0 +1,25 @@ +package at.hannibal2.skyhanni.test.command + +import at.hannibal2.skyhanni.data.ScoreboardData +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.OSUtils +import at.hannibal2.skyhanni.utils.StringUtils.removeColor + +object CopyScoreboardCommand { + fun command(args: Array) { + try { + val resultList = mutableListOf() + val noColor = args.size == 1 && args[0] == "true" + for (line in ScoreboardData.sidebarLinesFormatted) { + val scoreboardLine = if (noColor) line.removeColor() else line + resultList.add("'$scoreboardLine'") + } + val string = resultList.joinToString("\n") + OSUtils.copyToClipboard(string) + LorenzUtils.chat("§e[SkyHanni] scoreboard copied into the clipboard!") + } + catch (_: Throwable) { + LorenzUtils.chat("§c[SkyHanni] Nothing in scoreboard") + } + } +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/CopyTabListCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/command/CopyTabListCommand.kt new file mode 100644 index 000000000..65ec85d37 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/test/command/CopyTabListCommand.kt @@ -0,0 +1,25 @@ +package at.hannibal2.skyhanni.test.command + +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.OSUtils +import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import at.hannibal2.skyhanni.utils.TabListData + +object CopyTabListCommand { + fun command(args: Array) { + try { + val resultList = mutableListOf() + val noColor = args.size == 1 && args[0] == "true" + for (line in TabListData.getTabList()) { + val tabListLine = if (noColor) line.removeColor() else line + resultList.add("'$tabListLine'") + } + val string = resultList.joinToString("\n") + OSUtils.copyToClipboard(string) + LorenzUtils.chat("§e[SkyHanni] tablist copied into the clipboard!") + } + catch (_: Throwable) { + LorenzUtils.chat("§c[SkyHanni] Nothing in tablist") + } + } +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/TestChatCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/command/TestChatCommand.kt new file mode 100644 index 000000000..39740a8ec --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/test/command/TestChatCommand.kt @@ -0,0 +1,20 @@ +package at.hannibal2.skyhanni.test.command + +import at.hannibal2.skyhanni.utils.LorenzUtils +import net.minecraft.util.ChatComponentText +import net.minecraftforge.client.event.ClientChatReceivedEvent +import net.minecraftforge.common.MinecraftForge + +object TestChatCommand { + fun command(args: Array) { + if (args.isEmpty()) { + LorenzUtils.chat("§c[SkyHanni] Specify a chat message to test") + return + } + val rawMessage = args.toList().joinToString(" ") + LorenzUtils.chat("§a[SkyHanni] testing message: §7$rawMessage") + val formattedMessage = rawMessage.replace("&", "§") + LorenzUtils.chat(formattedMessage) + MinecraftForge.EVENT_BUS.post(ClientChatReceivedEvent(0, ChatComponentText(formattedMessage))) + } +} \ No newline at end of file -- cgit