Skip to content

Commit 42352d1

Browse files
committed
Switch to RFG & Remove dependence to Fluidlogged API
1 parent c219f5f commit 42352d1

19 files changed

+798
-201
lines changed

build.gradle

Lines changed: 182 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,209 @@
1-
buildscript {
2-
repositories {
3-
mavenCentral()
4-
maven { url 'https://files.minecraftforge.net/maven' }
5-
}
6-
dependencies {
7-
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
1+
import org.jetbrains.gradle.ext.Gradle
2+
3+
plugins {
4+
id 'java'
5+
id 'java-library'
6+
id 'maven-publish'
7+
id 'org.jetbrains.gradle.plugin.idea-ext' version '1.1.7'
8+
id 'eclipse'
9+
id 'com.gtnewhorizons.retrofuturagradle' version '1.3.27'
10+
id 'com.matthewprenger.cursegradle' version '1.4.0'
11+
}
12+
13+
version = project.mod_version
14+
group = project.maven_group
15+
archivesBaseName = project.archives_base_name
16+
17+
// Set the toolchain version to decouple the Java we run Gradle with from the Java used to compile and run the mod
18+
java {
19+
toolchain {
20+
languageVersion.set(JavaLanguageVersion.of(8))
21+
// Azul covers the most platforms for Java 8 toolchains, crucially including MacOS arm64
22+
vendor.set(org.gradle.jvm.toolchain.JvmVendorSpec.AZUL)
823
}
24+
// Generate sources and javadocs jars when building and publishing
25+
withSourcesJar()
26+
// withJavadocJar()
927
}
1028

11-
apply plugin: 'net.minecraftforge.gradle.forge'
12-
apply plugin: 'maven-publish'
29+
tasks.withType(JavaCompile).configureEach {
30+
options.encoding = 'UTF-8'
31+
}
1332

14-
version = 'v1.0.2-mc1.12.2'
15-
group = 'git.jbredwards.friendly_chests'
16-
archivesBaseName = 'Friendly-Chests'
17-
sourceCompatibility = targetCompatibility = '1.8'
33+
configurations {
34+
embed
35+
implementation.extendsFrom(embed)
36+
}
1837

1938
minecraft {
20-
version = "1.12.2-14.23.5.2847"
21-
runDir = "run"
22-
mappings = "stable_39"
23-
makeObfSourceJar = false
39+
mcVersion = '1.12.2'
40+
41+
// MCP Mappings
42+
mcpMappingChannel = 'stable'
43+
mcpMappingVersion = '39'
44+
45+
// Set username here, the UUID will be looked up automatically
46+
username = 'Developer'
47+
48+
// Add any additional tweaker classes here
49+
// extraTweakClasses.add('org.spongepowered.asm.launch.MixinTweaker')
50+
51+
// Add various JVM arguments here for runtime
52+
def args = ["-ea:${project.group}"]
53+
if (project.use_coremod.toBoolean()) {
54+
args << '-Dfml.coreMods.load=' + coremod_plugin_class_name
55+
}
56+
if (project.use_mixins.toBoolean()) {
57+
args << '-Dmixin.hotSwap=true'
58+
args << '-Dmixin.checks.interfaces=true'
59+
args << '-Dmixin.debug.export=true'
60+
}
61+
extraRunJvmArguments.addAll(args)
62+
63+
// Include and use dependencies' Access Transformer files
64+
useDependencyAccessTransformers = true
65+
66+
// Add any properties you want to swap out for a dynamic value at build time here
67+
// Any properties here will be added to a class at build time, the name can be configured below
68+
// Example:
69+
// injectedTags.put('VERSION', project.version)
70+
// injectedTags.put('MOD_ID', project.archives_base_name)
2471
}
2572

26-
dependencies {
27-
deobfCompile "com.github.jbredwards:fluidlogged-api:${fluidlogged_api_version}"
28-
deobfProvided "mezz.jei:jei_1.12.2:${jei_version}"
29-
//quark
30-
deobfProvided 'com.github.VazkiiMods:Quark:1.12-SNAPSHOT'
31-
deobfProvided 'com.github.VazkiiMods:AutoRegLib:1.12-SNAPSHOT'
73+
// Generate a group.archives_base_name.Tags class
74+
tasks.injectTags.configure {
75+
// Change Tags class' name here:
76+
outputClassName.set("${project.group}.${project.archives_base_name}.Tags")
3277
}
3378

3479
repositories {
35-
maven { url 'https://jitpack.io' }
3680
maven {
37-
//location of the maven that hosts JEI files
38-
name = 'Progwml6 maven'
39-
url = 'http://dvs1.progwml6.com/files/maven'
81+
name 'CleanroomMC Maven'
82+
url 'https://maven.cleanroommc.com'
83+
}
84+
maven {
85+
name 'SpongePowered Maven'
86+
url 'https://repo.spongepowered.org/maven'
4087
}
4188
maven {
42-
//location of a maven mirror for JEI files, as a fallback
43-
name = 'ModMaven'
44-
url = 'modmaven.k-4u.nl'
89+
name 'CurseMaven'
90+
url 'https://cursemaven.com'
91+
content {
92+
includeGroup 'curse.maven'
93+
}
94+
}
95+
mavenLocal() // Must be last for caching to work
96+
}
97+
98+
dependencies {
99+
if (project.use_assetmover.toBoolean()) {
100+
implementation 'com.cleanroommc:assetmover:2.5'
101+
}
102+
if (project.use_mixins.toBoolean()) {
103+
implementation 'zone.rong:mixinbooter:7.1'
104+
}
105+
106+
// Example of deobfuscating a dependency
107+
implementation rfg.deobf('curse.maven:had-enough-items-557549:4543375')
108+
implementation rfg.deobf('curse.maven:quark-243121:2924091')
109+
implementation rfg.deobf('curse.maven:autoreglib-250363:2746011')
110+
111+
if (project.use_mixins.toBoolean()) {
112+
// Change your mixin refmap name here:
113+
String mixin = modUtils.enableMixins('org.spongepowered:mixin:0.8.3', "mixins.${project.archives_base_name}.refmap.json")
114+
api (mixin) {
115+
transitive = false
116+
}
117+
annotationProcessor 'org.ow2.asm:asm-debug-all:5.2'
118+
annotationProcessor 'com.google.guava:guava:24.1.1-jre'
119+
annotationProcessor 'com.google.code.gson:gson:2.8.6'
120+
annotationProcessor (mixin) {
121+
transitive = false
122+
}
123+
}
124+
125+
}
126+
127+
// Adds Access Transformer files to tasks
128+
if (project.use_access_transformer.toBoolean()) {
129+
for (File at : sourceSets.getByName("main").resources.files) {
130+
if (at.name.toLowerCase().endsWith("_at.cfg")) {
131+
tasks.deobfuscateMergedJarToSrg.accessTransformerFiles.from(at)
132+
tasks.srgifyBinpatchedJar.accessTransformerFiles.from(at)
133+
}
45134
}
46135
}
47136

48137
processResources {
49-
// this will ensure that this task is redone when the versions change.
50-
inputs.property "version", project.version
51-
inputs.property "mcversion", project.minecraft.version
52-
53-
// replace stuff in mcmod.info, nothing else
54-
from(sourceSets.main.resources.srcDirs) {
55-
include 'mcmod.info'
56-
57-
// replace version and mcversion
58-
expand 'version':project.version, 'mcversion':project.minecraft.version
138+
// This will ensure that this task is redone when the versions change
139+
inputs.property 'version', project.version
140+
inputs.property 'mcversion', project.minecraft.version
141+
142+
// Replace various properties in mcmod.info and pack.mcmeta if applicable
143+
filesMatching(['mcmod.info', 'pack.mcmeta']) { fcd ->
144+
// Replace version and mcversion
145+
fcd.expand (
146+
'version': project.version,
147+
'mcversion': project.minecraft.version
148+
)
59149
}
60-
61-
// copy everything else except the mcmod.info
62-
from(sourceSets.main.resources.srcDirs) {
63-
exclude 'mcmod.info'
150+
151+
if (project.use_access_transformer.toBoolean()) {
152+
rename '(.+_at.cfg)', 'META-INF/$1' // Make sure Access Transformer files are in META-INF folder
64153
}
65154
}
66155

67-
//for applying asm outside dev environment
68156
jar {
69157
manifest {
70-
attributes(
71-
'FMLCorePlugin': 'git.jbredwards.friendly_chests.mod.asm.ASMHandler',
72-
'FMLCorePluginContainsFMLMod': 'true',
73-
'FMLAT': 'friendly_chests_at.cfg'
74-
)
158+
def attribute_map = [:]
159+
if (project.use_coremod.toBoolean()) {
160+
attribute_map['FMLCorePlugin'] = project.coremod_plugin_class_name
161+
if (project.include_mod.toBoolean()) {
162+
attribute_map['FMLCorePluginContainsFMLMod'] = true
163+
attribute_map['ForceLoadAsMod'] = project.gradle.startParameter.taskNames[0] == "build"
164+
}
165+
}
166+
if (project.use_access_transformer.toBoolean()) {
167+
attribute_map['FMLAT'] = project.archives_base_name + '_at.cfg'
168+
}
169+
attributes(attribute_map)
170+
}
171+
// Add all embedded dependencies into the jar
172+
from(provider{ configurations.embed.collect {it.isDirectory() ? it : zipTree(it)} })
173+
}
174+
175+
idea {
176+
module {
177+
inheritOutputDirs = true
178+
}
179+
project {
180+
settings {
181+
runConfigurations {
182+
"1. Run Client"(Gradle) {
183+
taskNames = ["runClient"]
184+
}
185+
"2. Run Server"(Gradle) {
186+
taskNames = ["runServer"]
187+
}
188+
"3. Run Obfuscated Client"(Gradle) {
189+
taskNames = ["runObfClient"]
190+
}
191+
"4. Run Obfuscated Server"(Gradle) {
192+
taskNames = ["runObfServer"]
193+
}
194+
}
195+
compiler.javac {
196+
afterEvaluate {
197+
javacAdditionalOptions = "-encoding utf8"
198+
moduleJavacAdditionalOptions = [
199+
(project.name + ".main"): tasks.compileJava.options.compilerArgs.collect { '"' + it + '"' }.join(' ')
200+
]
201+
}
202+
}
203+
}
75204
}
76205
}
77206

78-
//for applying asm with intellij
79-
runClient { jvmArgs '-Dfml.coreMods.load=git.jbredwards.friendly_chests.mod.asm.ASMHandler' }
80-
runServer { jvmArgs '-Dfml.coreMods.load=git.jbredwards.friendly_chests.mod.asm.ASMHandler' }
207+
tasks.named("processIdeaSettings").configure {
208+
dependsOn("injectTags")
209+
}

gradle.properties

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
22
# This is required to provide enough memory for the Minecraft decompilation process.
3-
org.gradle.jvmargs=-Xmx3G
4-
fluidlogged_api_version=2660dde0cd
5-
jei_version=4.15.0.268
3+
org.gradle.jvmargs = -Xmx3G
4+
5+
# Mod Information
6+
mod_version = 1.0.2
7+
maven_group = git.jbredwards
8+
archives_base_name = friendly_chests
9+
mod_id = friendly_chests
10+
mod_name = Friendly Chests
11+
# If any properties changes below this line, run `gradlew setupDecompWorkspace` and refresh gradle again to ensure everything is working correctly.
12+
13+
# Boilerplate Options
14+
use_mixins = false
15+
use_coremod = true
16+
use_assetmover = false
17+
18+
# Access Transformer files should be in the root of `resources` folder and with the filename formatted as: `{archives_base_name}_at.cfg`
19+
use_access_transformer = true
20+
21+
# Coremod Arguments
22+
include_mod = true
23+
coremod_plugin_class_name =git.jbredwards.friendly_chests.mod.asm.ASMHandler

0 commit comments

Comments
 (0)