Git Product home page Git Product logo

spongemixins's Introduction

SpongeMixins Library Mod

Mod that allows you to use mixins in 1.7.10

How to setup library in dev workspace:

  1. Put SpongeMixins-dev.jar in the %project%/libs folder and refresh gradle.

    1.1. Add this string to the dependencies in your main class of mod: required-after:spongemixins@[1.1.0,);

  2. Add this stuff to your build.gradle:

โ€ƒโ€ƒ2.1 Setup your workspace by including this script at the end of your build.gradle and replace strings yourMixinConfig, refMapForYourConfig and relativePathToMixinAP as represented in the comments near them:

//##########################################################################################################
//########################################    Mixin  Part   ################################################
//##########################################################################################################
/**
* The name of your mixin config. Should match the name of mixin config file, which you placed in src/main/resources/
*/
def yourMixinConfig = 'mixins.yourmodid.json'
/**
* The file with this name will be generated during build. Should math the remap value inside your src/main/resources/*yourMixinConfig*
*/
def refMapForYourConfig = 'mixins.yourmodid.refmap.json'
/**
* Relative path to the new annotation processor. 
* You should download it (https://github.com/TimeConqueror/SpongeMixins/raw/master/mixin-0.8-SNAPSHOT.jar) and then place to the project folder. 
* You may also place it in the inner folders, only thing you should to do is to provide right RELATIVE path.
*/
def relativePathToMixinAP = 'mixin-0.8-SNAPSHOT.jar'

repositories {
    maven {
        name = 'sponge'
        url = 'https://repo.spongepowered.org/repository/maven-public'
    }
}

dependencies {
    compile('org.spongepowered:mixin:0.7.11-SNAPSHOT') {
        // Mixin includes a lot of dependencies that are too up-to-date
        exclude module: 'launchwrapper'
        exclude module: 'guava'
        exclude module: 'gson'
        exclude module: 'commons-io'
        exclude module: 'log4j-core'
    }
}

def refMap = "${tasks.compileJava.temporaryDir}" + File.separator + refMapForYourConfig

def mixinSrg = "${tasks.reobf.temporaryDir}" + File.separator + "mixins.srg"

jar {
    from refMap
    manifest {
        attributes([
                "TweakClass": "org.spongepowered.asm.launch.MixinTweaker",
                'MixinConfigs': yourMixinConfig,
                'FMLCorePluginContainsFMLMod': 'true',
                "ForceLoadAsMod": true
        ])
    }
}

reobf {
    addExtraSrgFile mixinSrg
}

afterEvaluate {
    def fixedRelPathToAP = relativePathToMixinAP
    if(fixedRelPathToAP.startsWith('./') || fixedRelPathToAP.startsWith('.\\')){
        fixedRelPathToAP = fixedRelPathToAP.substring(2)
    } else if(fixedRelPathToAP.startsWith('/') || fixedRelPathToAP.startsWith('\\')){
        fixedRelPathToAP = fixedRelPathToAP.substring(1)
    }

    tasks.compileJava {
        println "Path: " + projectDir.absolutePath
        options.compilerArgs += [
                // There's a bug in the AnnotationProcessor for 0.7.11 that will generate the annotations pointing to the parent class instead of subclass
                // resulting in the mixin not being applied.  This is fixed in 0.8, however 0.8 needs guava > 21.0, and minecraft ships with 17.0.
                // So as a hacky workaround... ship with 0.7.11, but use the AP from 0.8 for compiling
                "-processorpath", projectDir.absolutePath + '/' + fixedRelPathToAP,
                "-processor", "org.spongepowered.tools.obfuscation.MixinObfuscationProcessorInjection,org.spongepowered.tools.obfuscation.MixinObfuscationProcessorTargets",
                "-Xlint:-sunapi", "-XDenableSunApiLintControl", "-XDignore.symbol.file",
                "-AreobfSrgFile=${tasks.reobf.srg}", "-AoutSrgFile=${mixinSrg}", "-AoutRefMapFile=${refMap}"
        ]
    }
}

sourceSets {
    main {
        output.resourcesDir = output.classesDir
        ext.refMap = refMapForYourConfig
    }
}

Starting magic with mixins or how to add its config

Create mixins.yourmodid.json file directly in resources folder (replace yourmodid with your modid). Here is an example of how to fill it (remember about changing yourmodid):

{
  "required": true,
  "minVersion": "0.7.11",
  "package": "com.company.mypackage.mixins",
  "refmap": "mixins.yourmodid.refmap.json",
  "target": "@env(DEFAULT)",
  "compatibilityLevel": "JAVA_8",
  "mixins": [
    "MixinTest1",
    "MixinTest2"
  ],
  "client": [
    "MixinMinecraft"
  ]
}

More info here: https://github.com/SpongePowered/Mixin

How to launch in dev-workspace

Add following Program Agruments:
--tweakClass org.spongepowered.asm.launch.MixinTweaker --mixin mixins.yourmodid.json
and replace yourmodid as mentioned above.

