Skip to content

Commit 7c27802

Browse files
committed
Pathing
1 parent 4c049a5 commit 7c27802

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

src/main/kotlin/cc/woverflow/crashpatch/CrashPatch.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import com.google.gson.stream.MalformedJsonException
99
import gg.essential.api.EssentialAPI
1010
import gg.essential.api.utils.Multithreading
1111
import gg.essential.universal.ChatColor
12+
import gg.essential.universal.UDesktop
1213
import net.minecraft.launchwrapper.Launch
1314
import net.minecraftforge.fml.common.Mod
1415
import net.minecraftforge.fml.common.event.FMLInitializationEvent
@@ -53,6 +54,14 @@ object CrashPatch {
5354
}
5455
return@let false
5556
} ?: false }
57+
val gameDir: File by lazy(LazyThreadSafetyMode.PUBLICATION) {
58+
try {
59+
if (Launch.minecraftHome.parentFile?.name == (if (UDesktop.isMac) "minecraft" else ".minecraft")) Launch.minecraftHome.parentFile else Launch.minecraftHome
60+
} catch (e: Exception) {
61+
e.printStackTrace()
62+
Launch.minecraftHome
63+
}
64+
}
5665

5766
@Mod.EventHandler
5867
fun onPreInit(e: FMLPreInitializationEvent) {

src/main/kotlin/cc/woverflow/crashpatch/gui/GuiCrashMenu.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ import gg.essential.universal.UDesktop
2525
import gg.essential.vigilance.gui.VigilancePalette
2626
import gg.essential.vigilance.utils.onLeftClick
2727
import net.minecraft.crash.CrashReport
28+
import net.minecraft.launchwrapper.Launch
2829
import java.awt.Color
30+
import java.io.File
2931
import java.io.IOException
3032

3133
class GuiCrashMenu @JvmOverloads constructor(val report: CrashReport, private val init: Boolean = false) : WindowScreen(version = ElementaVersion.V1) {
@@ -129,7 +131,7 @@ class GuiCrashMenu @JvmOverloads constructor(val report: CrashReport, private va
129131
textScale = 3.pixels()
130132
} childOf scrollableSolutions
131133
for (solution in list.value) {
132-
UIWrappedText(solution, centered = true) constrain {
134+
UIWrappedText(solution.replace("%gameroot%", CrashPatch.gameDir.absolutePath.removeSuffix(File.separator)).replace("%profileroot%", Launch.minecraftHome.absolutePath.removeSuffix(File.separator)), centered = true) constrain {
133135
x = 0.pixels()
134136
y = SiblingConstraint(4f)
135137
width = 100.percent()

src/main/kotlin/cc/woverflow/crashpatch/gui/GuiServerDisconnectMenu.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ import gg.essential.universal.ChatColor
2020
import gg.essential.universal.UDesktop
2121
import gg.essential.vigilance.gui.VigilancePalette
2222
import gg.essential.vigilance.utils.onLeftClick
23+
import net.minecraft.launchwrapper.Launch
2324
import net.minecraft.util.IChatComponent
2425
import java.awt.Color
26+
import java.io.File
2527
import java.io.IOException
2628

2729
class GuiServerDisconnectMenu(private val component: IChatComponent, reason: String) : WindowScreen(version = ElementaVersion.V1) {
@@ -115,7 +117,7 @@ class GuiServerDisconnectMenu(private val component: IChatComponent, reason: Str
115117
textScale = 3.pixels()
116118
} childOf scrollableSolutions
117119
for (solution in list.value) {
118-
UIWrappedText(solution, centered = true) constrain {
120+
UIWrappedText(solution.replace("%gameroot%", CrashPatch.gameDir.absolutePath.removeSuffix(File.separator)).replace("%profileroot%", Launch.minecraftHome.absolutePath.removeSuffix(File.separator)), centered = true) constrain {
119121
x = 0.pixels()
120122
y = SiblingConstraint(4f)
121123
width = 100.percent()

0 commit comments

Comments
 (0)