From 804b5a55917c853e394a0c24fbb0cd22116994ce Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 28 Oct 2023 02:10:11 +0200 Subject: fixed weird error messages in damage indicator --- .../java/at/hannibal2/skyhanni/test/command/ErrorManager.kt | 13 +++++++++---- src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt b/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt index adf8d2637..0e785a054 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt @@ -69,8 +69,8 @@ object ErrorManager { cache.put(pair, Unit) } - val fullStackTrace = throwable.getExactStackTrace(true).joinToString("\n") - val stackTrace = throwable.getExactStackTrace(false).joinToString("\n").removeSpam() + val fullStackTrace = throwable.getCustomStackTrace(true).joinToString("\n") + val stackTrace = throwable.getCustomStackTrace(false).joinToString("\n").removeSpam() val randomId = UUID.randomUUID().toString() val rawMessage = message.removeColor() @@ -85,7 +85,7 @@ object ErrorManager { } } -private fun Throwable.getExactStackTrace(full: Boolean, parent: List = emptyList()): List = buildList { +private fun Throwable.getCustomStackTrace(full: Boolean, parent: List = emptyList()): List = buildList { add("Caused by " + javaClass.name + ": $message") val breakAfter = listOf( @@ -94,6 +94,8 @@ private fun Throwable.getExactStackTrace(full: Boolean, parent: List = e val replace = mapOf( "io.mouberry,notenoughupdates" to "NEU", "at.hannibal2.skyhanni" to "SH", + "net.minecraft." to "MC.", + "net.minecraftforge.fml." to "FML.", ) for (traceElement in stackTrace) { @@ -115,7 +117,7 @@ private fun Throwable.getExactStackTrace(full: Boolean, parent: List = e } cause?.let { - addAll(it.getExactStackTrace(full, this)) + addAll(it.getCustomStackTrace(full, this)) } } @@ -137,6 +139,9 @@ private fun String.removeSpam(): String { "LorenzEvent.postAndCatch(LorenzEvent.kt:15)", "at net.minecraft.launchwrapper.", "at net.fabricmc.devlaunchinjector.", + "at SH.events.LorenzEvent.postAndCatchAndBlock(LorenzEvent.kt:28)", + "at SH.events.LorenzEvent.postAndCatchAndBlock\$default(LorenzEvent.kt:18)", + "at SH.events.LorenzEvent.postAndCatch(LorenzEvent.kt:16)", ) return split("\n").filter { line -> !ignored.any { line.contains(it) } }.joinToString("\n") } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt index ec8b61b5f..8e0cd9fdb 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt @@ -152,7 +152,7 @@ object EntityUtils { fun getAllEntities(): Sequence = Minecraft.getMinecraft()?.theWorld?.loadedEntityList?.let { if (Minecraft.getMinecraft().isCallingFromMinecraftThread) it else it.toMutableList() - }?.asSequence() ?: emptySequence() + }?.asSequence()?.filterNotNull() ?: emptySequence() fun Entity.canBeSeen(radius: Double = 150.0) = getLorenzVec().add(y = 0.5).canBeSeen(radius) } -- cgit