From dc702b2445ac1009f2288166944187b5e1ba0328 Mon Sep 17 00:00:00 2001 From: NikkyAI Date: Thu, 15 Feb 2018 22:10:38 +0100 Subject: [PATCH] because ForgeGradle sucks.. at least before 2.3-SNAPSHOT --- .gitignore | 1 + 1.10.2/build.gradle | 24 ++++++++++++++----- .../src/main/kotlin/matterlink/MatterLink.kt | 11 +-------- .../command/MatterlinkCommandSender.kt | 2 +- .../templates/kotlin/matterlink/Constants.kt | 7 ++++++ 1.11.2/build.gradle | 24 ++++++++++++++----- .../src/main/kotlin/matterlink/MatterLink.kt | 11 +-------- .../templates/kotlin/matterlink/Constants.kt | 7 ++++++ 1.12.2/build.gradle | 6 ++--- .../src/main/kotlin/matterlink/Constants.kt | 7 ++++++ .../src/main/kotlin/matterlink/MatterLink.kt | 9 +------ 11 files changed, 65 insertions(+), 44 deletions(-) create mode 100644 1.10.2/src/templates/kotlin/matterlink/Constants.kt create mode 100644 1.11.2/src/templates/kotlin/matterlink/Constants.kt create mode 100644 1.12.2/src/main/kotlin/matterlink/Constants.kt diff --git a/.gitignore b/.gitignore index d935fbf..d231071 100644 --- a/.gitignore +++ b/.gitignore @@ -98,3 +98,4 @@ gradle-app.setting run/ *.tmp +**/gen/ diff --git a/1.10.2/build.gradle b/1.10.2/build.gradle index 8704693..210708e 100644 --- a/1.10.2/build.gradle +++ b/1.10.2/build.gradle @@ -48,16 +48,28 @@ minecraft { runDir = "run" mappings = project.mcp_mappings +} - replaceIn 'MatterLink.kt' - replace '@VERSION@', project.mod_version - replace '@FORGELIN-VERSION@', project.forgelin_version - replace '@FORGE-VERSION@', project.forge_version +compileKotlin.doFirst { + def target = "src/main/kotlin/matterlink/gen" + copy { + from("../src/templates/kotlin/matterlink/Constants.kt") + into(target) + } + ant.replaceregexp(match:'@VERSION@', replace: project.mod_version, flags:'g', byline:true) { + fileset(dir: target, includes: 'Constants.kt') + } + ant.replaceregexp(match:'@FORGELIN-VERSION@', replace: project.forgelin_version, flags:'g', byline:true) { + fileset(dir: target, includes: 'Constants.kt') + } + ant.replaceregexp(match:'@FORGE-VERSION@', replace: project.forge_version, flags:'g', byline:true) { + fileset(dir: target, includes: 'Constants.kt') + } } processResources { // this will ensure that this task is redone when the versions change. - inputs.property "version", project.version + inputs.property "version", project.mod_version inputs.property "mcversion", project.minecraft.version // replace stuff in mcmod.info, nothing else @@ -65,7 +77,7 @@ processResources { include 'mcmod.info' // replace version and mcversion - expand 'version': project.version, 'mcversion': project.minecraft.version + expand 'version': project.mod_version, 'mcversion': project.minecraft.version } // copy everything else except the mcmod.info diff --git a/1.10.2/src/main/kotlin/matterlink/MatterLink.kt b/1.10.2/src/main/kotlin/matterlink/MatterLink.kt index 9977701..bd0300a 100644 --- a/1.10.2/src/main/kotlin/matterlink/MatterLink.kt +++ b/1.10.2/src/main/kotlin/matterlink/MatterLink.kt @@ -1,10 +1,5 @@ package matterlink -import jline.internal.Log -import matterlink.bridge.MessageHandler -import matterlink.bridge.command.BridgeCommandRegistry -import matterlink.bridge.command.HelpCommand -import matterlink.bridge.command.PlayerListCommand import matterlink.command.CommandMatterlink import matterlink.command.IMinecraftCommandSender import matterlink.command.MatterlinkCommandSender @@ -16,10 +11,6 @@ import net.minecraftforge.fml.common.event.* import org.apache.logging.log4j.Level import org.apache.logging.log4j.Logger -const val MODID = "matterlink" -const val NAME = "MatterLink" -const val VERSION = "@VERSION@" - lateinit var logger: Logger @Mod( @@ -29,7 +20,7 @@ lateinit var logger: Logger useMetadata = true, acceptableRemoteVersions = "*", modLanguageAdapter = "net.shadowfacts.forgelin.KotlinAdapter", - dependencies = "required-after:forgelin@[@FORGELIN-VERSION@,);required-after:forge@[@FORGE-VERSION@,);" + dependencies = DEPENDENCIES ) object MatterLink : IMatterLink() { init { diff --git a/1.10.2/src/main/kotlin/matterlink/command/MatterlinkCommandSender.kt b/1.10.2/src/main/kotlin/matterlink/command/MatterlinkCommandSender.kt index 525f29b..9385da2 100644 --- a/1.10.2/src/main/kotlin/matterlink/command/MatterlinkCommandSender.kt +++ b/1.10.2/src/main/kotlin/matterlink/command/MatterlinkCommandSender.kt @@ -34,7 +34,7 @@ object MatterlinkCommandSender : IMinecraftCommandSender, ICommandSender { } override fun getEntityWorld(): World { - return FMLCommonHandler.instance().minecraftServerInstance.getWorld(0) + return FMLCommonHandler.instance().minecraftServerInstance.worldServerForDimension(0) } override fun canUseCommand(permLevel: Int, commandName: String?): Boolean { diff --git a/1.10.2/src/templates/kotlin/matterlink/Constants.kt b/1.10.2/src/templates/kotlin/matterlink/Constants.kt new file mode 100644 index 0000000..d828e92 --- /dev/null +++ b/1.10.2/src/templates/kotlin/matterlink/Constants.kt @@ -0,0 +1,7 @@ +package matterlink + +const val MODID = "matterlink" +const val NAME = "MatterLink" +const val VERSION = "@VERSION@" +//const val DEPENDENCIES = "required-after:forgelin@[@FORGELIN-VERSION@,);required-after:forge@[@FORGE-VERSION@,);" +const val DEPENDENCIES = "required-after:forgelin@[@FORGELIN-VERSION@,);" diff --git a/1.11.2/build.gradle b/1.11.2/build.gradle index 15dabbd..ab58ce8 100644 --- a/1.11.2/build.gradle +++ b/1.11.2/build.gradle @@ -47,16 +47,28 @@ minecraft { runDir = "run" mappings = project.mcp_mappings +} - replaceIn 'MatterLink.kt' - replace '@VERSION@', project.mod_version - replace '@FORGELIN-VERSION@', project.forgelin_version - replace '@FORGE-VERSION@', project.forge_version +compileKotlin.doFirst { + def target = "src/main/kotlin/matterlink/gen" + copy { + from("../src/templates/kotlin/matterlink/Constants.kt") + into(target) + } + ant.replaceregexp(match:'@VERSION@', replace: project.mod_version, flags:'g', byline:true) { + fileset(dir: target, includes: 'Constants.kt') + } + ant.replaceregexp(match:'@FORGELIN-VERSION@', replace: project.forgelin_version, flags:'g', byline:true) { + fileset(dir: target, includes: 'Constants.kt') + } + ant.replaceregexp(match:'@FORGE-VERSION@', replace: project.forge_version, flags:'g', byline:true) { + fileset(dir: target, includes: 'Constants.kt') + } } processResources { // this will ensure that this task is redone when the versions change. - inputs.property "version", project.version + inputs.property "version", project.mod_version inputs.property "mcversion", project.minecraft.version // replace stuff in mcmod.info, nothing else @@ -64,7 +76,7 @@ processResources { include 'mcmod.info' // replace version and mcversion - expand 'version': project.version, 'mcversion': project.minecraft.version + expand 'version': project.mod_version, 'mcversion': project.minecraft.version } // copy everything else except the mcmod.info diff --git a/1.11.2/src/main/kotlin/matterlink/MatterLink.kt b/1.11.2/src/main/kotlin/matterlink/MatterLink.kt index 68d336a..f5af485 100644 --- a/1.11.2/src/main/kotlin/matterlink/MatterLink.kt +++ b/1.11.2/src/main/kotlin/matterlink/MatterLink.kt @@ -1,10 +1,5 @@ package matterlink -import jline.internal.Log -import matterlink.bridge.MessageHandler -import matterlink.bridge.command.BridgeCommandRegistry -import matterlink.bridge.command.HelpCommand -import matterlink.bridge.command.PlayerListCommand import matterlink.command.CommandMatterlink import matterlink.command.IMinecraftCommandSender import matterlink.command.MatterlinkCommandSender @@ -16,10 +11,6 @@ import net.minecraftforge.fml.common.event.* import org.apache.logging.log4j.Level import org.apache.logging.log4j.Logger -const val MODID = "matterlink" -const val NAME = "MatterLink" -const val VERSION = "@VERSION@" - lateinit var logger: Logger @Mod( @@ -29,7 +20,7 @@ lateinit var logger: Logger useMetadata = true, acceptableRemoteVersions = "*", modLanguageAdapter = "net.shadowfacts.forgelin.KotlinAdapter", - dependencies = "required-after:forgelin@[@FORGELIN-VERSION@,);required-after:forge@[@FORGE-VERSION@,);" + dependencies = DEPENDENCIES ) object MatterLink : IMatterLink() { init { diff --git a/1.11.2/src/templates/kotlin/matterlink/Constants.kt b/1.11.2/src/templates/kotlin/matterlink/Constants.kt new file mode 100644 index 0000000..d6e4a04 --- /dev/null +++ b/1.11.2/src/templates/kotlin/matterlink/Constants.kt @@ -0,0 +1,7 @@ +package matterlink + +const val MODID = "matterlink" +const val NAME = "MatterLink" +const val VERSION = "@VERSION@" +const val DEPENDENCIES = "required-after:forgelin@[@FORGELIN-VERSION@,);required-after:forge@[@FORGE-VERSION@,);" + diff --git a/1.12.2/build.gradle b/1.12.2/build.gradle index a53bba4..c139940 100644 --- a/1.12.2/build.gradle +++ b/1.12.2/build.gradle @@ -48,7 +48,7 @@ minecraft { mappings = project.mcp_mappings - replaceIn 'MatterLink.kt' + replaceIn 'Constants.kt' replace '@VERSION@', project.mod_version replace '@FORGELIN-VERSION@', project.forgelin_version replace '@FORGE-VERSION@', project.forge_version @@ -56,7 +56,7 @@ minecraft { processResources { // this will ensure that this task is redone when the versions change. - inputs.property "version", project.version + inputs.property "version", project.mod_version inputs.property "mcversion", project.minecraft.version // replace stuff in mcmod.info, nothing else @@ -64,7 +64,7 @@ processResources { include 'mcmod.info' // replace version and mcversion - expand 'version': project.version, 'mcversion': project.minecraft.version + expand 'version': project.mod_version, 'mcversion': project.minecraft.version } // copy everything else except the mcmod.info diff --git a/1.12.2/src/main/kotlin/matterlink/Constants.kt b/1.12.2/src/main/kotlin/matterlink/Constants.kt new file mode 100644 index 0000000..d6e4a04 --- /dev/null +++ b/1.12.2/src/main/kotlin/matterlink/Constants.kt @@ -0,0 +1,7 @@ +package matterlink + +const val MODID = "matterlink" +const val NAME = "MatterLink" +const val VERSION = "@VERSION@" +const val DEPENDENCIES = "required-after:forgelin@[@FORGELIN-VERSION@,);required-after:forge@[@FORGE-VERSION@,);" + diff --git a/1.12.2/src/main/kotlin/matterlink/MatterLink.kt b/1.12.2/src/main/kotlin/matterlink/MatterLink.kt index 352ecbc..bdbe720 100644 --- a/1.12.2/src/main/kotlin/matterlink/MatterLink.kt +++ b/1.12.2/src/main/kotlin/matterlink/MatterLink.kt @@ -1,8 +1,5 @@ package matterlink -import matterlink.bridge.command.BridgeCommandRegistry -import matterlink.bridge.command.HelpCommand -import matterlink.bridge.command.PlayerListCommand import matterlink.command.CommandMatterlink import matterlink.command.IMinecraftCommandSender import matterlink.command.MatterlinkCommandSender @@ -14,10 +11,6 @@ import net.minecraftforge.fml.common.event.* import org.apache.logging.log4j.Level import org.apache.logging.log4j.Logger -const val MODID = "matterlink" -const val NAME = "MatterLink" -const val VERSION = "@VERSION@" - lateinit var logger: Logger @Mod( @@ -27,7 +20,7 @@ lateinit var logger: Logger useMetadata = true, acceptableRemoteVersions = "*", modLanguageAdapter = "net.shadowfacts.forgelin.KotlinAdapter", - dependencies = "required-after:forgelin@[@FORGELIN-VERSION@,);required-after:forge@[@FORGE-VERSION@,);" + dependencies = DEPENDENCIES ) object MatterLink : IMatterLink() { init {