Skip to content

Commit

Permalink
Pathing
Browse files Browse the repository at this point in the history
  • Loading branch information
Wyvest committed Mar 15, 2022
1 parent 4c049a5 commit 7c27802
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/main/kotlin/cc/woverflow/crashpatch/CrashPatch.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.google.gson.stream.MalformedJsonException
import gg.essential.api.EssentialAPI
import gg.essential.api.utils.Multithreading
import gg.essential.universal.ChatColor
import gg.essential.universal.UDesktop
import net.minecraft.launchwrapper.Launch
import net.minecraftforge.fml.common.Mod
import net.minecraftforge.fml.common.event.FMLInitializationEvent
Expand Down Expand Up @@ -53,6 +54,14 @@ object CrashPatch {
}
return@let false
} ?: false }
val gameDir: File by lazy(LazyThreadSafetyMode.PUBLICATION) {
try {
if (Launch.minecraftHome.parentFile?.name == (if (UDesktop.isMac) "minecraft" else ".minecraft")) Launch.minecraftHome.parentFile else Launch.minecraftHome
} catch (e: Exception) {
e.printStackTrace()
Launch.minecraftHome
}
}

@Mod.EventHandler
fun onPreInit(e: FMLPreInitializationEvent) {
Expand Down
4 changes: 3 additions & 1 deletion src/main/kotlin/cc/woverflow/crashpatch/gui/GuiCrashMenu.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ import gg.essential.universal.UDesktop
import gg.essential.vigilance.gui.VigilancePalette
import gg.essential.vigilance.utils.onLeftClick
import net.minecraft.crash.CrashReport
import net.minecraft.launchwrapper.Launch
import java.awt.Color
import java.io.File
import java.io.IOException

class GuiCrashMenu @JvmOverloads constructor(val report: CrashReport, private val init: Boolean = false) : WindowScreen(version = ElementaVersion.V1) {
Expand Down Expand Up @@ -129,7 +131,7 @@ class GuiCrashMenu @JvmOverloads constructor(val report: CrashReport, private va
textScale = 3.pixels()
} childOf scrollableSolutions
for (solution in list.value) {
UIWrappedText(solution, centered = true) constrain {
UIWrappedText(solution.replace("%gameroot%", CrashPatch.gameDir.absolutePath.removeSuffix(File.separator)).replace("%profileroot%", Launch.minecraftHome.absolutePath.removeSuffix(File.separator)), centered = true) constrain {
x = 0.pixels()
y = SiblingConstraint(4f)
width = 100.percent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ import gg.essential.universal.ChatColor
import gg.essential.universal.UDesktop
import gg.essential.vigilance.gui.VigilancePalette
import gg.essential.vigilance.utils.onLeftClick
import net.minecraft.launchwrapper.Launch
import net.minecraft.util.IChatComponent
import java.awt.Color
import java.io.File
import java.io.IOException

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

0 comments on commit 7c27802

Please sign in to comment.