Skip to content

Commit fe3e48e

Browse files
Switch resource replacing to blossom, update readme
1 parent 76255dd commit fe3e48e

9 files changed

Lines changed: 65 additions & 94 deletions

File tree

README.md

Lines changed: 26 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# CleanroomModTemplate
22
Mod development template for Cleanroom, uses Unimined
33

4-
## Usage
4+
## DOs and DON'Ts
55
### Choose Branch
66
Choose mixin branch if you want to use Mixin.
77

8-
Use scala and kotlin branch if you want to write in non-Java language.
8+
Use scala and kotlin branch if you want to use those languages.
99

1010
There are 4 branches available:
1111
- main
@@ -15,61 +15,47 @@ There are 4 branches available:
1515

1616
If you want to use non-main branches, after clicked *Create a new repository* under *Use this template*, check the *Include all branches* checkbox.
1717

18-
### gradle.properties
19-
Edit gradle.properties and set your modid, mod version, mod name, package, etc.
20-
21-
If you are writing a coremod, remember to set related settings to true.
22-
23-
### Reference Class
24-
Mostly used to store mod version so you can fill it to `@Mod`.
2518

26-
You should change its location to fit your new package name.
27-
28-
You can find it under `src/main/java-templates`.
29-
30-
### Dependencies
31-
You can find dependency script in `gradle/scripts/dependencies.gradle`.
19+
### Running Client or Server
20+
If you are using IntelliJ, **DO NOT** use the `Minecraft Client` configure with a blue icon. Just use the `2. Run Client` Gradle task.
3221

33-
No more `rfg.deobf()` or `fg.deobf` for mods, you should use `modImplementation`, `modCompileOnly` and `modRuntimeOnly`.
22+
### Adding Mod Dependencies
23+
You can find dependencies block in `gradle/scripts/dependencies.gradle`.
3424

35-
### Shadow
36-
You can use `shadow` in dependency declaration to shadow libraries.
25+
No more `rfg.deobf()` or `fg.deobf`. You **MUST** add mods by using `modImplementation` or `modRuntimeOnly`, or the game will crash when running.
3726

38-
### Contain
39-
You can use `contain` in dependency declaration to add non-mod libraries to artifact jar.
27+
### Non-Mod Dependencies
28+
Two new configuration types `contain` and `shadow` are available, check more details in `dependencies.gradle`.
4029

41-
They will be extracted and loaded automatically in production.
30+
### gradle.properties
31+
Edit gradle.properties and set your modid, mod version, mod name, package, etc.
4232

43-
### Mixin
44-
MixinBooter API is deprecated in Cleanroom.
33+
If you are writing a coremod, remember to set related settings to true.
4534

46-
Current approach is to set json configs in `MixinConfigs` manifest key, which will be read by Cleanroom.
35+
### Reference Class
36+
There will be a `Reference` class under your top package.
4737

48-
You don't need to set tons of json too. If you aren't mixining into Forge, all you need is two jsons for `DEFAULT` hase and `MOD` Phase.
38+
This is used to store mod version so you can fill it to `@Mod` annotation.
4939

50-
All you need is to put `IEarlyMixinLoader` mixin to `DEFAULT` json, and, mixins from `ILateMixinLoader` to `MOD` json.
40+
You should change its location to fit your new package name.
5141

52-
As for calling `Loader.isModLoaded()`, just fit an `IMixinConfigPlugin` to your json and call in `shouldApply()`
42+
You can find its template under `src/main/java-templates`.
5343

54-
There are some example mixins and a HEI dependency in mixin fork, remove them before writing yours.
44+
### Mixin
45+
1. Rename json config file to include your modid. You will need one json per phase (`PRE_INIT`, `DEFAULT`, `MOD`)
46+
2. Add your mixin classes there.
47+
3. Use `IMixinConfigPlugin` to control if certain mixin should be enabled. You can call `Loader.isModLoaded()` for `MOD` phase mixins.
5548

