Skip to content

Warning or weak warning for mod ID mismatch between java code and other files #2499

@O7410

Description

@O7410

Minecraft Development for IntelliJ plugin version

2025.2-1.8.5

Description of the feature request

sorry for the wall of text xD
I might be able to implement this suggestion myself, but only in a couple of weeks, so I wanted to put it somewhere

The following is written specifically for Fabric because I have more experience in it, but something similar could be made for Forge and NeoForge.

I'm not sure if this ↓ can happen in Forge or NeoForge.
I have seen stuff like specific parts of datagen silently not work for people because their mod IDs in fabric.mod.json and java code don't match. Everything else in the project worked, so tracking the issue down can be a nightmare

my suggestion specifically:
have an inspection that if there's a final String field called MOD_ID or MODID that is set to a constant expression in an initializer class that is used as an entrypoint in a fabric.mod.json file, if the mod id from that fabric.mod.json doesn't match that constant expression, have either a warning or a weak warning on the constant expression, with a quick fix to change it to the mod id from the fabric.mod.json.

optional: have another quick fix to change the mod id in fabric.mod.json to the one from the code

another optional: have the inspections and quick fixes also on the field in fabric.mod.json

possible problem: the fabric.mod.json can have certain parts be replaced with a string. in the online fabric template generator, the mod version in fabric.mod.json is replaced by build.gradle with the mod version from gradle.properties. if people do that with the mod id, this inspection can falsely flag that as a mod id mismatch.

solution to the possible problem: if the mod id in fabric.mod.json has $ then either it's invalid because mod IDs cannot contain $ or it's replaced with something else by build.gradle (${version} in fabric.mod.json from the online template generator)

another suggestion that comes from this is to have an inspection for an invalid mod id in fabric.mod.json or other similar files

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions