Skip to content

Commit 48edc09

Browse files
committed
Add kotlin to template
1 parent 08479b3 commit 48edc09

File tree

6 files changed

+41
-17
lines changed

6 files changed

+41
-17
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Architectury Loom based template for 1.8.9 forge mods
1+
Architectury Loom based template for 1.8.9 kotlin forge mods
22

33
**For other templates, do check out the [other branches of this repository](https://github.com/romangraef/Forge1.8.9Template/branches/all)**
44

@@ -13,6 +13,9 @@ To get started, [Use this template](https://github.com/new?template_name=Forge1.
1313
> [!WARNING]
1414
> Do not Fork or Clone or Download ZIP this template. If you "use" this template a custom mod id will be generated. You can do that manually using the `make-my-own` script, if you are on linux. If not, just click the use this template button. If you want to use kotlin or make a 1.12 mod check the "Include all branches" and change the default branch in https://github.com/yourname/yourreponame/branches
1515
16+
Please note that Mixins should be kept in their own package, and should exclusively be written in Java, since older versions
17+
of Mixin don't play well with Kotlin.
18+
1619
This project uses [DevAuth](https://github.com/DJtheRedstoner/DevAuth) per default, so you can log in using your real
1720
minecraft account. If you don't need that, you can remove it from the buildscript.
1821

build.gradle.kts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ plugins {
66
id("gg.essential.loom") version "0.10.0.+"
77
id("dev.architectury.architectury-pack200") version "0.1.3"
88
id("com.github.johnrengelman.shadow") version "8.1.1"
9+
kotlin("jvm") version "2.0.0"
910
}
1011

1112
//Constants:
@@ -56,8 +57,14 @@ loom {
5657
}
5758
}
5859

60+
tasks.compileJava {
61+
dependsOn(tasks.processResources)
62+
}
63+
5964
sourceSets.main {
6065
output.setResourcesDir(sourceSets.main.flatMap { it.java.classesDirectory })
66+
java.srcDir(layout.projectDirectory.dir("src/main/kotlin"))
67+
kotlin.destinationDirectory.set(java.destinationDirectory)
6168
}
6269

6370
// Dependencies:
@@ -78,6 +85,8 @@ dependencies {
7885
mappings("de.oceanlabs.mcp:mcp_stable:22-1.8.9")
7986
forge("net.minecraftforge:forge:1.8.9-11.15.1.2318-1.8.9")
8087

88+
shadowImpl(kotlin("stdlib-jdk8"))
89+
8190
// If you don't want mixins, remove these lines
8291
shadowImpl("org.spongepowered:mixin:0.7.11-SNAPSHOT") {
8392
isTransitive = false

src/main/java/com/example/ExampleMod.java

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.example
2+
3+
import net.minecraft.client.Minecraft
4+
import net.minecraft.init.Blocks
5+
import net.minecraftforge.fml.common.Mod
6+
import net.minecraftforge.fml.common.event.FMLInitializationEvent
7+
import net.minecraft.client.renderer.GlStateManager
8+
9+
@Mod(modid = "examplemod", useMetadata = true)
10+
class ExampleMod {
11+
@Mod.EventHandler
12+
fun init(event: FMLInitializationEvent) {
13+
try {
14+
val resource: net.minecraft.client.resources.IResource = Minecraft.getMinecraft().getResourceManager()
15+
.getResource(net.minecraft.util.ResourceLocation("test:test.txt"))
16+
org.apache.commons.io.IOUtils.copy(resource.getInputStream(), java.lang.System.out)
17+
} catch (e: java.io.IOException) {
18+
throw java.lang.RuntimeException(e)
19+
}
20+
21+
println("Dirt: ${Blocks.dirt.unlocalizedName}")
22+
// Below is a demonstration of an access-transformed class access.
23+
println("Color State: " + GlStateManager.Color());
24+
}
25+
}

src/main/java/com/example/mixin/MixinGuiMainMenu.java renamed to src/main/kotlin/com/example/mixin/MixinGuiMainMenu.java

File renamed without changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
test
2+
from resource pack
3+

0 commit comments

Comments
 (0)