FAQ

  1. Q: project\build\tmp\reobf\mixins.srg (Can't find given file) while build
    A: You should run minecraft after you created or added new mixins to generate this file

spongemixins's People

Contributors

dream-master avatar mitchej123 avatar qeolvdxu avatar timeconqueror avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

spongemixins's Issues

Log4J causes crashes in some alternative launchers

In some alternative MC launchers l4j calls causes crashes. Maybe use just System.out.print instead? There is only one string.

[22:08:19] [main/INFO]: Initializing SpongeMixinsCore
[22:08:19] [main/INFO]: [java.lang.Throwable$WrappedPrintStream:println:749]: java.lang.NoClassDefFoundError: org/apache/logging/log4j/LogManager
[22:08:19] [main/INFO]: [java.lang.Throwable$WrappedPrintStream:println:749]: 	at org.spongepowered.asm.launch.MixinBootstrap.<clinit>(MixinBootstrap.java:68)
[22:08:19] [main/INFO]: [java.lang.Throwable$WrappedPrintStream:println:749]: 	at ru.timeconqueror.spongemixins.core.SpongeMixinsCore.<clinit>(SpongeMixinsCore.java:28)
[22:08:19] [main/INFO]: [java.lang.Throwable$WrappedPrintStream:println:749]: 	at java.lang.Class.forName0(Native Method)
[22:08:19] [main/INFO]: [java.lang.Throwable$WrappedPrintStream:println:749]: 	at java.lang.Class.forName(Class.java:348)
[22:08:19] [main/INFO]: [java.lang.Throwable$WrappedPrintStream:println:749]: 	at cpw.mods.fml.relauncher.CoreModManager.loadCoreMod(CoreModManager.java:460)
[22:08:19] [main/INFO]: [java.lang.Throwable$WrappedPrintStream:println:749]: 	at cpw.mods.fml.relauncher.CoreModManager.discoverCoreMods(CoreModManager.java:389)
[22:08:19] [main/INFO]: [java.lang.Throwable$WrappedPrintStream:println:749]: 	at cpw.mods.fml.relauncher.CoreModManager.handleLaunch(CoreModManager.java:221)
[22:08:19] [main/INFO]: [java.lang.Throwable$WrappedPrintStream:println:749]: 	at cpw.mods.fml.relauncher.FMLLaunchHandler.setupHome(FMLLaunchHandler.java:90)
[22:08:19] [main/INFO]: [java.lang.Throwable$WrappedPrintStream:println:749]: 	at cpw.mods.fml.relauncher.FMLLaunchHandler.setupClient(FMLLaunchHandler.java:67)
[22:08:19] [main/INFO]: [java.lang.Throwable$WrappedPrintStream:println:749]: 	at cpw.mods.fml.relauncher.FMLLaunchHandler.configureForClientLaunch(FMLLaunchHandler.java:34)
[22:08:19] [main/INFO]: [java.lang.Throwable$WrappedPrintStream:println:749]: 	at cpw.mods.fml.common.launcher.FMLTweaker.injectIntoClassLoader(FMLTweaker.java:126)
[22:08:19] [main/INFO]: [java.lang.Throwable$WrappedPrintStream:println:749]: 	at net.minecraft.launchwrapper.Launch.launch(Launch.java:116)
[22:08:19] [main/INFO]: [java.lang.Throwable$WrappedPrintStream:println:749]: 	at net.minecraft.launchwrapper.Launch.main(Launch.java:29)
[22:08:19] [main/INFO]: [java.lang.Throwable$WrappedPrintStream:println:749]: 	at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627)
[22:08:19] [main/INFO]: [java.lang.Throwable$WrappedPrintStream:println:749]: 	at pro.gravit.launcher.zonAsUMRaKamMt.zoNAsUMraKANTZ(Unknown Source)
[22:08:19] [main/INFO]: [java.lang.Throwable$WrappedPrintStream:println:749]: 	at pro.gravit.launcher.zonAsUMRaKamMt.main(Unknown Source)
[22:08:19] [main/INFO]: [java.lang.Throwable$WrappedPrintStream:println:749]: Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.LogManager
[22:08:19] [main/INFO]: [java.lang.Throwable$WrappedPrintStream:println:749]: 	at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
[22:08:19] [main/INFO]: [java.lang.Throwable$WrappedPrintStream:println:749]: 	at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
[22:08:19] [main/INFO]: [java.lang.Throwable$WrappedPrintStream:println:749]: 	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
[22:08:19] [main/INFO]: [java.lang.Throwable$WrappedPrintStream:println:749]: 	at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
[22:08:19] [main/INFO]: [java.lang.Throwable$WrappedPrintStream:println:749]: 	... 16 more

getJarInModPath doesn't work with dev deps

getJarInModPath only considers mods in /mods, not mods that have been loaded from dev dependencies (such as HungerOverhaul.jar in hodgepodge).

Adjust the function to look at the MC classpath, or at least expand it to include the dev dep path.

[Approval request] Modrinth reupload

Hello,

I have some 1.7.10 mods uploaded to Modrinth (a better alternative to curseforge) that require SpongeMixins to work, and to make sure that launchers can properly pull in the dependencies, i've went ahead and created a modrinth mirror of SpongeMixins 1.2.0 in good faith, which also directly links back to this repo in the description: https://modrinth.com/mod/spongemixin1710/

i just want to make sure that you don't have any objections to this, and if you don't want SpongeMixins on modrinth, i will remove the reupload from modrinth and link people to this repo instead in each mod.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.