Skip to content

Commit

Permalink
add build path to config (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
12rcu authored Jul 22, 2024
1 parent fdf9145 commit ee79ae0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/main/kotlin/com/lop/devtools/monstera/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ fun loadConfig(
else
MonsteraLocalConfig()

val buildPath = Path(
System.getProperty("user.dir"),
monsteraLocalConfig.buildPath,
)
val behPath = Path(
System.getProperty("user.dir"),
monsteraLocalConfig.buildPath,
Expand Down Expand Up @@ -90,6 +94,7 @@ fun loadConfig(
resModUUID = UUID.fromString(monsteraConfig.resModuleUUID),
targetMcVersion = monsteraConfig.targetMcVersion,
hashFileNames = monsteraConfig.hashFileNames,
buildPath = buildPath,
behPath = behPath,
resPath = resPath,
scriptingVersion = monsteraConfig.scriptingVersion ?: "",
Expand Down Expand Up @@ -267,6 +272,10 @@ class Config(
"games",
"com.mojang"
),
var buildPath: Path = Path(
System.getProperty("user.dir"),
"build",
),
var paths: AddonPaths = AddonPaths(behPath, resPath),
var targetMcVersion: MutableList<Int> = arrayListOf(1, 20, 70),
var formatVersions: FormatVersions = FormatVersions(getVersionAsString(targetMcVersion)),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.lop.devtools.monstera.addon.dev

import com.lop.devtools.monstera.addon.Addon
import java.io.File
import java.io.FileNotFoundException
import java.io.InputStream
import kotlin.io.path.Path


@Suppress("unused")
Expand All @@ -13,7 +15,12 @@ object ResourceLoader {
}

fun getDefaultTexture(): File {
val tmp = File("build/tmp/monstera/default_texture.png")
val buildPath = Addon.active?.config?.buildPath ?: Path(
System.getProperty("user.dir"),
"build",
)

val tmp = buildPath.resolve("tmp").resolve("monstera").resolve("default_texture.png").toFile()
if(!tmp.exists()) {
tmp.parentFile.mkdirs()
tmp.createNewFile()
Expand All @@ -23,7 +30,12 @@ object ResourceLoader {
}

fun getDefaultModel(): File {
val tmp = File("build/tmp/monstera/default_model.geo.json")
val buildPath = Addon.active?.config?.buildPath ?: Path(
System.getProperty("user.dir"),
"build",
)

val tmp = buildPath.resolve("tmp").resolve("monstera").resolve("default_model.geo.json").toFile()
if(!tmp.exists()) {
tmp.parentFile.mkdirs()
tmp.createNewFile()
Expand Down

0 comments on commit ee79ae0

Please sign in to comment.