Created
December 11, 2018 11:00
-
-
Save happyzleaf/5629836dce2e3cf6dac293cc8234eadb to your computer and use it in GitHub Desktop.
Forge Mixins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildscript { | |
repositories { | |
jcenter() | |
maven { | |
name = 'forge' | |
url = 'https://files.minecraftforge.net/maven' | |
} | |
maven { | |
url = 'http://repo.spongepowered.org/maven' | |
} | |
} | |
dependencies { | |
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT' | |
classpath 'org.spongepowered:mixingradle:0.6-SNAPSHOT' | |
} | |
} | |
apply plugin: 'net.minecraftforge.gradle.forge' | |
apply plugin: 'org.spongepowered.mixin' | |
version = MODVERSION | |
group = com.MODID | |
archivesBaseName = MODID | |
sourceCompatibility = 1.8 | |
targetCompatibility = 1.8 | |
sourceSets { | |
main { | |
ext.refMap = 'mixins.MODID.refmap.json' | |
} | |
} | |
processResources { | |
// this will ensure that this task is redone when the versions change. | |
inputs.property 'version', 1.12.2-14.23.4.2705 | |
inputs.property 'mcversion', stable_39 | |
// replace stuff in mcmod.info, nothing else | |
from(sourceSets.main.resources.srcDirs) { | |
include 'mcmod.info' | |
// replace version and mcversion | |
expand 'version': project.version, 'mcversion': project.minecraft.version | |
} | |
// copy everything else, thats not the mcmod.info | |
from(sourceSets.main.resources.srcDirs) { | |
exclude 'mcmod.info' | |
} | |
rename '(.+_at.cfg)', 'META-INF/$1' | |
} | |
minecraft { | |
version = 1.12.2-14.23.4.2705 | |
runDir = 'run' | |
// the mappings can be changed at any time, and must be in the following format. | |
// snapshot_YYYYMMDD snapshot are built nightly. | |
// stable_# stables are built at the discretion of the MCP team. | |
// Use non-default mappings at your own risk. they may not always work. | |
// simply re-run your setup task after changing the mappings to update your workspace. | |
mappings = stable_39 | |
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. | |
def args = [ | |
'-Dfml.coreMods.load=com.MODID.asm.MODCoremod', | |
'-Dmixin.hotSwap=true', | |
'-Dmixin.checks.interfaces=true' | |
] | |
clientJvmArgs.addAll(args) | |
serverJvmArgs.addAll(args) | |
} | |
configurations { | |
embed | |
implementation.extendsFrom(embed) | |
} | |
repositories { | |
//mavenCentral() | |
maven { | |
url = 'http://repo.spongepowered.org/maven' | |
} | |
} | |
dependencies { | |
embed('org.spongepowered:mixin:0.7.11-SNAPSHOT') { | |
transitive = false | |
} | |
} | |
jar { | |
from(configurations.embed.collect { it.isDirectory() ? it : zipTree(it) }) { | |
exclude 'LICENSE.txt', 'META-INF/MANIFSET.MF', 'META-INF/maven/**', 'META-INF/*.RSA', 'META-INF/*.SF' | |
} | |
manifest.attributes( | |
'FMLCorePluginContainsFMLMod': true, | |
'ForceLoadAsMod': true, | |
'TweakClass': 'org.spongepowered.asm.launch.MixinTweaker', | |
'MixinConfigs': 'mixins.MODID.json', | |
'FMLCorePlugin': 'com.MODID.asm.MODCoremod' | |
) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.MODID.asm; | |
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin; | |
import org.spongepowered.asm.launch.MixinBootstrap; | |
import org.spongepowered.asm.mixin.Mixins; | |
import javax.annotation.Nullable; | |
import java.util.Map; | |
@IFMLLoadingPlugin.SortingIndex(CHOOSE_A_RANDOM_NUMBER) | |
public class MODCoremod implements IFMLLoadingPlugin { | |
public MODCoremod() { | |
MixinBootstrap.init(); | |
Mixins.addConfiguration("mixins.MODID.json"); | |
} | |
@Override | |
public String[] getASMTransformerClass() { | |
return new String[0]; | |
} | |
@Override | |
public String getModContainerClass() { | |
return null; | |
} | |
@Nullable | |
@Override | |
public String getSetupClass() { | |
return null; | |
} | |
@Override | |
public void injectData(Map<String, Object> data) {} | |
@Override | |
public String getAccessTransformerClass() { | |
return null; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"package": "com.MODID.asm.mixin", | |
"refmap": "mixins.MODID.refmap.json", | |
"target": "@env(DEFAULT)", | |
"minVersion": "0.6", | |
"compatibilityLevel": "JAVA_8", | |
"mixins": [ | |
"MixinEntityPlayer" | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment