Reputation: 19
Tutorials for modding Minecraft using Minecraftforge use a constant called BuiltInRegistries.CONFIGURED_FEATURE
to allow a mod to register a custom feature. This constant is missing from Minecraft 1.19.3.
For example, this solution to a similar problem doesn't work in 1.19: Minecraft Forge Modding 1.18.1 Ore Generation Confusion
Does anyone know what this has been replaced with in 1.19.3 or know of an updated tutorial. Here's what we're doing:
final Block MY_ORE_BLOCK = Registry.register(BuiltInRegistries.BLOCK, "my_ore", new DropExperienceBlock(BlockBehaviour.Properties.of(Material.STONE).requiresCorrectToolForDrops().strength(3.0F, 3.0F), UniformInt.of(3, 7)));
final ResourceKey<ConfiguredFeature<?, ?>> MY_ORE_LARGE = FeatureUtils.createKey("my_ore_large");
List<OreConfiguration.TargetBlockState> list = List.of(OreConfiguration.target(ruletest1, MY_ORE_BLOCK.defaultBlockState()));
ConfiguredFeature<?,?> feature = new ConfiguredFeature(Feature.ORE, new OreConfiguration(list, 4, 0.5F));
Registry.register(BuiltInRegistries.CONFIGURED_FEATURE, MY_ORE_LARGE, feature);
The purpose of the code being to create a new type of Ore and to register it as a feature so that the world generator generates deposits of it.
We tried to compile, but BuiltInRegistries doesn't have a CONFIGURED_FEATURE
constant in 1.19.3 so that doesn't compile.
We also tried to use FeatureUtils.register()
to register the feature but couldn't find how to get a BootstapContext to pass to its first parameter.
Upvotes: 0
Views: 1157
Reputation: 19
I found a solution to the problem. The authors of minecraftforge said that ConfiguredFeature
s are now data driven. After a lot more research, I found that the following json files were needed in order to generate ore (no code needed except to create the new Block
):
data/mymod/worldgen/placed_feature/ore_mine.json
{
"feature": "examplemod:ore_mine_small",
"placement": [
{
"type": "minecraft:count",
"count": 16
},
{
"type": "minecraft:in_square"
},
{
"type": "minecraft:height_range",
"height": {
"type": "minecraft:trapezoid",
"max_inclusive": {
"absolute": 112
},
"min_inclusive": {
"absolute": -16
}
}
},
{
"type": "minecraft:biome"
}
]
}
data/mymod/worldgen/configured_feature/ore_mine_small.json
{
"type": "minecraft:ore",
"config": {
"discard_chance_on_air_exposure": 0.0,
"size": 10,
"targets": [
{
"state": {
"Name": "examplemod:my_ore"
},
"target": {
"predicate_type": "minecraft:tag_match",
"tag": "minecraft:stone_ore_replaceables"
}
},
{
"state": {
"Name": "examplemod:my_ore"
},
"target": {
"predicate_type": "minecraft:tag_match",
"tag": "minecraft:deepslate_ore_replaceables"
}
}
]
}
}
data/mymod/forge/biome_modifier/add_my_ore.json
{
"type": "forge:add_features",
"biomes": "#minecraft:is_overworld",
"features": "examplemod:ore_mine_small",
"step": "underground_ores"
}
The first two files define how to place the new ore similarly to how built in ores are placed. The third file is what adds this configured feature to specific biomes. It was documented in net.minecraftforge.common.world.ForgeBiomeModifiers
, but the documentation didn't clarify where the json file should be placed: data/examplemod/forge/biome_modifier/
Upvotes: 1
Reputation: 551
Use the FEATURES
deferred registry
Forge Docs on registries, Forge JavaDocs of FEATURES
registry.
private static final DeferredRegister<Feature<?>> FEATURES = DeferredRegister.create(ForgeRegistries.FEATURES, MODID);
Upvotes: 0