Jump to content

denoflions

Members
  • Posts

    13
  • Joined

  • Last visited

Posts posted by denoflions

  1. When building a project written in Groovy ForgeGradle seems to have awareness of the fact that it is Groovy since it generates the appropriate tasks to compile it. However, the output doesn't seem to get reobf'd since I get an endless stream of 'No such property' errors any time I hit an obf'd field or method.

     

    So unless I've done something wrong configuring my project, I assume getting a mod written in Groovy to load in an obf'd environment is impossible without a go-between java class or metaClass shenanigans. Am I wrong here?

     

    edit: I've figured out the solution. You need to set every class that interacts with obf'd minecraft classes to CompileStatic. I wrote a hacky gradle task to accomplish this across the whole project automatically. Slap the following into your build.gradle and away you go.

     

    task staticGroovy{

        def base = new File("src/main/groovy")

        base.eachFileRecurse {

            if (!it.isDirectory()){

                if (it.getName().contains(".groovy")){

                    def bail = false

                    def import_added = false

                    def anno_added = false

                    def list = [] as List<String>

                    def marker = "//Preprocessed."

                    def file = it

                    list.add(marker)

                    it.eachLine {

                        if (it.contains(marker)){

                            bail = true

                        }

                        def name = FilenameUtils.removeExtension(file.getName())

                        if (it.contains("class ${name}") && it.contains("{") && !anno_added){

                            list.add("@CompileStatic")

                            anno_added = true

                        }

                        list.add(it)

                        if (it.contains("package ") && !import_added){

                            list.add("")

                            list.add("import groovy.transform.CompileStatic")

                            import_added = true

                        }

                    }

                    if (!bail){

                        BufferedWriter out = new BufferedWriter(new FileWriter(it))

                        list.each{

                            out.write(it)

                            out.newLine()

                        }

                        out.flush()

                        out.close()

                    }

                }

            }

        }

    }

     

    sourceMainGroovy.dependsOn staticGroovy

  2. I have a mod project that uses maven for dependencies. I use Intellij IDEA Ultimate for my IDE.

     

    Once I have set up the project using the idea switch for ForgeGradle how would I update the dependencies? Changing them in build.gradle and running the idea switch again doesn't seem to work. I'd rather not have to recreate the project file every time as I'd have to wait for it to index and import the gradle settings every time.

  3. Make sure you're checking the right things. Witht he gradle the only choice is to Obfusicate to SRG names.

    It LOOKS like it's not reobfed, because it's in the middle stage.

    All function references should be func_####_ {Unless it's a method we add in that code it doesnt change}

     

    Indeed I am checking the right things. Example:

     

    Code in Intelij: http://i.imgur.com/L81PXCch.png

     

    Class file compiled by gradle: http://i.imgur.com/NqUjQk1h.png

     

    Class file compiled by the old mcp scripts in 953: http://i.imgur.com/5WpPeQPh.png

     

    The mod fails to load in a normal minecraft environment as soon as it hits a deobf'd field.

     

  4. The only way I've seen it done is to modify the class and package it with your coremod. Override the class with a Transformer like how NEI does.

     

    Here is an example of a class overrider in the same vein as NEI. Link. Here is it being used in a Transformer. Link.

     

    You set the location in your FMLLoadingPlugin in injectData with a line like:

     

    location = (File) data.get("coremodLocation");

  5. The slot index corresponds to the slot of an ItemStack array that you should have created in your TileEntity. All of the IInventory implemented methods should point to that array.

     

    It basically maps out so that each slot in a GUI lines up with a slot in that array. So you put something in the slot that you designated slot 0 in your Container, it will go in 0 slot of the array inside the TileEntity and you can reference it from there.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.