5649
### Access Transformer
57-
You MUST write AT file in MCP name. It will be remapped back to SRG name in artifact jar.
58-
59-
Rename AT file name to your modid before using it. There's an example entry in AT file, remove it if you want to use AT.
50+
You **MUST** write AT file in MCP name. It will be remapped back to SRG name in artifact jar.
6051

61-
**WARNING**: ATs from dependency won't be applied to vanilla source.
52+
Rename AT file name to your modid before using it. There's an example entry in AT file, remove it if you want to use AT.
6253

63-
### Source Code with Comments
64-
Run `genSources` task in gradle.
54+
### Vanilla Source Code with Comments
55+
Run `genSources` task in gradle. If it didn't work, run again until a file with `-sources.jar` suffix appeared.
6556

6657
If you want to `find usage` from vanilla like RFG, just change the scope in IntelliJ settings.
6758

68-
### Running Client or Server
69-
You **MUST** add mods by using `modImplementation` or `modRuntimeOnly`, or mapping and ATs will break.
70-
71-
If you are using IntelliJ, **DO NOT** use the `Minecraft Client` configure with a blue icon. Just use the `runClient` Gradle task.
72-
7359
### GitHub Action
7460
This template comes with three workflows.
7561

@@ -81,7 +67,7 @@ This template comes with three workflows.
8167

8268
You need to fill in your project IDs and configure your tokens in GitHub repository first.
8369

84-
By default, you will need to manually trigger the workflow in web page, but you can also enable tag triggering by merging it into `release.yml`.
70+
By default, you will need to manually trigger the workflow in web page, but you can also enable tag triggering by merging the third yml into `release.yml`.
8571

8672
### Credit
8773
Thanks @Karnatour for fixing shadow plugin

build.gradle

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
id 'com.gradleup.shadow' version '9.3.2'
66
id 'org.jetbrains.gradle.plugin.idea-ext' version '1.4.1'
77
id 'xyz.wagyourtail.unimined' version '1.4.10-kappa'
8-
id 'net.kyori.blossom' version '2.1.0'
8+
id 'net.kyori.blossom' version '2.2.0'
99
}
1010

1111
import org.jetbrains.gradle.ext.Gradle
@@ -48,9 +48,7 @@ java {
4848
}
4949

5050
configurations {
51-
embed
5251
contain
53-
implementation.extendsFrom(embed)
5452
implementation.extendsFrom(contain)
5553
modCompileOnly
5654
compileOnly.extendsFrom(modCompileOnly)
@@ -120,33 +118,6 @@ dependencies {
120118
apply from: 'gradle/scripts/dependencies.gradle'
121119

122120
processResources {
123-
124-
inputs.property 'mod_id', propertyString('mod_id')
125-
inputs.property 'mod_name', propertyString('mod_name')
126-
inputs.property 'mod_version', propertyString('mod_version')
127-
inputs.property 'mod_description', propertyString('mod_description')
128-
inputs.property 'mod_authors', "${propertyStringList('mod_authors', ',').join(', ')}"
129-
inputs.property 'mod_credits', propertyString('mod_credits')
130-
inputs.property 'mod_url', propertyString('mod_url')
131-
inputs.property 'mod_update_json', propertyString('mod_update_json')
132-
inputs.property 'mod_logo_path', propertyString('mod_logo_path')
133-
134-
def filterList = ['mcmod.info', 'pack.mcmeta']
135-
136-
filesMatching(filterList) { fcd ->
137-
fcd.expand(
138-
'mod_id': propertyString('mod_id'),
139-
'mod_name': propertyString('mod_name'),
140-
'mod_version': propertyString('mod_version'),
141-
'mod_description': propertyString('mod_description'),
142-
'mod_authors': "${propertyStringList('mod_authors', ',').join(', ')}",
143-
'mod_credits': propertyString('mod_credits'),
144-
'mod_url': propertyString('mod_url'),
145-
'mod_update_json': propertyString('mod_update_json'),
146-
'mod_logo_path': propertyString('mod_logo_path'),
147-
)
148-
}
149-
150121
rename '(.+_at.cfg)', 'META-INF/$1'
151122
}
152123

@@ -159,6 +130,17 @@ sourceSets {
159130
property('mod_version', propertyString('mod_version'))
160131
property('package', "${root_package}.${mod_id}")
161132
}
133+
resources {
134+
property('mod_id', propertyString('mod_id'))
135+
property('mod_name', propertyString('mod_name'))
136+
property('mod_version', propertyString('mod_version'))
137+
property('mod_description', propertyString('mod_description'))
138+
property('mod_authors', "${propertyStringList('mod_authors', ',').join(', ')}")
139+
property('mod_credits', propertyString('mod_credits'))
140+
property('mod_url', propertyString('mod_url'))
141+
property('mod_update_json', propertyString('mod_update_json'))
142+
property('mod_logo_path', propertyString('mod_logo_path'))
143+
}
162144
}
163145
}
164146
}
@@ -201,6 +183,7 @@ compileJava {
201183
}
202184

