Skip to content

Surface Rules

gniftygnome edited this page Mar 27, 2024 · 8 revisions

Adding Surface Material Rules

Each material rule to be added requires the dimension key of the target dimension, an identifier to specify the rules owner, and one or more material rules.

The namespace of the rules owner must match the namespace of the biome(s) to which the rule will apply in order to be compatible with TerraBlender. Otherwise, when TerraBlender is present, the material rules may not be applied. Overriding the material rules of vanilla biomes is also not allowed by TerraBlender.

If more than one material rule with the same owner identifier is supplied, rules with identical owner id will be sequenced together by Biolith prior to injection.

in code

  • Methods: addOverworldSurfaceRules, addNetherSurfaceRules, addEndSurfaceRules
MaterialRule birchForest = condition(MaterialRules.biome(BiomeKeys.BIRCH_FOREST),
        block(Blocks.CALCITE));

MaterialRule crimsonForest = condition(MaterialRules.biome(BiomeKeys.CRIMSON_FOREST), sequence(
        condition(STONE_DEPTH_FLOOR,
                MaterialRules.sequence(
                        MaterialRules.condition(
                                MaterialRules.noiseThreshold(NoiseParametersKeys.NETHER_WART, 1.17),
                                block(Blocks.NETHER_WART_BLOCK)),
                        block(Blocks.CRIMSON_NYLIUM))),
        block(Blocks.NETHERRACK)));

MaterialRule warpedForest = condition(MaterialRules.biome(BiomeKeys.WARPED_FOREST), sequence(
        condition(STONE_DEPTH_FLOOR,
                MaterialRules.sequence(
                        MaterialRules.condition(
                                MaterialRules.noiseThreshold(NoiseParametersKeys.NETHER_WART, 1.17),
                                block(Blocks.WARPED_WART_BLOCK)),
                        block(Blocks.WARPED_NYLIUM))),
        block(Blocks.NETHERRACK)));

SurfaceGeneration.addOverworldSurfaceRules(
        Identifier.of("minecraft", "rules/overworld"),
        condition(surface(), sequence(birchForest, crimsonForest, warpedForest)));

as data

  • Multiple surface rules can be specified in the surface_rules list.

Material rules specified in JSON datapacks must parse correctly using Mojang's material rule CODEC, or they may be silently discarded. For more information about writing material rules in JSON, see these sites:

{
  "surface_rules": [
    {
      "dimension": "minecraft:overworld",
      "rules_owner": "biolith_examples:breaks_with_terrablender",
      "material_rules": [
        {
          "type": "minecraft:condition",
          "if_true": {
            "type": "minecraft:biome",
            "biome_is": [
              "minecraft:birch_forest"
            ]
          },
          "then_run": {
            "type": "minecraft:block",
            "result_state": {
              "Name": "minecraft:calcite"
            }
          }
        }
      ]
    },
    {
      "dimension": "minecraft:overworld",
      "rules_owner": "minecraft:rules/overworld",
      "material_rules": [
        {
          "type": "minecraft:condition",
          "if_true": {
            "type": "minecraft:above_preliminary_surface"
          },
          "then_run": {
            "type": "minecraft:sequence",
            "sequence": [
              {
                "type": "minecraft:condition",
                "if_true": {
                  "type": "minecraft:biome",
                  "biome_is": [
                    "minecraft:crimson_forest"
                  ]
                },
                "then_run": {
                  "type": "minecraft:sequence",
                  "sequence": [
                    {
                      "type": "minecraft:condition",
                      "if_true": {
                        "type": "minecraft:stone_depth",
                        "surface_type": "floor",
                        "add_surface_depth": false,
                        "secondary_depth_range": 0,
                        "offset": 0
                      },
                      "then_run": {
                        "type": "minecraft:sequence",
                        "sequence": [
                          {
                            "type": "minecraft:condition",
                            "if_true": {
                              "type": "minecraft:noise_threshold",
                              "noise": "minecraft:nether_wart",
                              "min_threshold": 1.17,
                              "max_threshold": 1E308
                            },
                            "then_run": {
                              "type": "minecraft:block",
                              "result_state": {
                                "Name": "minecraft:nether_wart_block"
                              }
                            }
                          },
                          {
                            "type": "minecraft:block",
                            "result_state": {
                              "Name": "minecraft:crimson_nylium"
                            }
                          }
                        ]
                      }
                    },
                    {
                      "type": "minecraft:block",
                      "result_state": {
                        "Name": "minecraft:netherrack"
                      }
                    }
                  ]
                }
              },
              {
                "type": "minecraft:condition",
                "if_true": {
                  "type": "minecraft:biome",
                  "biome_is": [
                    "minecraft:warped_forest"
                  ]
                },
                "then_run": {
                  "type": "minecraft:sequence",
                  "sequence": [
                    {
                      "type": "minecraft:condition",
                      "if_true": {
                        "type": "minecraft:stone_depth",
                        "surface_type": "floor",
                        "add_surface_depth": false,
                        "secondary_depth_range": 0,
                        "offset": 0
                      },
                      "then_run": {
                        "type": "minecraft:sequence",
                        "sequence": [
                          {
                            "type": "minecraft:condition",
                            "if_true": {
                              "type": "minecraft:noise_threshold",
                              "noise": "minecraft:nether_wart",
                              "min_threshold": 1.17,
                              "max_threshold": 1E308
                            },
                            "then_run": {
                              "type": "minecraft:block",
                              "result_state": {
                                "Name": "minecraft:warped_wart_block"
                              }
                            }
                          },
                          {
                            "type": "minecraft:block",
                            "result_state": {
                              "Name": "minecraft:warped_nylium"
                            }
                          }
                        ]
                      }
                    },
                    {
                      "type": "minecraft:block",
                      "result_state": {
                        "Name": "minecraft:netherrack"
                      }
                    }
                  ]
                }
              }
            ]
          }
        }
      ]
    }
  ]
}
Clone this wiki locally