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 = "http://repo.spongepowered.org/maven/"
    }
}

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 timeconqueror avatar

Watchers

 avatar

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.