Download env.json — Minecraft Mods — MetaMods

env.json

Active

Downloads

0

Last update

1 year ago

Versions

1.20.1 — 1.21.1
Client
Fabric
Quilt
Game mechanics
Libraries
Control

env.json

env.json is a Minecraft library that introduces a new file format with the .env.json extension. The main purpose of this library is to redirect game resources to alternatives based on the current gameplay context.

Compatibility

The library works with Fabric Loader and Quilt Loader. For proper operation, Fabric API installation is required.

How It Works

The env.json library itself does not implement resource redirection mechanisms directly. Instead, it provides tools for working with .env.json files and managing resource reloading.

Official Implementations

Currently, there are two official implementations that utilize env.json capabilities:

Environment Driven Assets (EDA)

  • Mod identifier: env-driven-assets
  • Working environment: Client
  • Applies .env.json operations to standard Minecraft resource types

Environment Driven Data (EDD)

  • Mod identifier: env-driven-data
  • Working environment: Common and server
  • Applies .env.json operations to Minecraft data types

.env.json File Format

[
  {
    "rules": [ // primary rule set, works on "any" principle
      {
        "type": "sequence", // all rules in sequence must pass
        "rule": [] // rules
      },
      {
        "type": "any", // triggers if at least one rule passes
        "rule": [] // rules
      },
      {
        "type": "not", // inverts the rule
        "rule": { // rule
          "type": "...",
          "rule": "..."
        }
      },
      {
        "type": "dimension", // triggers if current dimension matches
        "rule": "minecraft:overworld" // dimension, can be a tag
      },
      {
        "type": "biome", // triggers if current biome matches
        "rule": "minecraft:plains" // biome, can be a tag
      },
      {
        "type": "x_coord", // checks X-axis coordinates
        "rule": {
          "comparator": "==", // can be <, >, ==, <=, >=, =< or =>
          "value": "100" // must be an integer
        }
      },
      {
        "type": "y_coord", // checks Y-axis coordinates
        "rule": {
          "comparator": "==", // can be <, >, ==, <=, >=, =< or =>
          "value": "100" // must be an integer
        }
      },
      {
        "type": "z_coord", // checks Z-axis coordinates
        "rule": {
          "comparator": "==", // can be <, >, ==, <=, >=, =< or =>
          "value": "100" // must be an integer
        }
      },
      {
        "type": "submerged", // checks if context is underwater
        "rule": true // true for "if underwater", false for "if not underwater"
      },
      {
        "type": "sky", // checks position relative to sky limit
        "rule": "at" // can be "above", "at" or "below"
      },
      {
        "type": "water", // checks position relative to water level
        "rule": "at" // can be "above", "at" or "below"
      },
      {
        "type": "void", // checks position relative to void limit
        "rule": "at" // can be "above", "at" or "below"
      }
    ],
    "result": "minecraft:block/stone" // redirected resource
  }
]

Files must be registered in the format: redirected_resource-extension.env.json.

Usage for Developers

In the build.gradle file:

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

// ...

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

Now you can get the EnvJson object from a Resource object using ExtendedResource#of(Resource)#getEnvJson or parse it using EnvJson#parse(Path) or EnvJson#parse(InputStream).