1.19.3 OreGen / ConfiguredFeature Usage #2793
-
In short: I was following a tutorial and implementing Ore Generation using Configured Features until I realized that it's done differently in 1.19.3 (since a few Constants/Methods went missing). I checked out the 1.19.3 update post, and it briefly mentioned that the OreGen is now done using the DataGen API, as of my understanding. I searched the web and tried to implement it myself, but my Fabric API knowledge is limited (it's my second day working with it) and there seem to be no docs online regarding OreGen using DataGen (or more generally: Structures/Features using DataGen). More details can be found in #2792 (Next time I will write up the post here directly 😅, apologies). Thanks in advance 😄 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
I don't know if there are any tutorials for 1.19.3 yet? You can find this example in the fabric api testsuite: But you know you can just put your configured/placed features in json files in your src/main/resources/data Docs for datapacks: https://minecraft.fandom.com/wiki/Data_pack A"gui" to help you generate them: Vanilla's iron generation as json files: The datagen just lets you generate these files in a program. |
Beta Was this translation helpful? Give feedback.
-
@rshchekotov FYI, your issue is probably that you passed the wrong registriesFuture in the provider constructor. You pass the argument as is, you don't make one yourself. |
Beta Was this translation helpful? Give feedback.
-
Hey @warjort (and @apple502j), just wanted to thank you once again & let you know - I made it work! If someone will stumble upon this discussion in search for a solution, here's my way of doing it (It's Kotlin, but it should be easy to translate to Java if necessary, imports are not included, if not clear - feel free to ask!): Assuming you have: I prefer to split things in two, a "ModFeatures"-class and the "DataGen"-class, first the "ModFeatures": object ModOres {
val EXAMPLE_ORE = registerDualOre(
ModBlocks.EXAMPLE_BLOCK, ModBlocks.DEEPSLATE_EXAMPLE_BLOCK,
"example_block", 9)
fun registerDualOre(block: Block, deepslate: Block, key: String, size: Int): OreGenRegistry {
val featureConfig = OreFeatureConfig(
listOf(
OreFeatureConfig.createTarget(TagMatchRuleTest(BlockTags.STONE_ORE_REPLACEABLES), block.defaultState),
OreFeatureConfig.createTarget(TagMatchRuleTest(BlockTags.DEEPSLATE_ORE_REPLACEABLES), deepslate.defaultState)
), size)
val feature = ConfiguredFeature(Feature.ORE, featureConfig)
val configured = RegistryKey.of(RegistryKeys.CONFIGURED_FEATURE, custom(key))
val placed = RegistryKey.of(RegistryKeys.PLACED_FEATURE, custom(key))
return OreGenEntry(feature, configured, placed)
}
data class OreGenRegistry(
val feature: ConfiguredFeature<OreFeatureConfig, Feature<OreFeatureConfig>>,
val configured: RegistryKey<ConfiguredFeature<*, *>>,
val placed: RegistryKey<PlacedFeature>)
} And then, the "registered" Ore can be data-gen'ed as follows: class OreGenerationProvider(
output: FabricDataOutput?,
registriesFuture: CompletableFuture<RegistryWrapper.WrapperLookup>
) : FabricDynamicRegistryProvider(output, registriesFuture) {
override fun getName(): String {
return "Configured Features for minecraft:ores"
}
override fun configure(registries: RegistryWrapper.WrapperLookup, entries: Entries) {
val oreRegistry = registries.getWrapperOrThrow(RegistryKeys.CONFIGURED_FEATURE)
entries.addAll(oreRegistry)
entries.registerOre(ModOres.EXAMPLE_ORE, 20, YOffset.getBottom(), YOffset.fixed(64))
}
private fun Entries.registerOre(oreGenEntry: ModOres.OreGenEntry, count: Int, bottom: YOffset, top: YOffset) {
val featureRef = add(oreGenEntry.configured, oreGenEntry.feature)
val placedFeature = PlacedFeature(featureRef, listOf(
CountPlacementModifier.of(count),
SquarePlacementModifier.of(),
HeightRangePlacementModifier.uniform(bottom, top)
))
add(oreGenEntry.placed, placedFeature)
}
} (Note: the Kotlin-Extension Functions private static void registerOre(Entries entries, OreGenEntry oreGenEntry, ...) {
RegistryEntry<ConfiguredFeature<?, ?>> featureRef = entries.add(...)
// ...
} |
Beta Was this translation helpful? Give feedback.
I don't know if there are any tutorials for 1.19.3 yet?
You can find this example in the fabric api testsuite:
https://github.com/FabricMC/fabric/blob/1.19.3/fabric-biome-api-v1/src/testmod/java/net/fabricmc/fabric/test/biome/WorldgenProvider.java
But you know you can just put your configured/placed features in json files in your src/main/resources/data
Your mod is a datapack so all the normal rules apply.
Docs for datapacks: https://minecraft.fandom.com/wiki/Data_pack
A"gui" to help you generate them:
https://misode.github.io/
Vanilla's iron generation as json files:
https://github.com/misode/mcmeta/blob/data/data/minecraft/worldgen/configured_feature/ore_iron.json
https://github.com/mis…