diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/WorldGen.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/WorldGen.kt index 43d292e1d..50f4f0935 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/WorldGen.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/WorldGen.kt @@ -33,8 +33,10 @@ import ru.dbotthepony.mc.otm.registry.game.MBlocks import ru.dbotthepony.mc.otm.registry.data.MWorldGenFeatures import ru.dbotthepony.mc.otm.worldgen.feature.BlackHolePlacerFeature import ru.dbotthepony.mc.otm.worldgen.feature.DebugPlacerFeature +import ru.dbotthepony.mc.otm.worldgen.placement.ChainPlacement import ru.dbotthepony.mc.otm.worldgen.placement.EnormousPlacement import ru.dbotthepony.mc.otm.worldgen.placement.EllipsoidPlacement +import ru.dbotthepony.mc.otm.worldgen.placement.SplitPlacement import ru.dbotthepony.mc.otm.worldgen.placement.WormPlacement private object ConfiguredFeatures { @@ -59,8 +61,8 @@ fun registerConfiguredFeatures(context: BootstrapContext ) context.register(ConfiguredFeatures.TRITANIUM_ORE, ConfiguredFeature(Feature.ORE, OreConfiguration(target, 9))) - //context.register(ConfiguredFeatures.TRITANIUM_ORE_SMALL, ConfiguredFeature(Feature.REPLACE_SINGLE_BLOCK, ReplaceBlockConfiguration(target))) - context.register(ConfiguredFeatures.TRITANIUM_ORE_SMALL, ConfiguredFeature(MWorldGenFeatures.DEBUG_PLACEMENT, DebugPlacerFeature.Config(MBlocks.TRITANIUM_ORE.defaultBlockState()))) + context.register(ConfiguredFeatures.TRITANIUM_ORE_SMALL, ConfiguredFeature(Feature.REPLACE_SINGLE_BLOCK, ReplaceBlockConfiguration(target))) + //context.register(ConfiguredFeatures.TRITANIUM_ORE_SMALL, ConfiguredFeature(MWorldGenFeatures.DEBUG_PLACEMENT, DebugPlacerFeature.Config(MBlocks.TRITANIUM_ORE.defaultBlockState()))) } run { @@ -120,28 +122,45 @@ fun registerPlacedFeatures(context: BootstrapContext) { chunkScanRange = 24, seedMix = 9284343575495L, children = listOf( - RarityFilter.onAverageOnceEvery(300), + RarityFilter.onAverageOnceEvery(140), InSquarePlacement.spread(), - HeightRangePlacement.of(StandardDeviationHeightProvider(VerticalAnchor.absolute(120), 15.0)), - WormPlacement( - length = UniformInt.of(120, 400), - turnRateXY = WormPlacement.normalDistributedTurnRate(10f), - turnRateXZ = WormPlacement.normalDistributedTurnRate(60f), - turnSpeedXZ = WormPlacement.constantTurnRate(10f), - turnSpeedXY = WormPlacement.constantTurnRate(4f), - turnChanceXY = BooleanProvider.Unbiased(6), - turnChanceXZ = BooleanProvider.BiasedLinear(0.6f, 5), - maxTravelUp = 16, - maxTravelDown = 16, - ), - EllipsoidPlacement( - count = UniformInt.of(4, 7), - xLength = ConstantFloat.of(6f), - yLength = ConstantFloat.of(6f), - zLength = ConstantFloat.of(6f), - x = ClampedNormalFloat.of(0f, 0.2f, -1f, 1f), - y = ClampedNormalFloat.of(0f, 0.2f, -1f, 1f), - z = ClampedNormalFloat.of(0f, 0.2f, -1f, 1f), + HeightRangePlacement.of(StandardDeviationHeightProvider(VerticalAnchor.absolute(-40), 15.0)), + SplitPlacement( + // "heart" + EllipsoidPlacement( + count = UniformInt.of(600, 900), + xLength = UniformFloat.of(9f, 12f), + yLength = UniformFloat.of(9f, 12f), + zLength = UniformFloat.of(9f, 12f), + x = ClampedNormalFloat.of(0f, 0.4f, -1f, 1f), + y = ClampedNormalFloat.of(0f, 0.4f, -1f, 1f), + z = ClampedNormalFloat.of(0f, 0.4f, -1f, 1f), + ), + // "branches" + ChainPlacement( + CountPlacement.of(UniformInt.of(2, 7)), + WormPlacement( + length = UniformInt.of(60, 120), + turnRateXY = WormPlacement.normalDistributedTurnRate(2f, 3f), + initialAngleXY = WormPlacement.normalDistributedTurnRate(3f, 4f), + turnRateXZ = WormPlacement.normalDistributedTurnRate(30f), + turnSpeedXZ = WormPlacement.constantTurnRate(10f), + turnSpeedXY = WormPlacement.constantTurnRate(4f), + turnChanceXY = BooleanProvider.Unbiased(6), + turnChanceXZ = BooleanProvider.BiasedLinear(0.6f, 5), + maxTravelUp = 90, + maxTravelDown = 10, + ), + EllipsoidPlacement( + count = UniformInt.of(3, 6), + xLength = ConstantFloat.of(4f), + yLength = ConstantFloat.of(4f), + zLength = ConstantFloat.of(4f), + x = ClampedNormalFloat.of(0f, 0.2f, -1f, 1f), + y = ClampedNormalFloat.of(0f, 0.2f, -1f, 1f), + z = ClampedNormalFloat.of(0f, 0.2f, -1f, 1f), + ) + ) ) ) ) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/data/MPlacementModifiers.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/data/MPlacementModifiers.kt index 276041103..9df5e6202 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/data/MPlacementModifiers.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/data/MPlacementModifiers.kt @@ -4,8 +4,10 @@ import net.minecraft.core.registries.BuiltInRegistries import net.minecraft.world.level.levelgen.placement.PlacementModifierType import net.neoforged.bus.api.IEventBus import ru.dbotthepony.mc.otm.registry.MDeferredRegister +import ru.dbotthepony.mc.otm.worldgen.placement.ChainPlacement import ru.dbotthepony.mc.otm.worldgen.placement.EllipsoidPlacement import ru.dbotthepony.mc.otm.worldgen.placement.EnormousPlacement +import ru.dbotthepony.mc.otm.worldgen.placement.SplitPlacement import ru.dbotthepony.mc.otm.worldgen.placement.WormPlacement object MPlacementModifiers { @@ -18,4 +20,6 @@ object MPlacementModifiers { val ENORMOUS by registry.register("enormous") { PlacementModifierType { EnormousPlacement.CODEC } } val ELLIPSOID_PLACEMENT by registry.register("ellipsoid") { PlacementModifierType { EllipsoidPlacement.CODEC } } val WORM_PLACEMENT by registry.register("worm") { PlacementModifierType { WormPlacement.CODEC } } + val SPLIT by registry.register("split") { PlacementModifierType { SplitPlacement.CODEC} } + val CHAIN by registry.register("chain") { PlacementModifierType { ChainPlacement.CODEC} } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/worldgen/placement/ChainPlacement.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/worldgen/placement/ChainPlacement.kt new file mode 100644 index 000000000..dd854ae73 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/worldgen/placement/ChainPlacement.kt @@ -0,0 +1,35 @@ +package ru.dbotthepony.mc.otm.worldgen.placement + +import com.google.common.collect.ImmutableList +import com.mojang.serialization.Codec +import com.mojang.serialization.MapCodec +import net.minecraft.core.BlockPos +import net.minecraft.util.RandomSource +import net.minecraft.world.level.levelgen.placement.PlacementContext +import net.minecraft.world.level.levelgen.placement.PlacementModifier +import net.minecraft.world.level.levelgen.placement.PlacementModifierType +import ru.dbotthepony.mc.otm.registry.data.MPlacementModifiers +import java.util.stream.Stream + +/** + * Daisy-chaining placements. Required only when using placement modifiers which operate on children list + */ +class ChainPlacement( + val children: List +) : PlacementModifier() { + constructor(vararg children: PlacementModifier) : this(ImmutableList.copyOf(children)) + + override fun getPositions(context: PlacementContext, random: RandomSource, pos: BlockPos): Stream { + var stream = Stream.of(pos) + children.forEach { c -> stream = stream.flatMap { c.getPositions(context, random, it) } } + return stream + } + + override fun type(): PlacementModifierType<*> { + return MPlacementModifiers.CHAIN + } + + companion object { + val CODEC: MapCodec = Codec.list(PlacementModifier.CODEC).xmap(::ChainPlacement, ChainPlacement::children).fieldOf("children") + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/worldgen/placement/SplitPlacement.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/worldgen/placement/SplitPlacement.kt new file mode 100644 index 000000000..6538f8bfa --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/worldgen/placement/SplitPlacement.kt @@ -0,0 +1,35 @@ +package ru.dbotthepony.mc.otm.worldgen.placement + +import com.google.common.collect.ImmutableList +import com.mojang.serialization.Codec +import com.mojang.serialization.MapCodec +import net.minecraft.core.BlockPos +import net.minecraft.util.RandomSource +import net.minecraft.world.level.levelgen.placement.PlacementContext +import net.minecraft.world.level.levelgen.placement.PlacementModifier +import net.minecraft.world.level.levelgen.placement.PlacementModifierType +import ru.dbotthepony.mc.otm.registry.data.MPlacementModifiers +import java.util.stream.Stream + +/** + * Or "shard" placement, if you will. + * + * Basically, allows multiple [PlacementModifier]s to split/branch off from provided point. + */ +class SplitPlacement( + val children: List +) : PlacementModifier() { + constructor(vararg children: PlacementModifier) : this(ImmutableList.copyOf(children)) + + override fun getPositions(context: PlacementContext, random: RandomSource, pos: BlockPos): Stream { + return children.stream().flatMap { it.getPositions(context, random, pos) } + } + + override fun type(): PlacementModifierType<*> { + return MPlacementModifiers.SPLIT + } + + companion object { + val CODEC: MapCodec = Codec.list(PlacementModifier.CODEC).xmap(::SplitPlacement, SplitPlacement::children).fieldOf("children") + } +}