Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.