203185
jar {
186+
archiveClassifier = 'dev'
204187
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
205188
if (configurations.contain.size() > 0) {
206189
into('/') {

gradle/scripts/dependencies.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ dependencies {
3737
// runtimeOnly = runtime dependency
3838
// compileOnly = compile time dependency
3939
// annotationProcessor = annotation processing dependencies
40-
// contain = bundle dependency jars into final artifact, will extract them in mod loading. Please only do this to non-mod dependencies.
40+
// contain = bundle dependency jars into final artifact, will extract them in mod loading. Can be used it as jar-in-jar
4141
// shadow = bundle dependencies into shadow output artifact (relocation configurable in shadowJar task)
4242
// modImplementation = mod dependency available at both compile time and runtime
4343
// modCompileOnly = mod dependency available only at compile time

settings.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
pluginManagement {
22
repositories {
3+
gradlePluginPortal() {
4+
content {
5+
excludeGroup("org.apache.logging.log4j")
6+
}
7+
}
38
mavenCentral()
49
maven {
510
url = "https://maven.minecraftforge.net/"
@@ -17,11 +22,6 @@ pluginManagement {
1722
maven {
1823
url = "https://maven.wagyourtail.xyz/snapshots"
1924
}
20-
gradlePluginPortal() {
21-
content {
22-
excludeGroup("org.apache.logging.log4j")
23-
}
24-
}
2525
}
2626
}
2727

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.example.modid;
22

33
import com.example.modid.proxy.IProxy;
4+
import net.minecraft.client.Minecraft;
45
import net.minecraftforge.fml.common.Mod;
56
import net.minecraftforge.fml.common.SidedProxy;
67
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
@@ -23,6 +24,7 @@ public class ExampleMod {
2324
public void preInit(FMLPreInitializationEvent event) {
2425
LOGGER.info("Hello From {}!", Reference.MOD_NAME);
2526
LOGGER.info("Proxy is {}", proxy);
27+
LOGGER.info("Language: {}", Minecraft.getMinecraft().getLanguageManager().getCurrentLanguage());
2628
}
2729

2830
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[{
2+
"modid": "{{ mod_id }}",
3+
"name": "{{ mod_name }}",
4+
"version": "{{ mod_version }}",
5+
"mcversion": "1.12.2",
6+
"description": "{{ mod_description }}",
7+
"authorList": ["{{ mod_authors }}"],
8+
"credits": "{{ mod_credits }}",
9+
"url": "{{ mod_url }}",
10+
"updateJSON": "{{ mod_update_json }}",
11+
"logoFile": "{{ mod_logo_path }}"
12+
}]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"pack": {
3+
"description": "{{ mod_name }} Resources",
4+
"pack_format": 3
5+
}
6+
}

src/main/resources/mcmod.info

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/main/resources/pack.mcmeta

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)