datagen biome modifiers for ores
This commit is contained in:
parent
c6059b0393
commit
a51a4a3ad0
@ -20,6 +20,7 @@ import net.minecraftforge.common.data.ForgeAdvancementProvider
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent
|
||||
import net.minecraftforge.fml.common.Mod
|
||||
import net.minecraftforge.data.event.GatherDataEvent
|
||||
import net.minecraftforge.registries.ForgeRegistries
|
||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||
import ru.dbotthepony.mc.otm.android.AndroidResearchDataProvider
|
||||
import ru.dbotthepony.mc.otm.block.*
|
||||
@ -531,6 +532,7 @@ object DataGen {
|
||||
.add(Registries.DAMAGE_TYPE, ::registerDamageTypes)
|
||||
.add(Registries.CONFIGURED_FEATURE, ::registerConfiguredFeatures)
|
||||
.add(Registries.PLACED_FEATURE, ::registerPlacedFeatures)
|
||||
.add(ForgeRegistries.Keys.BIOME_MODIFIERS, ::registerBiomeModifiers)
|
||||
|
||||
event.generator.addProvider(event.includeServer(), DatapackBuiltinEntriesProvider(event.generator.packOutput, event.lookupProvider, registrySetBuilder, setOf(MOD_ID)))
|
||||
|
||||
|
@ -1,10 +1,13 @@
|
||||
package ru.dbotthepony.mc.otm.datagen
|
||||
|
||||
import net.minecraft.core.HolderSet
|
||||
import net.minecraft.core.RegistrySetBuilder
|
||||
import net.minecraft.core.registries.Registries
|
||||
import net.minecraft.data.worldgen.BootstapContext
|
||||
import net.minecraft.resources.ResourceKey
|
||||
import net.minecraft.tags.BiomeTags
|
||||
import net.minecraft.tags.BlockTags
|
||||
import net.minecraft.world.level.levelgen.GenerationStep
|
||||
import net.minecraft.world.level.levelgen.VerticalAnchor
|
||||
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature
|
||||
import net.minecraft.world.level.levelgen.feature.Feature
|
||||
@ -15,10 +18,19 @@ import net.minecraft.world.level.levelgen.placement.InSquarePlacement
|
||||
import net.minecraft.world.level.levelgen.placement.PlacedFeature
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.TagMatchTest
|
||||
import net.minecraftforge.common.data.DatapackBuiltinEntriesProvider
|
||||
import net.minecraftforge.common.world.BiomeModifier
|
||||
import net.minecraftforge.common.world.ForgeBiomeModifiers
|
||||
import net.minecraftforge.data.event.GatherDataEvent
|
||||
import net.minecraftforge.registries.ForgeRegistries
|
||||
import ru.dbotthepony.mc.otm.registry.MBlocks
|
||||
|
||||
private val oreKey by lazy { ResourceKey.create(Registries.CONFIGURED_FEATURE, modLocation("tritanium_ore")) }
|
||||
private object ConfiguredFeatures {
|
||||
val TRITANIUM_ORE = key("tritanium_ore")
|
||||
|
||||
private fun key(name: String): ResourceKey<ConfiguredFeature<*, *>> {
|
||||
return ResourceKey.create(Registries.CONFIGURED_FEATURE, modLocation(name))
|
||||
}
|
||||
}
|
||||
|
||||
fun registerConfiguredFeatures(context: BootstapContext<ConfiguredFeature<*, *>>) {
|
||||
val stone = TagMatchTest(BlockTags.STONE_ORE_REPLACEABLES)
|
||||
@ -29,16 +41,23 @@ fun registerConfiguredFeatures(context: BootstapContext<ConfiguredFeature<*, *>>
|
||||
OreConfiguration.target(deepslate, MBlocks.DEEPSLATE_TRITANIUM_ORE.defaultBlockState()),
|
||||
)
|
||||
|
||||
context.register(oreKey, ConfiguredFeature(Feature.ORE, OreConfiguration(target, 9)))
|
||||
context.register(ConfiguredFeatures.TRITANIUM_ORE, ConfiguredFeature(Feature.ORE, OreConfiguration(target, 9)))
|
||||
}
|
||||
|
||||
private object PlacedFeatures {
|
||||
val NORMAL_TRITANIUM = key("normal_tritanium")
|
||||
val DEEP_TRITANIUM = key("deep_tritanium")
|
||||
|
||||
private fun key(name: String): ResourceKey<PlacedFeature> {
|
||||
return ResourceKey.create(Registries.PLACED_FEATURE, modLocation(name))
|
||||
}
|
||||
}
|
||||
|
||||
fun registerPlacedFeatures(context: BootstapContext<PlacedFeature>) {
|
||||
fun location(name: String) = ResourceKey.create(Registries.PLACED_FEATURE, modLocation(name))
|
||||
|
||||
val configured = context.lookup(Registries.CONFIGURED_FEATURE)
|
||||
val ore = configured.getOrThrow(oreKey)
|
||||
val ore = configured.getOrThrow(ConfiguredFeatures.TRITANIUM_ORE)
|
||||
|
||||
context.register(location("normal_tritanium"), PlacedFeature(
|
||||
context.register(PlacedFeatures.NORMAL_TRITANIUM, PlacedFeature(
|
||||
ore,
|
||||
listOf(
|
||||
CountPlacement.of(8),
|
||||
@ -47,7 +66,7 @@ fun registerPlacedFeatures(context: BootstapContext<PlacedFeature>) {
|
||||
)
|
||||
))
|
||||
|
||||
context.register(location("deep_tritanium"), PlacedFeature(
|
||||
context.register(PlacedFeatures.DEEP_TRITANIUM, PlacedFeature(
|
||||
ore,
|
||||
listOf(
|
||||
CountPlacement.of(10),
|
||||
@ -56,3 +75,28 @@ fun registerPlacedFeatures(context: BootstapContext<PlacedFeature>) {
|
||||
)
|
||||
))
|
||||
}
|
||||
|
||||
private object BiomeModifiers {
|
||||
val TRITANIUM_ORE = key("tritanium_ore")
|
||||
|
||||
private fun key(name: String): ResourceKey<BiomeModifier> {
|
||||
return ResourceKey.create(ForgeRegistries.Keys.BIOME_MODIFIERS, modLocation(name))
|
||||
}
|
||||
}
|
||||
|
||||
fun registerBiomeModifiers(context: BootstapContext<BiomeModifier>) {
|
||||
val placed = context.lookup(Registries.PLACED_FEATURE)
|
||||
val biomes = context.lookup(Registries.BIOME)
|
||||
|
||||
context.register(
|
||||
BiomeModifiers.TRITANIUM_ORE,
|
||||
ForgeBiomeModifiers.AddFeaturesBiomeModifier(
|
||||
biomes.getOrThrow(BiomeTags.IS_OVERWORLD),
|
||||
HolderSet.direct(
|
||||
placed.getOrThrow(PlacedFeatures.NORMAL_TRITANIUM),
|
||||
placed.getOrThrow(PlacedFeatures.DEEP_TRITANIUM)
|
||||
),
|
||||
GenerationStep.Decoration.UNDERGROUND_ORES
|
||||
)
|
||||
)
|
||||
}
|
||||
|
@ -1,9 +0,0 @@
|
||||
{
|
||||
"type": "forge:add_features",
|
||||
"biomes": "#minecraft:is_overworld",
|
||||
"features": [
|
||||
"overdrive_that_matters:deep_tritanium",
|
||||
"overdrive_that_matters:normal_tritanium"
|
||||
],
|
||||
"step": "underground_ores"
|
||||
}
|
Loading…
Reference in New Issue
Block a user