FabricMC / fabric-loom

Gradle build system plugin used to automate the setup of a minecraft mod development environment.
MIT License
243 stars 212 forks source link

Option to disable automatic addition of environment annotations #1087

Open MattiDragon opened 8 months ago

MattiDragon commented 8 months ago

Loom currently adds @Environment(EnvType.CLIENT) to all client only minecraft classes with no way to disable. This isn't great as the annotations come from fabric loader, which isn't required for loom to work. The primary case where loom is used without loader is in multiloader setups, where loom is used for managing minecraft in the common subproject. Adding these annotations without loader on classpath results in ugly errors in IDEs and log spam from APs unable to resolve the annotations in the form of warning: unknown enum constant EnvType.CLIENT.

An option to disable environment annotations (or possibly to swap the out for a custom class) would improve the experiance when using loom for multiloader projects.

modmuss50 commented 8 months ago

This can likely be best fixed by allowing the jars to be split with splitMinecraftJar() without the adding the client only annotations. Care needs to be taken to ensure that the jar will get a diffrent name when this option is enabled. The API would be something like:

loom {
  splitMinecraftJar() {
     enableEnvAnnotations = false
   }
}