Interface ForgeExtensionAPI

All Known Implementing Classes:
ForgeExtensionImpl

@NonExtendable public interface ForgeExtensionAPI
This is the Forge extension API available to build scripts.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    Deprecated, for removal: This API element is subject to removal in a future version.
    Removed in favor of configuring the data generator directly.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    default void
    convertAccessWideners(org.gradle.api.tasks.TaskProvider<? extends org.gradle.jvm.tasks.Jar> jarTask, String... awPaths)
    Sets up AW → AT conversion for the provided jar task.
    void
    convertAccessWideners(org.gradle.api.tasks.TaskProvider<? extends org.gradle.jvm.tasks.Jar> jarTask, org.gradle.api.Action<? super Aw2AtSettings> action)
    Sets up AW → AT conversion for the provided jar task.
    void
    dataGen(org.gradle.api.Action<ForgeExtensionAPI.DataGenConsumer> action)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Removed in favor of configuring the data generator directly.
    org.gradle.api.file.ConfigurableFileCollection
    A collection of all project access transformers.
    org.gradle.api.provider.Property<Boolean>
    If true, the project access widener file will be remapped to an access transformer file if set.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Removed in favor of configuring the data generator directly.
    org.gradle.api.provider.SetProperty<String>
    A set of additional access widener files that will be converted to access transformers if enabled.
    org.gradle.api.provider.SetProperty<String>
    A set of all mixin configs related to source set resource roots.
    org.gradle.api.provider.Property<Pack200Provider>
    pack200 解包器,仅供 legacy Forge(1.8-1.16)使用.
    org.gradle.api.provider.Property<Boolean>
    If true, upstream Mixin from Sponge will be replaced with Fabric's or Architectury's fork.
    org.gradle.api.provider.Property<Boolean>
    Deprecated, for removal: This API element is subject to removal in a future version.
    This API is not needed on newer Minecraft versions where Forge forces its own logger config.
    default void
    mixinConfig(String... mixinConfigs)
    Adds mixin config files to mixinConfigs.
    void
    mixinConfigs(String... mixinConfigs)
    Adds mixin config files to mixinConfigs.
  • Method Details

    • getConvertAccessWideners

      org.gradle.api.provider.Property<Boolean> getConvertAccessWideners()
      If true, the project access widener file will be remapped to an access transformer file if set.

      Note that convertAccessWideners(TaskProvider, String...) can be used instead of this method for more fine-grained control over which jar task converts the access wideners. This method targets the remapJar task on obfuscated versions and the jar task on unobfuscated versions.

      Returns:
      the property
    • getExtraAccessWideners

      org.gradle.api.provider.SetProperty<String> getExtraAccessWideners()
      A set of additional access widener files that will be converted to access transformers if enabled. The files are specified as paths in jar files (e.g. path/to/my_aw.accesswidener).

      Note that convertAccessWideners(TaskProvider, String...) can be used instead of this method for more fine-grained control over which jar task converts the access wideners. This method targets the remapJar task on obfuscated versions and the jar task on unobfuscated versions.

      Returns:
      the property
    • getAccessTransformers

      org.gradle.api.file.ConfigurableFileCollection getAccessTransformers()
      A collection of all project access transformers. The collection should only contain AT files, and not directories or other files.

      If this collection is empty, Loom tries to resolve the AT from the default path (META-INF/accesstransformer.cfg in the main source set).

      Returns:
      the collection of AT files
    • accessTransformer

      void accessTransformer(Object file)
      Parameters:
      file - the file, evaluated as per Project.file(Object)
    • convertAccessWideners

      @Experimental void convertAccessWideners(org.gradle.api.tasks.TaskProvider<? extends org.gradle.jvm.tasks.Jar> jarTask, org.gradle.api.Action<? super Aw2AtSettings> action)
      Sets up AW → AT conversion for the provided jar task.

      The file paths are relative to the mod jar root, corresponding to resources directories in a development environment, not the project directory! For example, "my_mod.accesswidener" corresponds to the source file src/main/resources/my_mod.accesswidener.

      The specified files will be converted and removed from the final jar.

      In projects with an obfuscated version of Minecraft, this method must target remapJar or another RemapJarTask in order for the access transformer to be remapped properly.

      When the provided task is a RemapJarTask, the AW paths will simply be added to the corresponding atAccessWideners property.

    • convertAccessWideners

      @Experimental default void convertAccessWideners(org.gradle.api.tasks.TaskProvider<? extends org.gradle.jvm.tasks.Jar> jarTask, String... awPaths)
      Sets up AW → AT conversion for the provided jar task.

      The file paths are relative to the mod jar root, corresponding to resources directories in a development environment, not the project directory! For example, "my_mod.accesswidener" corresponds to the source file src/main/resources/my_mod.accesswidener.

      The specified files will be converted and removed from the final jar.

      In projects with an obfuscated version of Minecraft, this method must target remapJar or another RemapJarTask in order for the access transformer to be remapped properly.

      When the provided task is a RemapJarTask, the AW paths will simply be added to the corresponding atAccessWideners property.

      Usage example on unobfuscated versions:

      loom.forge.convertAccessWideners(tasks.jar, "my_mod.accesswidener")
      
      Parameters:
      awPaths - the paths of the access wideners relative to the mod jar root, cannot be empty
    • getMixinConfigs

      org.gradle.api.provider.SetProperty<String> getMixinConfigs()
      A set of all mixin configs related to source set resource roots. All mixin configs must be added to this property so that they apply in a dev environment.
      Returns:
      the property
    • mixinConfigs

      void mixinConfigs(String... mixinConfigs)
      Adds mixin config files to mixinConfigs.
      Parameters:
      mixinConfigs - the mixin config file paths relative to resource roots
    • mixinConfig

      default void mixinConfig(String... mixinConfigs)
      Adds mixin config files to mixinConfigs.
      Parameters:
      mixinConfigs - the mixin config file paths relative to resource roots
    • getUseCustomMixin

      org.gradle.api.provider.Property<Boolean> getUseCustomMixin()
      If true, upstream Mixin from Sponge will be replaced with Fabric's or Architectury's fork. This is enabled by default.
      Returns:
      the property
    • getUseForgeLoggerConfig

      @ScheduledForRemoval(inVersion="2.0") @Deprecated(forRemoval=true) org.gradle.api.provider.Property<Boolean> getUseForgeLoggerConfig()
      Deprecated, for removal: This API element is subject to removal in a future version.
      This API is not needed on newer Minecraft versions where Forge forces its own logger config.
      If true, Loom will use Forge's Log4J config file instead of its own. This is disabled by default.
      Returns:
      the property
    • getPack200Provider

      org.gradle.api.provider.Property<Pack200Provider> getPack200Provider()
      pack200 解包器,仅供 legacy Forge(1.8-1.16)使用.

      legacy 的 binpatches 以 pack200 压缩,而 JDK 自 14 起不再自带解包实现, 需要调用方注入(例如 architectury-pack200)。

    • getDataGenMods

      @ScheduledForRemoval(inVersion="2.0") @Deprecated(forRemoval=true) List<String> getDataGenMods()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Removed in favor of configuring the data generator directly.
      A list of mod IDs for mods applied for data generation. The returned list is unmodifiable but not immutable - it will reflect changes done with dataGen(Action).
      Returns:
      the list
    • dataGen

      @ScheduledForRemoval(inVersion="2.0") @Deprecated(forRemoval=true) void dataGen(org.gradle.api.Action<ForgeExtensionAPI.DataGenConsumer> action)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Removed in favor of configuring the data generator directly.
      Applies data generation settings.
      Parameters:
      action - the action to configure data generation