From 044dde34514cce7bb4032f763332e25060cc1a68 Mon Sep 17 00:00:00 2001 From: Timo Ley Date: Sun, 23 Oct 2022 21:28:14 +0200 Subject: [PATCH] fix: mixin issues --- build.gradle | 5 ++ gradle/scripts/mixins.gradle | 78 +++++++++++++++++++ .../cwg/genlayer/GenLayerBiomeClassic.java | 2 + .../tilera/cwg/mixins/MixinBiomeGenBase.java | 2 +- 4 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 gradle/scripts/mixins.gradle diff --git a/build.gradle b/build.gradle index 8d1ecb4..d6ce0f7 100644 --- a/build.gradle +++ b/build.gradle @@ -18,6 +18,7 @@ buildscript { apply plugin: 'forge' apply plugin: 'maven-publish' +apply from: './gradle/scripts/mixins.gradle' sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 @@ -121,4 +122,8 @@ publishing { mavenLocal() } } +} + +mixin { + mixinRefMapName = 'cwg.refmap.json' } \ No newline at end of file diff --git a/gradle/scripts/mixins.gradle b/gradle/scripts/mixins.gradle new file mode 100644 index 0000000..91ba32d --- /dev/null +++ b/gradle/scripts/mixins.gradle @@ -0,0 +1,78 @@ +abstract class MixinTask extends DefaultTask { + + @Input + abstract Property getMixinRefMapName() + + private File mixinSrg + private File mixinRefMap + + MixinTask() { + mixinRefMapName.convention("mixin.${project.name.replaceAll('[_\\-.]', '').toLowerCase()}.refmap.json") + } + + @TaskAction + void action() { + def mixinDir = new File(project.buildDir, 'mixins') + if (!mixinDir.exists()) { + mixinDir.mkdirs() + } + def srgFile = new File(project.buildDir, 'srgs/mcp-srg.srg') + mixinSrg = new File(mixinDir, "${mixinRefMapName.get()}.srg") + mixinRefMap = new File(mixinDir, mixinRefMapName.get()) + + if (!mixinSrg.exists()) { + mixinSrg.createNewFile() + } + + project.tasks.reobf.configure { + addExtraSrgFile mixinSrg + } + + def compileJava = project.tasks.compileJava + compileJava.configure { + options.compilerArgs += [ + '-Xlint:-processing', + "-AoutSrgFile=${mixinSrg.canonicalPath}", + "-AoutRefMapFile=${mixinRefMap.canonicalPath}", + "-AreobfSrgFile=${srgFile.canonicalPath}" + ] + } + + project.tasks.jar.configure { + from mixinRefMap + } + } + + @Internal + File getMixinSrg() { + return mixinSrg + } + + @Internal + File getMixinRefMap() { + return mixinRefMap + } +} + +tasks.register('mixin', MixinTask) + +task copySrgs(type: Copy, dependsOn: 'genSrgs') { + from plugins.getPlugin('forge').delayedFile('{SRG_DIR}') + include '**/*.srg' + into layout.buildDirectory.file('srgs') +} + +compileJava.dependsOn(copySrgs, mixin) +tasks.findByPath(":prepareKotlinBuildScriptModel")?.dependsOn(copySrgs, mixin) + +processResources { + afterEvaluate { + def refmap = tasks.mixin.mixinRefMapName.get() + inputs.property 'mixin_refmap', refmap + from(sourceSets.main.resources.srcDirs) { + include '*.json' + expand 'mixin_refmap': refmap + duplicatesStrategy = DuplicatesStrategy.INCLUDE + } + } +} \ No newline at end of file diff --git a/src/main/java/dev/tilera/cwg/genlayer/GenLayerBiomeClassic.java b/src/main/java/dev/tilera/cwg/genlayer/GenLayerBiomeClassic.java index 48ebe45..c62312f 100644 --- a/src/main/java/dev/tilera/cwg/genlayer/GenLayerBiomeClassic.java +++ b/src/main/java/dev/tilera/cwg/genlayer/GenLayerBiomeClassic.java @@ -47,6 +47,8 @@ public class GenLayerBiomeClassic extends GenLayer { addedBiomes.add(BiomeGenBase.savanna); biomeEntries.add(new BiomeEntry(BiomeGenBase.savannaPlateau, 10)); addedBiomes.add(BiomeGenBase.savannaPlateau); + biomeEntries.add(new BiomeEntry(BiomeGenBase.megaTaiga, 10)); + addedBiomes.add(BiomeGenBase.megaTaiga); } for (BiomeType t : BiomeType.values()) { diff --git a/src/main/java/dev/tilera/cwg/mixins/MixinBiomeGenBase.java b/src/main/java/dev/tilera/cwg/mixins/MixinBiomeGenBase.java index 35403b0..bc2126d 100644 --- a/src/main/java/dev/tilera/cwg/mixins/MixinBiomeGenBase.java +++ b/src/main/java/dev/tilera/cwg/mixins/MixinBiomeGenBase.java @@ -22,7 +22,7 @@ public abstract class MixinBiomeGenBase { * @author tilera * @reason No snow on hills */ - @Overwrite(remap = false) + @Overwrite public final float getFloatTemperature(int p_150564_1_, int p_150564_2_, int p_150564_3_) { if (p_150564_2_ > 64 && Config.enableHeightSnow) { float f = (float)temperatureNoise.func_151601_a((double)p_150564_1_ * 1.0D / 8.0D, (double)p_150564_3_ * 1.0D / 8.0D) * 4.0F;