env.json

模组

· 作者 MModding

一个小型的 FabricMC 库,可将 `env.json` 文件转换为 Java 对象。它主要被 Environment Driven Assets 和 Environment Driven Data 所使用。

0 本站下载 0 关注 更新于 2 年前

需要前置:Fabric API

最新 0.4.3-beta · 1.21.1 · Fabric / Quilt

一键开服(送7天)

MModding

env.json

env.json logo

支持

Supports Fabric Loader Supports Quilt Loader

依赖

Requires Fabric API

概念

env.json 是一个 Minecraft 库,引入了一种新的子 JSON 文件扩展名格式,旨在根据环境上下文将 Minecraft 资源重定向到其他资源。

实现

env.json 不直接提供这些重定向功能,而是仅负责处理 env.json 文件及其资源重载管理的相关操作。

目前有两个官方实现的 env.json:

模组标识符:env-driven-assets。

适用环境:客户端 (Client)

将 env.json 操作应用于 Minecraft 原版资产类型。

  • Environment Driven Data (EDD)

模组标识符:env-driven-data。

适用环境:通用 & 服务端 (Common & Server)

将 env.json 操作应用于 Minecraft 原版数据包类型。

env.json 格式

[
  {
    "rules": [ // 主要规则集,属于 "any" 类型
      {
        "type": "sequence", // 序列中的所有规则都必须通过
        "rule": [] // 规则列表
      },
      {
        "type": "any", // 只要至少有一条规则通过即生效
        "rule": [] // 规则列表
      },
      {
        "type": "not", // 反转规则结果
        "rule": { // 被反转的规则
          "type": "...",
          "rule": "..."
        }
      },
      {
        "type": "dimension", // 如果当前维度与此匹配则通过
        "rule": "minecraft:overworld" // 维度,也可以是标签 (tag)
      },
      {
        "type": "biome", // 如果当前生物群系与此匹配则通过
        "rule": "minecraft:plains" // 生物群系,也可以是标签 (tag)
      },
      {
        "type": "x_coord", // 如果对 X 轴的操作有效则通过
        "rule": {
          "comparator": "==", // 必须是 <, >, ==, <=, >=, =< 或 =>
          "value": "100" // 必须是整数
        }
      },
      {
        "type": "y_coord", // 如果对 Y 轴的操作有效则通过
        "rule": {
          "comparator": "==", // 必须是 <, >, ==, <=, >=, =< 或 =>
          "value": "100" // 必须是整数
        }
      },
      {
        "type": "z_coord", // 如果对 Z 轴的操作有效则通过
        "rule": {
          "comparator": "==", // 必须是 <, >, ==, <=, >=, =< 或 =>
          "value": "100" // 必须是整数
        }
      },
      {
        "type": "submerged", // 如果当前上下文被水包围或未包围则通过
        "rule": true // true 表示“如果被水包围”,false 表示“如果未被水包围”
      },
      {
        "type": "sky", // 如果上下文在天空限制之上、等于或之下则通过
        "rule": "at" // 必须是 "above"(之上)、"at"(等于)或 "below"(之下)
      },
      {
        "type": "water", // 如果上下文在水位之上、等于或之下则通过
        "rule": "at" // 必须是 "above"(之上)、"at"(等于)或 "below"(之下)
      },
      {
        "type": "void", // 如果上下文在虚空限制之上、等于或之下则通过
        "rule": "at" // 必须是 "above"(之上)、"at"(等于)或 "below"(之下)
      }
    ],
    "result": "minecraft:block/stone" // 重定向的目标资源
  }
]

该文件必须按以下格式注册:redirected_resource_name-redirected_resource_extension.env.json。

开发者用法

在你的 build.gradle 中:

repositories {
    // ...
    maven { url 'https://jitpack.io' }
}

// ...

dependencies {
    // ...
    modImplementation "com.mmodding:env.json:${theMostBeautifulVersionYouCanFind}"
}

你现在可以通过 ExtendedResource#of(Resource)#getEnvJson 从 Resource 对象获取你的 EnvJson 对象,或者使用 EnvJson#parse(Path) 或 EnvJson#parse(InputStream) 进行解析。

开发者徽章

Requires env.json

[<img src="https://github.com/MModding/art/blob/main/mods/env_json/requires_env_json.png?raw=true" width="256" alt="Requires env.json">](https://modrinth.com/mod/env.json)

推广

ModFest 1.20

你是这个资源的作者?登录后可认领此资源。

评论 0

0.0
暂无评分
5 星
0
4 星
0
3 星
0
2 星
0
1 星
0
我的评分

登录后参与评分

还没有评论,来抢沙发吧

评论配图

相似资源