Skip to content

[7.0] Minecraft extension lacking IDE support #984

@PaintNinja

Description

@PaintNinja

The following code has no IDE support currently:

minecraft {
    mappings channel: 'official', version: '1.21.8'
    
    runs {
        server {
            mainClass = 'net.minecraft.server.Main'

            args 'nogui'
        }
    }
}
Image

After investigating further, I've determined that it's due to a visibility issue - IntelliJ is picking up the internal implementations which are not publicly accessible:
Image

A workaround is to manually cast to the correct type and wrap in a tap, like so:

minecraft {  ((MinecraftExtension.ForProject) it).tap {
    mappings channel: 'official', version: '1.21.8'
    
    runs {
        server {
            mainClass = 'net.minecraft.server.Main'

            args 'nogui'
        }
    }
}}
Image

As for the yellow highlight for the runs block, that's because IntelliJ is a dumbass and thinks Closure<Void> means you expect users to explicitly return null - likely a bug in their Groovy support. I remember advising you to add the return type and forgot about this edge-case, my bad. The fix is to replace Closure<Void> with Closure<?> or have a raw Closure when you don't care about the return type (such as void).

Interestingly, the fg extension does have IDE support. Possibly a difference between how the fg and minecraft extensions are registered?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions