diff options
author | CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> | 2023-05-10 17:42:26 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-10 09:42:26 +0200 |
commit | b7b4c4bde154e6177d03367024a6537133841309 (patch) | |
tree | d8a6f03816501674971b9e49c76ae10a42c17d21 /src/main/java/at/hannibal2/skyhanni | |
parent | e5d9561f8cdedff4c29a5b6153997a10ceaae921 (diff) | |
download | skyhanni-b7b4c4bde154e6177d03367024a6537133841309.tar.gz skyhanni-b7b4c4bde154e6177d03367024a6537133841309.tar.bz2 skyhanni-b7b4c4bde154e6177d03367024a6537133841309.zip |
Fix features and copy error (#97)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
6 files changed, 56 insertions, 15 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 2d69881c9..162e62e2f 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -268,13 +268,14 @@ class SkyHanniMod { loadModule(ChumBucketHider()) loadModule(GardenRecentTeleportPadsDisplay()) loadModule(InquisitorWaypointShare) - loadModule(CopyNearbyParticlesCommand) loadModule(TrevorFeatures()) loadModule(TrevorSolver) init() + // test stuff loadModule(SkyHanniTestCommand()) + loadModule(CopyNearbyParticlesCommand) 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 26bb65e56..23e478ade 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -83,6 +83,7 @@ object Commands { registerCommand("shcopyparticles") { CopyNearbyParticlesCommand.command(it) } registerCommand("shtestpacket") { PacketTest.toggle() } registerCommand("shtestmessage") { TestChatCommand.command(it) } + registerCommand("shcopyerror") { CopyErrorCommand.command() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTimer.kt index afdd55e87..6c43f92f1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTimer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTimer.kt @@ -6,6 +6,8 @@ import at.hannibal2.skyhanni.events.CropClickEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.VisitorArrivalEvent import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.test.command.CopyErrorCommand +import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher @@ -39,7 +41,13 @@ class GardenVisitorTimer { init { fixedRateTimer(name = "skyhanni-update-visitor-display", period = 1000L) { - updateVisitorDisplay() + try { + updateVisitorDisplay() + } catch (error: Throwable) { + CopyErrorCommand.errorMessage = error.toString() + CopyErrorCommand.errorStackTrace = error.stackTrace.asList() + LorenzUtils.chat("§c[SkyHanni] encountered an error when updating visitor display, please run /shcopyerror") + } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt index 69a5a0548..35831f55c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt @@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.withAlpha import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled +import at.hannibal2.skyhanni.test.command.CopyErrorCommand import at.hannibal2.skyhanni.utils.* import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText @@ -50,9 +51,15 @@ class TrevorFeatures { init { fixedRateTimer(name = "skyhanni-update-trapper", period = 1000L) { - if (onFarmingIsland()) { - updateTrapper() - TrevorSolver.findMob() + try { + if (onFarmingIsland()) { + updateTrapper() + TrevorSolver.findMob() + } + } catch (error: Throwable) { + CopyErrorCommand.errorMessage = error.toString() + CopyErrorCommand.errorStackTrace = error.stackTrace.asList() + LorenzUtils.chat("§c[SkyHanni] encountered an error when updating the trapper solver, please run /shcopyerror") } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorSolver.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorSolver.kt index 3d6c91417..46b367e7d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorSolver.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorSolver.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.toLorenzVec import net.minecraft.client.Minecraft +import net.minecraft.client.entity.EntityOtherPlayerMP import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.item.EntityArmorStand @@ -42,33 +43,35 @@ object TrevorSolver { val world = Minecraft.getMinecraft().theWorld ?: return for (entity in world.getLoadedEntityList()) { val name = entity.name - // looking at 2 diff entities rn + if (entity is EntityOtherPlayerMP) continue + // looking at 2 diff entities rn - Mostly fixed I think as it returns val entityHealth = if (entity is EntityLivingBase) entity.baseMaxHealth else 0 if (intArrayOf(100, 500, 1000, 5000, 10000).any { it == entityHealth }) { if (animalNames.any { it == name }) { if (LocationUtils.canSee(LocationUtils.playerLocation(), entity.position.toLorenzVec())) { - if (entity.isInvisibleToPlayer(Minecraft.getMinecraft().thePlayer)) return - - if (foundID == entity.entityId) { - mobLocation = CurrentMobArea.FOUND - mobCoordinates = entity.position.toLorenzVec() - } else { - foundID = entity.entityId + if (!entity.isInvisibleToPlayer(Minecraft.getMinecraft().thePlayer)) { + if (foundID == entity.entityId) { + mobLocation = CurrentMobArea.FOUND + mobCoordinates = entity.position.toLorenzVec() + } else { + foundID = entity.entityId + } + return } - return } } } if (entity is EntityArmorStand) { for (animal in animalNames) { - if (name.contains(animal)) { + if (name.contains(animal) && name.contains("§c❤")) { if (foundID == entity.entityId) { mobLocation = CurrentMobArea.FOUND mobCoordinates = entity.position.toLorenzVec() } else { foundID = entity.entityId } + return } } } diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/CopyErrorCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/command/CopyErrorCommand.kt new file mode 100644 index 000000000..e2fbd98c5 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/test/command/CopyErrorCommand.kt @@ -0,0 +1,21 @@ +package at.hannibal2.skyhanni.test.command + +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.OSUtils + +object CopyErrorCommand { + var errorMessage = "" + var errorStackTrace = listOf<StackTraceElement>() + fun command() { + try { + if (errorMessage == "") LorenzUtils.chat("§c[SkyHanni] no error to copy") else { + val result = errorMessage + "\nCaused at:\n" + errorStackTrace.joinToString("\n") + OSUtils.copyToClipboard(result) + LorenzUtils.chat("§e[SkyHanni] error message copied into the clipboard, please report it on the SkyHanni discord!") + } + } catch (error: Throwable) { + OSUtils.copyToClipboard(error.toString()) + LorenzUtils.chat("§c[SkyHanni] error occurred while fetching error, please report this on the SkyHanni discord!") + } + } +}
\ No newline at end of file |