aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md16
-rw-r--r--build.gradle55
-rw-r--r--src/main/kotlin/thedarkcolour/kotlinforforge/KotlinForForge.kt2
-rw-r--r--src/main/kotlin/thedarkcolour/kotlinforforge/KotlinLanguageProvider.kt2
-rw-r--r--src/main/kotlin/thedarkcolour/kotlinforforge/forge/Forge.kt43
-rw-r--r--src/main/kotlin/thedarkcolour/kotlinforforge/webgenerator/WebGenerator.kt (renamed from webgenerator/WebGenerator.kt)8
-rw-r--r--src/main/resources/META-INF/mods.toml2
-rw-r--r--thedarkcolour/kotlinforforge/1.0.0/kotlinforforge-1.0.0-sources.jarbin6807 -> 8142 bytes
-rw-r--r--thedarkcolour/kotlinforforge/1.0.0/kotlinforforge-1.0.0-sources.jar.md52
-rw-r--r--thedarkcolour/kotlinforforge/1.0.0/kotlinforforge-1.0.0-sources.jar.sha12
-rw-r--r--thedarkcolour/kotlinforforge/1.0.0/kotlinforforge-1.0.0.jarbin78066 -> 81103 bytes
-rw-r--r--thedarkcolour/kotlinforforge/1.0.0/kotlinforforge-1.0.0.jar.md51
-rw-r--r--thedarkcolour/kotlinforforge/1.0.0/kotlinforforge-1.0.0.jar.sha12
13 files changed, 53 insertions, 82 deletions
diff --git a/README.md b/README.md
index cec9159..4d47218 100644
--- a/README.md
+++ b/README.md
@@ -7,6 +7,16 @@ Makes Kotlin forge-friendly by doing the following:
To implement in your project, add the following to your build.gradle:
```groovy
+buildscript {
+ // ...
+ dependencies {
+ // Check the mod file for the Kotlin version
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.61"
+ }
+}
+
+apply plugin: 'kotlin'
+
repositories {
maven {
name = 'kotlinforforge'
@@ -18,6 +28,12 @@ dependencies {
// Uses the latest version of KotlinForForge
implementation 'thedarkcolour:kotlinforforge:1+'
}
+
+compileKotlin {
+ kotlinOptions {
+ jvmTarget = '1.8'
+ }
+}
```
Then, add the following to your mods.toml file:
```toml
diff --git a/build.gradle b/build.gradle
index 26760ab..363c8c3 100644
--- a/build.gradle
+++ b/build.gradle
@@ -15,14 +15,10 @@ plugins {
}
apply plugin: 'net.minecraftforge.gradle'
-// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
-apply plugin: 'maven-publish'
-apply plugin: 'eclipse'
-apply plugin: 'idea'
apply plugin: 'kotlin'
version = '1.0.0'
-group = 'thedarkcolour.kotlinforforge' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
+group = 'thedarkcolour.kotlinforforge'
archivesBaseName = 'kotlinforforge'
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
@@ -37,51 +33,27 @@ minecraft {
client {
workingDirectory project.file('run')
- // Recommended logging data for a userdev environment
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
- // Recommended logging level for the console
property 'forge.logging.console.level', 'debug'
-
- mods {
- examplemod {
- source sourceSets.main
- }
- }
}
server {
workingDirectory project.file('run')
- // Recommended logging data for a userdev environment
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
- // Recommended logging level for the console
property 'forge.logging.console.level', 'debug'
-
- mods {
- examplemod {
- source sourceSets.main
- }
- }
}
data {
workingDirectory project.file('run')
- // Recommended logging data for a userdev environment
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
- // Recommended logging level for the console
property 'forge.logging.console.level', 'debug'
args '--mod', 'examplemod', '--all', '--output', file('src/generated/resources/')
-
- mods {
- examplemod {
- source sourceSets.main
- }
- }
}
}
}
@@ -127,7 +99,7 @@ jar {
attributes([
"Specification-Title": "Mod Language Provider",
"Specification-Vendor": "Forge",
- "Specification-Version": "1", // We are version 1 of ourselves
+ "Specification-Version": "1",
"Implementation-Title": project.name,
"Implementation-Version": "${version}",
"Implementation-Vendor" :"thedarkcolour",
@@ -136,29 +108,6 @@ jar {
}
}
-// Example configuration to allow publishing using the maven-publish task
-// we define a custom artifact that is sourced from the reobfJar output task
-// and then declare that to be published
-// Note you'll need to add a repository hereI
-def reobfFile = file("$buildDir/reobfJar/output.jar")
-def reobfArtifact = artifacts.add('default', reobfFile) {
- type 'jar'
- builtBy 'reobfJar'
-}
-
-publishing {
- publications {
- mavenJava(MavenPublication) {
- artifact reobfArtifact
- }
- }
- repositories {
- maven {
- url "file:///${project.projectDir}/mcmodsrepo"
- }
- }
-}
-
compileKotlin {
kotlinOptions {
freeCompilerArgs = ["-Xinline-classes"]
diff --git a/src/main/kotlin/thedarkcolour/kotlinforforge/KotlinForForge.kt b/src/main/kotlin/thedarkcolour/kotlinforforge/KotlinForForge.kt
index 4b07205..f6139bc 100644
--- a/src/main/kotlin/thedarkcolour/kotlinforforge/KotlinForForge.kt
+++ b/src/main/kotlin/thedarkcolour/kotlinforforge/KotlinForForge.kt
@@ -1,10 +1,8 @@
package thedarkcolour.kotlinforforge
import net.minecraftforge.fml.common.Mod
-import net.minecraftforge.registries.DeferredRegister
import org.apache.logging.log4j.LogManager
import org.apache.logging.log4j.Logger
-import thedarkcolour.kotlinforforge.forge.MOD_BUS
/**
* Set 'modLoader' in mods.toml to "kotlinforforge" and loaderVersion to "[1,)".
diff --git a/src/main/kotlin/thedarkcolour/kotlinforforge/KotlinLanguageProvider.kt b/src/main/kotlin/thedarkcolour/kotlinforforge/KotlinLanguageProvider.kt
index 378b999..7d68f7e 100644
--- a/src/main/kotlin/thedarkcolour/kotlinforforge/KotlinLanguageProvider.kt
+++ b/src/main/kotlin/thedarkcolour/kotlinforforge/KotlinLanguageProvider.kt
@@ -6,9 +6,7 @@ import net.minecraftforge.forgespi.language.ILifecycleEvent
import net.minecraftforge.forgespi.language.IModInfo
import net.minecraftforge.forgespi.language.IModLanguageProvider
import net.minecraftforge.forgespi.language.ModFileScanData
-import java.util.function.BinaryOperator
import java.util.function.Consumer
-import java.util.function.Function
import java.util.function.Supplier
import java.util.stream.Collectors
diff --git a/src/main/kotlin/thedarkcolour/kotlinforforge/forge/Forge.kt b/src/main/kotlin/thedarkcolour/kotlinforforge/forge/Forge.kt
index 297afe4..73cab7e 100644
--- a/src/main/kotlin/thedarkcolour/kotlinforforge/forge/Forge.kt
+++ b/src/main/kotlin/thedarkcolour/kotlinforforge/forge/Forge.kt
@@ -1,8 +1,11 @@
package thedarkcolour.kotlinforforge.forge
import net.minecraftforge.api.distmarker.Dist
+import net.minecraftforge.common.ForgeConfigSpec
import net.minecraftforge.common.MinecraftForge
import net.minecraftforge.eventbus.api.IEventBus
+import net.minecraftforge.fml.ModLoadingContext
+import net.minecraftforge.fml.config.ModConfig
import net.minecraftforge.fml.loading.FMLEnvironment
import thedarkcolour.kotlinforforge.KotlinModLoadingContext
@@ -38,6 +41,9 @@ val MOD_BUS: IEventBus
val MOD_CONTEXT: KotlinModLoadingContext
inline get() = KotlinModLoadingContext.get()
+val LOADING_CONTEXT: ModLoadingContext
+ inline get() = ModLoadingContext.get()
+
/** @since 1.0.0
* The current [Dist] of this environment.
*/
@@ -45,37 +51,48 @@ val DIST: Dist = FMLEnvironment.dist
/** @since 1.0.0
* An alternative to [net.minecraftforge.fml.DistExecutor.callWhenOn]
- * that uses Kotlin functions instead of Java functional interfaces.
+ * that inlines the callable.
*/
-fun <T> callWhenOn(dist: Dist, toRun: () -> () -> T): T? {
- if (DIST == dist) {
+inline fun <T> callWhenOn(dist: Dist, toRun: () -> T): T? {
+ return if (DIST == dist) {
try {
- return toRun()()
+ toRun()
} catch (e: Exception) {
throw RuntimeException(e)
}
+ } else {
+ null
}
-
- return null
}
/** @since 1.0.0
- * An alternative to [net.minecraftforge.fml.DistExecutor.callWhenOn]
+ * An alternative to [net.minecraftforge.fml.DistExecutor.runWhenOn]
* that uses Kotlin functions instead of Java functional interfaces.
*/
-fun runWhenOn(dist: Dist, toRun: () -> () -> Unit) {
+inline fun runWhenOn(dist: Dist, toRun: () -> Unit) {
if (DIST == dist) {
- toRun()()
+ toRun()
}
}
/** @since 1.0.0
* An alternative to [net.minecraftforge.fml.DistExecutor.runForDist]
- * that uses Kotlin functions instead of Java functional interfaces.
+ * that inlines the method call.
*/
-fun <T> runForDist(clientTarget: () -> () -> T, serverTarget: () -> () -> T): T {
+inline fun <T> runForDist(clientTarget: () -> T, serverTarget: () -> T): T {
return when (DIST) {
- Dist.CLIENT -> clientTarget()()
- Dist.DEDICATED_SERVER -> serverTarget()()
+ Dist.CLIENT -> clientTarget()
+ Dist.DEDICATED_SERVER -> serverTarget()
+ }
+}
+
+/** @since 1.0.0
+ * Registers a config.
+ */
+fun registerConfig(type: ModConfig.Type, spec: ForgeConfigSpec, fileName: String? = null) {
+ if (fileName == null) {
+ LOADING_CONTEXT.registerConfig(type, spec)
+ } else {
+ LOADING_CONTEXT.registerConfig(type, spec, fileName)
}
} \ No newline at end of file
diff --git a/webgenerator/WebGenerator.kt b/src/main/kotlin/thedarkcolour/kotlinforforge/webgenerator/WebGenerator.kt
index 29150f0..fb0dc56 100644
--- a/webgenerator/WebGenerator.kt
+++ b/src/main/kotlin/thedarkcolour/kotlinforforge/webgenerator/WebGenerator.kt
@@ -39,14 +39,6 @@ fun run() {
val innerWeb = File("${file.absolutePath}\\web.html")
innerWeb.createNewFile()
}
- //webHtml.allElements.find {
- // it.tagName() == "body"
- //}!!.allElements.find {
- // it.tagName() == "pre"
- //}!!.allElements.find {
- // print(it.attr("href"))
- // it.className() == ""
- //}//.appendChild((Element(Tag.valueOf("a"), "hi")))
}
}
diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml
index e79af5b..0aa5be1 100644
--- a/src/main/resources/META-INF/mods.toml
+++ b/src/main/resources/META-INF/mods.toml
@@ -22,7 +22,7 @@ Kotlin for Forge. Allows mods to use the Kotlin programming language.
[[dependencies.kotlinforforge]]
modId="minecraft"
mandatory=true
- versionRange="[1.14.4]"
+ versionRange="[1.14,1.16)"
ordering="NONE"
side="BOTH"
diff --git a/thedarkcolour/kotlinforforge/1.0.0/kotlinforforge-1.0.0-sources.jar b/thedarkcolour/kotlinforforge/1.0.0/kotlinforforge-1.0.0-sources.jar
index 8c61a66..eb5e82e 100644
--- a/thedarkcolour/kotlinforforge/1.0.0/kotlinforforge-1.0.0-sources.jar
+++ b/thedarkcolour/kotlinforforge/1.0.0/kotlinforforge-1.0.0-sources.jar
Binary files differ
diff --git a/thedarkcolour/kotlinforforge/1.0.0/kotlinforforge-1.0.0-sources.jar.md5 b/thedarkcolour/kotlinforforge/1.0.0/kotlinforforge-1.0.0-sources.jar.md5
index b440f7b..70de8fc 100644
--- a/thedarkcolour/kotlinforforge/1.0.0/kotlinforforge-1.0.0-sources.jar.md5
+++ b/thedarkcolour/kotlinforforge/1.0.0/kotlinforforge-1.0.0-sources.jar.md5
@@ -1 +1 @@
-cda2255791958f5288c24161b2826b1d \ No newline at end of file
+896142079761595540d2f1fa85073333 \ No newline at end of file
diff --git a/thedarkcolour/kotlinforforge/1.0.0/kotlinforforge-1.0.0-sources.jar.sha1 b/thedarkcolour/kotlinforforge/1.0.0/kotlinforforge-1.0.0-sources.jar.sha1
index 01e1999..2b4a8ba 100644
--- a/thedarkcolour/kotlinforforge/1.0.0/kotlinforforge-1.0.0-sources.jar.sha1
+++ b/thedarkcolour/kotlinforforge/1.0.0/kotlinforforge-1.0.0-sources.jar.sha1
@@ -1 +1 @@
-2207a49e93eb065bc7f0442fdf6160d9f4e94c4d \ No newline at end of file
+54f989a11ca7c4deb65b220df847cfa609409ae8 \ No newline at end of file
diff --git a/thedarkcolour/kotlinforforge/1.0.0/kotlinforforge-1.0.0.jar b/thedarkcolour/kotlinforforge/1.0.0/kotlinforforge-1.0.0.jar
index 331ba80..9ccf5d2 100644
--- a/thedarkcolour/kotlinforforge/1.0.0/kotlinforforge-1.0.0.jar
+++ b/thedarkcolour/kotlinforforge/1.0.0/kotlinforforge-1.0.0.jar
Binary files differ
diff --git a/thedarkcolour/kotlinforforge/1.0.0/kotlinforforge-1.0.0.jar.md5 b/thedarkcolour/kotlinforforge/1.0.0/kotlinforforge-1.0.0.jar.md5
index e69de29..8f70740 100644
--- a/thedarkcolour/kotlinforforge/1.0.0/kotlinforforge-1.0.0.jar.md5
+++ b/thedarkcolour/kotlinforforge/1.0.0/kotlinforforge-1.0.0.jar.md5
@@ -0,0 +1 @@
+58d767d557b954d4385c9f67415aba8d \ No newline at end of file
diff --git a/thedarkcolour/kotlinforforge/1.0.0/kotlinforforge-1.0.0.jar.sha1 b/thedarkcolour/kotlinforforge/1.0.0/kotlinforforge-1.0.0.jar.sha1
index b6ea805..690420a 100644
--- a/thedarkcolour/kotlinforforge/1.0.0/kotlinforforge-1.0.0.jar.sha1
+++ b/thedarkcolour/kotlinforforge/1.0.0/kotlinforforge-1.0.0.jar.sha1
@@ -1 +1 @@
-F91033F841208DBDCFF5EB46C8A4B1CCDFC49E66 \ No newline at end of file
+51f2fd0551bf0aadd9052af5537073c3cd94f10c \ No newline at end of file