Add mixin to all projects
This commit is contained in:
parent
45030884b0
commit
fc6f452e8c
|
|
@ -2,6 +2,7 @@ plugins {
|
||||||
id 'fabric-loom' version '1.2-SNAPSHOT' apply(false)
|
id 'fabric-loom' version '1.2-SNAPSHOT' apply(false)
|
||||||
id 'net.minecraftforge.gradle' version '[6.0,6.2)' apply(false)
|
id 'net.minecraftforge.gradle' version '[6.0,6.2)' apply(false)
|
||||||
id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT' apply(false)
|
id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT' apply(false)
|
||||||
|
id("org.spongepowered.mixin") version "0.7-SNAPSHOT" apply(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
|
|
@ -59,7 +60,7 @@ subprojects {
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
filesMatching(['pack.mcmeta', 'fabric.mod.json', 'mods.toml']) {
|
filesMatching(['pack.mcmeta', 'fabric.mod.json', 'mods.toml', '*.mixins.json']) {
|
||||||
expand project.properties
|
expand project.properties
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.example.examplemod.mixin;
|
||||||
|
|
||||||
|
import com.example.examplemod.Constants;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.screens.TitleScreen;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
@Mixin(Minecraft.class)
|
||||||
|
public class MixinMinecraft {
|
||||||
|
|
||||||
|
@Inject(at = @At("TAIL"), method = "<init>")
|
||||||
|
private void init(CallbackInfo info) {
|
||||||
|
|
||||||
|
Constants.LOG.info("This line is printed by an example mod common mixin!");
|
||||||
|
Constants.LOG.info("MC Version: {}", Minecraft.getInstance().getVersionType());
|
||||||
|
}
|
||||||
|
}
|
||||||
18
common/src/main/resources/examplemod.mixins.json
Normal file
18
common/src/main/resources/examplemod.mixins.json
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"required": true,
|
||||||
|
"minVersion": "0.8",
|
||||||
|
"package": "com.example.examplemod.mixin",
|
||||||
|
"refmap": "${mod_id}.refmap.json",
|
||||||
|
"compatibilityLevel": "JAVA_17",
|
||||||
|
"mixins": [
|
||||||
|
],
|
||||||
|
"client": [
|
||||||
|
"MixinMinecraft"
|
||||||
|
],
|
||||||
|
"server": [
|
||||||
|
],
|
||||||
|
"injectors": {
|
||||||
|
"defaultRequire": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -17,6 +17,9 @@ dependencies {
|
||||||
}
|
}
|
||||||
|
|
||||||
loom {
|
loom {
|
||||||
|
mixin {
|
||||||
|
defaultRefmapName.set("${mod_id}.refmap.json")
|
||||||
|
}
|
||||||
runs {
|
runs {
|
||||||
client {
|
client {
|
||||||
client()
|
client()
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,12 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
@Mixin(TitleScreen.class)
|
@Mixin(TitleScreen.class)
|
||||||
public class ExampleMixin {
|
public class MixinTitleScreen {
|
||||||
|
|
||||||
@Inject(at = @At("HEAD"), method = "init()V")
|
@Inject(at = @At("HEAD"), method = "init()V")
|
||||||
private void init(CallbackInfo info) {
|
private void init(CallbackInfo info) {
|
||||||
|
|
||||||
Constants.LOG.info("This line is printed by an example mod mixin from Fabric!");
|
Constants.LOG.info("This line is printed by an example mod mixin from Fabric!");
|
||||||
Constants.LOG.info("MC Version: {}", Minecraft.getInstance().getVersionType());
|
Constants.LOG.info("MC Version: {}", Minecraft.getInstance().getVersionType());
|
||||||
Constants.LOG.info("Classloader: {}", this.getClass().getClassLoader());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2,11 +2,14 @@
|
||||||
"required": true,
|
"required": true,
|
||||||
"minVersion": "0.8",
|
"minVersion": "0.8",
|
||||||
"package": "com.example.examplemod.mixin",
|
"package": "com.example.examplemod.mixin",
|
||||||
|
"refmap": "${mod_id}.refmap.json",
|
||||||
"compatibilityLevel": "JAVA_17",
|
"compatibilityLevel": "JAVA_17",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
],
|
],
|
||||||
"client": [
|
"client": [
|
||||||
"ExampleMixin"
|
"MixinTitleScreen"
|
||||||
|
],
|
||||||
|
"server": [
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
|
|
@ -20,7 +20,8 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"modid.mixins.json"
|
"examplemod.mixins.json",
|
||||||
|
"examplemod.fabric.mixins.json"
|
||||||
],
|
],
|
||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.14",
|
"fabricloader": ">=0.14",
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,18 @@ plugins {
|
||||||
id 'idea'
|
id 'idea'
|
||||||
id 'maven-publish'
|
id 'maven-publish'
|
||||||
id 'net.minecraftforge.gradle'
|
id 'net.minecraftforge.gradle'
|
||||||
|
id 'org.spongepowered.mixin'
|
||||||
}
|
}
|
||||||
|
|
||||||
archivesBaseName = "${mod_name}-forge-${minecraft_version}"
|
archivesBaseName = "${mod_name}-forge-${minecraft_version}"
|
||||||
|
|
||||||
|
mixin {
|
||||||
|
add(sourceSets.main, "${mod_id}.refmap.json")
|
||||||
|
|
||||||
|
config("${mod_id}.mixins.json")
|
||||||
|
config("${mod_id}.forge.mixins.json")
|
||||||
|
}
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
mappings channel: 'official', version: minecraft_version
|
mappings channel: 'official', version: minecraft_version
|
||||||
|
|
||||||
|
|
@ -67,6 +75,7 @@ sourceSets.main.resources.srcDir 'src/generated/resources'
|
||||||
dependencies {
|
dependencies {
|
||||||
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
|
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
|
||||||
compileOnly project(":common")
|
compileOnly project(":common")
|
||||||
|
annotationProcessor("org.spongepowered:mixin:0.8.5-SNAPSHOT:processor")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType(JavaCompile) {
|
tasks.withType(JavaCompile) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.example.examplemod.mixin;
|
||||||
|
|
||||||
|
import com.example.examplemod.Constants;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.screens.TitleScreen;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
@Mixin(TitleScreen.class)
|
||||||
|
public class MixinTitleScreen {
|
||||||
|
|
||||||
|
@Inject(at = @At("HEAD"), method = "init()V")
|
||||||
|
private void init(CallbackInfo info) {
|
||||||
|
|
||||||
|
Constants.LOG.info("This line is printed by an example mod mixin from Forge!");
|
||||||
|
Constants.LOG.info("MC Version: {}", Minecraft.getInstance().getVersionType());
|
||||||
|
}
|
||||||
|
}
|
||||||
17
forge/src/main/resources/examplemod.forge.mixins.json
Normal file
17
forge/src/main/resources/examplemod.forge.mixins.json
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"required": true,
|
||||||
|
"minVersion": "0.8",
|
||||||
|
"package": "com.example.examplemod.mixin",
|
||||||
|
"refmap": "${mod_id}.refmap.json",
|
||||||
|
"compatibilityLevel": "JAVA_17",
|
||||||
|
"mixins": [
|
||||||
|
],
|
||||||
|
"client": [
|
||||||
|
"MixinTitleScreen"
|
||||||
|
],
|
||||||
|
"server": [
|
||||||
|
],
|
||||||
|
"injectors": {
|
||||||
|
"defaultRequire": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -16,7 +16,7 @@ fabric_loader_version=0.14.11
|
||||||
# Mod options
|
# Mod options
|
||||||
mod_name=MultiLoader
|
mod_name=MultiLoader
|
||||||
mod_author=Jared
|
mod_author=Jared
|
||||||
mod_id=multiloader
|
mod_id=examplemod
|
||||||
|
|
||||||
# Gradle
|
# Gradle
|
||||||
org.gradle.jvmargs=-Xmx3G
|
org.gradle.jvmargs=-Xmx3G
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user