Skip to content

Instantly share code, notes, and snippets.

@shedaniel
Last active August 20, 2020 10:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shedaniel/1f819e811cefa59e414ef9f6c6d121db to your computer and use it in GitHub Desktop.
Save shedaniel/1f819e811cefa59e414ef9f6c6d121db to your computer and use it in GitHub Desktop.

This is a tutorial on registering ores to Minecraft 1.16.2 using Cloth API:

Step 1: Adding Cloth API

repositories {
  jcenter()
}

dependencies {
   modCompile "me.shedaniel.cloth.api:cloth-dynamic-registry-api-v1:1.2.1"
   include "me.shedaniel.cloth.api:cloth-dynamic-registry-api-v1:1.2.1"
}

Step 2: Listening to when the biomes are loaded and add the ores

Biomes registration has been moved to dynamic registry managers, DynamicRegistryCallback will listen to where entries are added to it.

RegistryKey<ConfiguredFeature<?, ?>> COPPER_ORE_KEY = RegistryKey.of(Registry.CONFIGURED_FEATURE_WORLDGEN, new Identifier("modid:copper_ore"));

DynamicRegistryCallback.callback(Registry.BIOME_KEY).register((manager, key, biome) -> {
    // You might also want to check if the biome is not nether and the end here.
    BiomesRegistry.registerFeature(manager, biome, GenerationStep.Feature.UNDERGROUND_ORES, COPPER_ORE_KEY);
});

Step 3: Making the ores json

Create a json file at src/main/resources/data/modid/worldgen/configured_feature/copper_ore.json, replace the modid and the copper_ore to the identifier of the registry key in the above java code.

This json template below is the json for iron ores, adjust accordingly for your mod's ore.

{
  "config": {
    "feature": {
      "config": {
        "feature": {
          "config": {
            "feature": {
              "config": {
                "target": {
                  "tag": "minecraft:base_stone_overworld",
                  "predicate_type": "minecraft:tag_match"
                },
                "state": {
                  "Name": "minecraft:iron_ore"
                },
                "size": 9
              },
              "type": "minecraft:ore"
            },
            "decorator": {
              "config": {
                "bottom_offset": 32,
                "top_offset": 32,
                "maximum": 80
              },
              "type": "minecraft:range"
            }
          },
          "type": "minecraft:decorated"
        },
        "decorator": {
          "config": {},
          "type": "minecraft:square"
        }
      },
      "type": "minecraft:decorated"
    },
    "decorator": {
      "config": {
        "count": 20
      },
      "type": "minecraft:count"
    }
  },
  "type": "minecraft:decorated"
}

Step 4: Test and play

There is no saying that this above method will work for future versions of minecraft considering that worldgen is changing rapidly. But at least it will work for now! Go and test if this will work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment