Skip to content

Commit

Permalink
fixed the bug
Browse files Browse the repository at this point in the history
Signed-off-by: Lyzev <[email protected]>
  • Loading branch information
Lyzev committed May 25, 2024
1 parent 1f326d0 commit 2bc1ee7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 13 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ loom {
tasks.register("fixRunResources") {
group = project.extra["archives_base_name"] as String
description = "Fix Run Resources"
dependsOn("generateProperties", "processResources")
dependsOn("processResources")
doLast {
copy {
from("build/resources/main")
Expand Down
3 changes: 1 addition & 2 deletions src/main/kotlin/dev/lyzev/api/imgui/font/ImGuiFonts.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ enum class ImGuiFonts(override val fontName: String, override val type: ImGuiFon

init {
val fontAtlas = getIO().fonts
val `is` =
ClassLoader.getSystemResourceAsStream("assets/${Schizoid.MOD_ID}/fonts/$fontName.${type.name.lowercase()}")
val `is` = javaClass.getResourceAsStream("/assets/${Schizoid.MOD_ID}/fonts/$fontName.${type.name.lowercase()}")
requireNotNull(`is`) { "Font file not found: $fontName.${type.name.lowercase()}" }
font = fontAtlas.addFontFromMemoryTTF(`is`.readAllBytes(), size, glyphRanges)
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/kotlin/dev/lyzev/api/opengl/shader/Shader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ abstract class Shader(val shader: String) : EventListener {
var matchResult = includeRegex.find(modifiedSource)
while (matchResult != null) {
val includePath = matchResult.groupValues[1]
val includeFile = javaClass.classLoader.getResource("$PATH/include/$includePath")
val includeFile = javaClass.getResource("$PATH/include/$includePath")
if (includeFile == null) {
Schizoid.logger.error(FileNotFoundException("Could not find include file: $includePath"))
return modifiedSource
Expand Down Expand Up @@ -221,7 +221,7 @@ abstract class Shader(val shader: String) : EventListener {
/**
* The path to the shaders.
*/
val PATH = "assets/${Schizoid.MOD_ID}/shaders"
val PATH = "/assets/${Schizoid.MOD_ID}/shaders"

/**
* Draws a full screen quad.
Expand All @@ -247,13 +247,13 @@ abstract class ShaderVertexFragment(
super.init()
if (tmp == program)
return
val vSource = ClassLoader.getSystemResourceAsStream("$PATH/core/$shader/${shader}_VP.glsl")?.use {
val vSource = javaClass.getResourceAsStream("$PATH/core/$shader/${shader}_VP.glsl")?.use {
it.readAllBytes().decodeToString()
} ?: "null"
val vShader = compile(GL_VERTEX_SHADER, vSource)
glAttachShader(program, vShader)

val fSource = ClassLoader.getSystemResourceAsStream("$PATH/core/$shader/${shader}_FP.glsl")?.use {
val fSource = javaClass.getResourceAsStream("$PATH/core/$shader/${shader}_FP.glsl")?.use {
it.readAllBytes().decodeToString()
} ?: "null"
val fShader = compile(GL_FRAGMENT_SHADER, fSource)
Expand Down Expand Up @@ -326,7 +326,7 @@ abstract class ShaderCompute(
super.init()
if (tmp == program)
return
ClassLoader.getSystemResourceAsStream("$PATH/core/$shader/${shader}_CP.glsl")
javaClass.getResourceAsStream("$PATH/core/$shader/${shader}_CP.glsl")
?.use {
val computeShader = compile(
GL_COMPUTE_SHADER,
Expand Down
6 changes: 1 addition & 5 deletions src/main/kotlin/dev/lyzev/schizoid/Schizoid.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ import kotlin.concurrent.thread
*/
object Schizoid : EventListener {

private val properties = Properties().apply {
ClassLoader.getSystemResourceAsStream("app.properties").use {
load(it)
}
}
private val properties = Properties().apply { load(Schizoid::class.java.getResourceAsStream("/app.properties")) }

/**
* The unique identifier of the mod.
Expand Down

0 comments on commit 2bc1ee7

Please sign in to comment.