aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-10-28 02:10:11 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-10-28 02:10:11 +0200
commit804b5a55917c853e394a0c24fbb0cd22116994ce (patch)
tree0f97e300cec4e1dd4981720922741c2dbfbc94e6 /src/main
parent8bc5d988c2b8cece038027689b2b17521d5693d2 (diff)
downloadskyhanni-804b5a55917c853e394a0c24fbb0cd22116994ce.tar.gz
skyhanni-804b5a55917c853e394a0c24fbb0cd22116994ce.tar.bz2
skyhanni-804b5a55917c853e394a0c24fbb0cd22116994ce.zip
fixed weird error messages in damage indicator
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt13
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt2
2 files changed, 10 insertions, 5 deletions
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<String> = emptyList()): List<String> = buildList {
+private fun Throwable.getCustomStackTrace(full: Boolean, parent: List<String> = emptyList()): List<String> = buildList {
add("Caused by " + javaClass.name + ": $message")
val breakAfter = listOf(
@@ -94,6 +94,8 @@ private fun Throwable.getExactStackTrace(full: Boolean, parent: List<String> = 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<String> = 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<Entity> = 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)
}