diff --git a/build.gradle.kts b/build.gradle.kts index 158d4cf..72e2f45 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -42,9 +42,14 @@ loom { } } +tasks.compileJava { + dependsOn(tasks.processResources) +} + sourceSets.main { + kotlin.destinationDirectory.set(java.destinationDirectory) java.srcDir(file("$projectDir/src/main/kotlin")) - output.setResourcesDir(file("$buildDir/classes/java/main")) + output.setResourcesDir(java.destinationDirectory) } // Dependencies: diff --git a/src/main/kotlin/com/example/ExampleMod.kt b/src/main/kotlin/com/example/ExampleMod.kt index 4e5ebda..bf32496 100644 --- a/src/main/kotlin/com/example/ExampleMod.kt +++ b/src/main/kotlin/com/example/ExampleMod.kt @@ -1,5 +1,6 @@ package com.example +import net.minecraft.client.Minecraft import net.minecraft.init.Blocks import net.minecraftforge.fml.common.Mod import net.minecraftforge.fml.common.event.FMLInitializationEvent @@ -8,6 +9,14 @@ import net.minecraftforge.fml.common.event.FMLInitializationEvent class ExampleMod { @Mod.EventHandler fun init(event: FMLInitializationEvent) { + try { + val resource: net.minecraft.client.resources.IResource = Minecraft.getMinecraft().getResourceManager() + .getResource(net.minecraft.util.ResourceLocation("test:test.txt")) + org.apache.commons.io.IOUtils.copy(resource.getInputStream(), java.lang.System.out) + } catch (e: java.io.IOException) { + throw java.lang.RuntimeException(e) + } + println("Dirt: ${Blocks.dirt.unlocalizedName}") } } diff --git a/src/main/resources/assets/test/test.txt b/src/main/resources/assets/test/test.txt new file mode 100644 index 0000000..ea839e2 --- /dev/null +++ b/src/main/resources/assets/test/test.txt @@ -0,0 +1,3 @@ +test +from resource pack +