This is a tutorial on registering ores to Minecraft 1.16.2 using 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"
}
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);
});
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"
}
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.