Add passthrough placement modifier, and add argument-less placed feature builder

This commit is contained in:
DBotThePony 2025-03-24 19:30:17 +07:00
parent 1e6e38ea7d
commit e150b57b65
Signed by: DBot
GPG Key ID: DCC23B5715498507
3 changed files with 17 additions and 1 deletions

View File

@ -56,7 +56,9 @@ object MBuiltInRegistries {
}
val FEATURE by Delegate(MRegistries.FEATURE)
val PLACEMENT_MODIFIER by Delegate(MRegistries.PLACEMENT_MODIFIER)
val PLACEMENT_MODIFIER by Delegate(MRegistries.PLACEMENT_MODIFIER) {
defaultKey(ResourceLocation(OverdriveThatMatters.MOD_ID, "passthrough"))
}
internal fun register(bus: IEventBus) {
delegates.forEach { bus.addListener(it::build) }

View File

@ -233,6 +233,8 @@ object EnhancedPlacedFeature : Feature<EnhancedPlacedFeature.Config>(
private val children = ArrayList<Builder>()
private val contents: Either<EnhancedPlacementModifier, Holder<EnhancedFeature.Configured<*, *>>>
constructor() : this(EnhancedPlacementModifier.Passthrough)
constructor(root: EnhancedPlacementModifier) {
this.root = null
this.contents = Either.left(root)

View File

@ -39,11 +39,23 @@ interface EnhancedPlacementModifier {
}
}
object Passthrough : EnhancedPlacementModifier, Type<Passthrough> {
override fun evaluate(context: EnhancedPlacementContext, positions: Set<BlockPos>): Set<BlockPos> {
return positions
}
override val type: Type<*>
get() = this
override val codec: MapCodec<Passthrough> = MapCodec.unit(this)
}
companion object {
private val registrar = MDeferredRegister(MRegistries.PLACEMENT_MODIFIER)
init {
registrar.register("wrapper") { Wrapper.Companion }
registrar.register("passthrough") { Passthrough }
}
val CODEC: Codec<EnhancedPlacementModifier> by lazy {