User Tools

Site Tools


zh_cn:documentation:fabric_mod_json

This is an old revision of the document!


fabric.mod.json

fabric.mod.json 文件是由 Fabric 加载器使用以加载模组的模组元数据文件。模组需要有这个文件才能被加载,该文件需要放在模组 JAR 的根目录下,且名称一致。

必要字段

  • schemaVersion 用于内部机制。总是为 1
  • id 定义模组的 id——由字母、数字、下划线组成的字符串,长度为 1 到 63。。
  • version 定义模组版本——字符串值,建议符合 Semantic Versioning 2.0.0 的规定。

可选字段

模组加载

  • environment:定义了模组在哪里运行:只在客户端(客户端模组),或只在服务端(插件),或二者(常规模组)。包含环境标识符:
    • * 运行在客户端与服务的。默认。
    • client 运行在客户端。
    • server 运行在服务端。
  • entrypoints 定义了你的模组的要加载的主要的类。
    • 你的模组有三种默认的入口点:
      • main 会先运行。用于实现了 ModInitializer 的类。
      • client 仅在客户端,会随后运行。用于实现了 ClientModInitializer 的类。
      • server 仅在服务端,会随后运行。用于实现了 DedicatedServerModInitializer
    • 每个入口点都可以包含多个需要加载的模组。类(或者方法,或者静态字段)可以用两种方式定义:
      • 如果使用Java,列举类(或者其他)的完整名称。例如:
        "main": [
            "net.fabricmc.example.ExampleMod",
            "net.fabricmc.example.ExampleMod::handle"
        ]
  • 如果你使用其他语言,参考该语言的文档。Kotlin 的位于 此网站
  • jars 你的模组 JAR 中需要加载的嵌套 JAR。使用此字段前,请参考使用嵌套 JAR 的指引。每一项都是包含 file 键的对象,这个键应该是你的模组 JAR 到嵌套 JAR 的路径。例如:
    "jars": [
       {
          "file": "nested/vendor/dependency.jar"
       }
    ]
  • languageAdapters 从使用的语言映射到其接收器(adapter)类完整名称的字典。例如:
    "languageAdapters": {
       "kotlin": "net.fabricmc.language.kotlin.KotlinAdapter"
    }
  • mixins mixin配置文件的列表。每一项都是到你的模组 JAR 内的 mixin 配置文件的路径,或者包含以下字段的对象:
    • config 你的模组 JAR 内到 mixin 配置文件的路径。
    • environment 与上层 environment 字段相同。见上。如:
      "mixins": [
         "modid.mixins.json",
         {
            "config": "modid.client-mixins.json",
            "environment": "client"
         }
      ]

依赖解析

下方各对象的项的键均为依赖的模组 id。

每一个键的值都是字符串,或者字符串数组,声明支持的版本范围。对于数组,会假定一个“OR”关系——也就是说,只要符合其中一个。

对于所有版本的情况,*是特殊的字符串,声明所有版本都符合该范围。此外,无论版本范围,必须能够符合准确字符串。

  • depends 需要才能运行的依赖,否则游戏崩溃。
  • recommends 不必要就能运行的依赖,否则游戏会输出警告。
  • suggests 不需要就能运行的依赖,用作元数据。
  • breaks 一起运行可能导致游戏崩溃的模组。一起运行时,游戏崩溃。
  • conflicts 一起运行时游戏可能出现问题的模组。一起运行时,会输出警告。

元数据

  • name Defines the user-friendly mod's name. If not present, assume it matches id.
  • description Defines the mod's description. If not present, assume empty string.
  • contact Defines the contact information for the project. It is an object of the following fields:
    • email Contact e-mail pertaining to the mod. Must be a valid e-mail address.
    • irc IRC channel pertaining to the mod. Must be of a valid URL format - for example: irc://irc.esper.net:6667/charset for #charset at EsperNet - the port is optional, and assumed to be 6667 if not present.
    • homepage Project or user homepage. Must be a valid HTTP/HTTPS address.
    • issues Project issue tracker. Must be a valid HTTP/HTTPS address.
    • sources Project source code repository. Must be a valid URL - it can, however, be a specialized URL for a given VCS (such as Git or Mercurial).
    • The list is not exhaustive - mods may provide additional, non-standard keys (such as discord, slack, twitter, etc) - if possible, they should be valid URLs.
  • authors A list of authors of the mod. Each entry is a single name or an object containing following fields:
    • name The real name, or username, of the person. Mandatory.
    • contact Person's contact information. The same as upper level contact. See above. Optional.
  • contributors A list of contributors to the mod. Each entry is the same as in author field. See above.
  • license Defines the licensing information. Can either be a single license string or a list of them.
    • This should provide the complete set of preferred licenses conveying the entire mod package. In other words, compliance with all listed licenses should be sufficient for usage, redistribution, etc. of the mod package as a whole.
    • For cases where a part of code is dual-licensed, choose the preferred license. The list is not exhaustive, serves primarily as a kind of hint, and does not prevent you from granting additional rights/licenses on a case-by-case basis.
    • To aid automated tools, it is recommended to use SPDX License Identifiers for open-source licenses.
  • icon Defines the mod's icon. Icons are square PNG files. (Minecraft resource packs use 128×128, but that is not a hard requirement - a power of two is, however, recommended.) Can be provided in one of two forms:
    • A path to a single PNG file.
    • A dictionary of images widths to their files' paths.

自定义字段

You can add any field you want to add inside custom field. Loader would ignore them. However it's highly recommended to namespace your fields to avoid conflicts if your fields (names) would be added to the standard specification.

zh_cn/documentation/fabric_mod_json.1630483974.txt.gz · Last modified: 2021/09/01 08:12 by solidblock