From 13c9e93d312d42a68b65aa47d7910cefb4b6f307 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 24 Feb 2025 15:15:25 +0700 Subject: [PATCH 1/4] Move black hole spawn chance to placedfeature --- src/data/kotlin/ru/dbotthepony/mc/otm/datagen/WorldGen.kt | 3 ++- .../dbotthepony/mc/otm/worldgen/feature/BlackHolePlacer.kt | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) 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 f40c0c6c9..ad8c630ef 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/WorldGen.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/WorldGen.kt @@ -65,7 +65,7 @@ fun registerConfiguredFeatures(context: BootstrapContext context.register(ConfiguredFeatures.BLACK_HOLE, ConfiguredFeature( MWorldGenFeatures.BLACK_HOLE_PLACER, - BlackHolePlacerFeature.Config(0.001f, Decimal("0.25"), Decimal(1)))) + BlackHolePlacerFeature.Config(Decimal("0.25"), Decimal(1)))) } private object PlacedFeatures { @@ -152,6 +152,7 @@ fun registerPlacedFeatures(context: BootstrapContext) { context.register(PlacedFeatures.BLACK_HOLE, PlacedFeature( blackHole, listOf( + RarityFilter.onAverageOnceEvery(1000), InSquarePlacement.spread(), HeightRangePlacement.uniform(VerticalAnchor.absolute(64), VerticalAnchor.absolute(128)) ) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/worldgen/feature/BlackHolePlacer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/worldgen/feature/BlackHolePlacer.kt index 4c0056db6..102d3eccf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/worldgen/feature/BlackHolePlacer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/worldgen/feature/BlackHolePlacer.kt @@ -15,13 +15,12 @@ import ru.dbotthepony.mc.otm.registry.game.MBlocks object BlackHolePlacerFeature : Feature( RecordCodecBuilder.create { it.group( - Codec.floatRange(0.0F, 1.0F).fieldOf("chance").forGetter(Config::chance), DecimalCodec.fieldOf("matter_min").forGetter(Config::minMatter), DecimalCodec.fieldOf("matter_max").forGetter(Config::maxMatter) ).apply(it, ::Config) } ) { - data class Config(val chance: Float, val minMatter: Decimal, val maxMatter: Decimal) : FeatureConfiguration + data class Config(val minMatter: Decimal, val maxMatter: Decimal) : FeatureConfiguration override fun place(context: FeaturePlaceContext): Boolean { val random = context.random() @@ -30,7 +29,7 @@ object BlackHolePlacerFeature : Feature( val config = context.config() - if (level.getBlockState(pos).isAir && random.nextDouble() < config.chance.toDouble()) { + if (level.getBlockState(pos).isAir) { if (level.setBlock(pos, MBlocks.BLACK_HOLE.defaultBlockState(), 2)) { val entity = level.getBlockEntity(pos) From 96d902bc98240cc47e1e8304c58828bfadc9be0c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 24 Feb 2025 16:29:11 +0700 Subject: [PATCH 2/4] Type specific setChanged override in MatterySlot --- src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt index 640b6156a..c5482b474 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt @@ -51,6 +51,14 @@ inline fun makeSlots(containers: List?, size: Int, initial open class MatterySlot(container: Container, index: Int, x: Int = 0, y: Int = 0) : Slot(container, index, x, y) { var ignoreSpectators = true + override fun setChanged() { + if (container is IMatteryContainer) { + (container as IMatteryContainer).setChanged(index) + } else { + super.setChanged() + } + } + override fun mayPickup(player: Player): Boolean { return super.mayPickup(player) && (!ignoreSpectators || !player.isSpectator) } From d0ee1fb0e37e4307b21191a8ac9a239305b84cd7 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 24 Feb 2025 16:37:39 +0700 Subject: [PATCH 3/4] Properly delegate setChanged in combined container slot --- .../ru/dbotthepony/mc/otm/container/CombinedContainer.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/CombinedContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/CombinedContainer.kt index a7094db4a..946136c0c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/CombinedContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/CombinedContainer.kt @@ -34,6 +34,10 @@ class CombinedContainer(containers: Stream>>) : IM override val container: Container get() = this@CombinedContainer + override fun setChanged() { + outer.setChanged() + } + override fun component1(): Int { return super.component1() } From d4636038cc96a1e92bbd1b964144fb13f713a4cf Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 24 Feb 2025 18:08:02 +0700 Subject: [PATCH 4/4] :skull_rotate: --- src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt index c5482b474..bf6ee95a6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt @@ -53,7 +53,7 @@ open class MatterySlot(container: Container, index: Int, x: Int = 0, y: Int = 0) override fun setChanged() { if (container is IMatteryContainer) { - (container as IMatteryContainer).setChanged(index) + (container as IMatteryContainer).setChanged(containerSlot) } else { super.setChanged() }