diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index ba76baaba..ce93d1b65 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -23,6 +23,7 @@ import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.* import ru.dbotthepony.mc.otm.config.EnergyBalanceValues +import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.UpgradeContainer @@ -52,7 +53,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : val pattern: Optional, val asDust: Boolean, ticks: Double, - ) : ItemJob(itemStack, ticks, BASE_CONSUMPTION) { + ) : ItemJob(itemStack, ticks, MachinesConfig.MATTER_REPLICATOR.energyConsumption) { companion object { val CODEC: Codec by lazy { RecordCodecBuilder.create { @@ -71,8 +72,8 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } override val upgrades = UpgradeContainer(this::setChangedLight, 3, UpgradeType.REPLICATOR) - val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::energyLevelUpdated, upgrades.transform(ENERGY_VALUES))) - val matter = ProfiledMatterStorage(MatterStorageImpl(::matterLevelUpdated, FlowDirection.INPUT, upgrades.matterCapacity(::MATTER_CAPACITY))) + val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::energyLevelUpdated, upgrades.transform(MachinesConfig.MATTER_REPLICATOR))) + val matter = ProfiledMatterStorage(MatterStorageImpl(::matterLevelUpdated, FlowDirection.INPUT, upgrades.matterCapacity(MachinesConfig.MATTER_REPLICATOR::matterCapacity))) val container = MatteryContainer(::itemContainerUpdated, 5).also(::addDroppableContainer) val energyConfig = ConfigurableEnergy(energy) @@ -164,7 +165,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } override fun computeNextJob(id: Int): JobContainer { - if (energy.batteryLevel < BASE_CONSUMPTION) { + if (energy.batteryLevel < MachinesConfig.MATTER_REPLICATOR.energyConsumption) { return JobContainer.noEnergy() } @@ -193,7 +194,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : val drainPerTick = job.matterPerTick * status.ticksAdvanced if (matter.extractMatter(drainPerTick, true) < drainPerTick) { - val toDrain = (drainPerTick * DRAIN_MULT) + val toDrain = (drainPerTick * Decimal(200)) .coerceAtMost(job.matterPerTick * (status.ticks - status.workTicks + status.ticksAdvanced)) .coerceAtLeast(Decimal.ONE) .coerceAtMost(matter.missingMatter) @@ -206,29 +207,6 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } companion object { - private val BASE_CONSUMPTION get() = _BASE_CONSUMPTION.get() - private val DRAIN_MULT get() = _DRAIN_MULT.get() - private val MATTER_CAPACITY get() = _MATTER_CAPACITY.get() - - private var _BASE_CONSUMPTION: DecimalConfigValue by WriteOnce() - private var _DRAIN_MULT: DecimalConfigValue by WriteOnce() - private var _MATTER_CAPACITY: DecimalConfigValue by WriteOnce() - - var ENERGY_VALUES: EnergyBalanceValues by WriteOnce() - private set - - fun registerConfig(builder: ForgeConfigSpec.Builder) { - builder.push(MNames.MATTER_REPLICATOR) - - ENERGY_VALUES = BlockEnergyStorageImpl.makeConfigEntry(builder, capacity = Decimal(200_000), throughput = Decimal(4_000)) - - _BASE_CONSUMPTION = builder.defineDecimal("basePowerConsumption", Decimal(400), Decimal.ONE) - _DRAIN_MULT = builder.comment("How much 'ticks' of replication should replicator drain matter from network when running low on internal matter buffer. This is ultimately a performance value.").defineDecimal("drainMultiplier", Decimal(200), Decimal.ONE) - _MATTER_CAPACITY = builder.defineDecimal("matterCapacity", Decimal(1_000), Decimal.ONE_TENTH) - - builder.pop() - } - const val FIRST_ACTUAL_OUTPUT_SLOT = 0 const val LAST_ACTUAL_OUTPUT_SLOT = 2 const val OUTPUT_DUST_MAIN = 3 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/AbstractConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/AbstractConfig.kt index 906314c6c..aee16436d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/AbstractConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/AbstractConfig.kt @@ -49,7 +49,7 @@ abstract class AbstractConfig(private val configName: String, private val type: energyStorage: Decimal, energyThroughput: Decimal, workTimeMultiplier: Double? = 1.0, - powerConsumption: Decimal, + energyConsumption: Decimal, matterCapacity: Decimal? = null, configurator: ForgeConfigSpec.Builder.() -> Unit = {} ): WorkerBalanceValues { @@ -58,7 +58,7 @@ abstract class AbstractConfig(private val configName: String, private val type: val obj = object : WorkerBalanceValues { override val energyCapacity: Decimal by builder.defineDecimal("ENERGY_CAPACITY", energyStorage, minimum = Decimal.ONE) override val energyThroughput: Decimal by builder.defineDecimal("ENERGY_THROUGHPUT", energyThroughput, minimum = Decimal.ONE) - override val energyConsumption: Decimal by builder.defineDecimal("ENERGY_CONSUMPTION", powerConsumption, minimum = Decimal.ONE) + override val energyConsumption: Decimal by builder.defineDecimal("ENERGY_CONSUMPTION", energyConsumption, minimum = Decimal.ONE) override val matterCapacity: Decimal by (if (matterCapacity == null) GetterSetter.box(Decimal.ZERO) else builder.defineDecimal("MATTER_CAPACITY", matterCapacity, minimum = Decimal.ONE)) override val workTimeMultiplier: Double by (if (workTimeMultiplier == null) GetterSetter.box(1.0) else builder.defineInRange("WORK_TIME_MULTIPLIER", workTimeMultiplier, 0.0)) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt index 1cd3ee462..875f885ff 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.config import ru.dbotthepony.mc.otm.block.entity.matter.MatterBottlerBlockEntity -import ru.dbotthepony.mc.otm.block.entity.matter.MatterReplicatorBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.AndroidStationBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.ChemicalGeneratorBlockEntity import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl @@ -14,21 +13,20 @@ object MachinesConfig : AbstractConfig("machines") { AndroidStationBlockEntity.registerConfig(builder) ChemicalGeneratorBlockEntity.registerConfig(builder) MatterBottlerBlockEntity.registerConfig(builder) - MatterReplicatorBlockEntity.registerConfig(builder) } val PLATE_PRESS = workerValues( MNames.PLATE_PRESS, energyStorage = Decimal(40_000), energyThroughput = Decimal(200), - powerConsumption = Decimal(15) + energyConsumption = Decimal(15) ) val MATTER_DECOMPOSER = workerValues( MNames.MATTER_DECOMPOSER, energyStorage = Decimal(100_000), energyThroughput = Decimal(400), - powerConsumption = Decimal(240), + energyConsumption = Decimal(240), matterCapacity = Decimal(400), ) @@ -36,14 +34,22 @@ object MachinesConfig : AbstractConfig("machines") { MNames.MATTER_SCANNER, energyStorage = Decimal(40_000), energyThroughput = Decimal(200), - powerConsumption = Decimal(80), + energyConsumption = Decimal(80), + ) + + val MATTER_REPLICATOR = workerValues( + MNames.MATTER_REPLICATOR, + energyStorage = Decimal(200_000), + energyThroughput = Decimal(4_000), + energyConsumption = Decimal(400), + matterCapacity = Decimal(200) ) private val MATTER_RECYCLER = workerValues( MNames.MATTER_RECYCLER, energyStorage = Decimal(80_000), energyThroughput = Decimal(400), - powerConsumption = Decimal(100), + energyConsumption = Decimal(100), matterCapacity = Decimal(400), workTimeMultiplier = null ) { @@ -59,7 +65,7 @@ object MachinesConfig : AbstractConfig("machines") { MNames.MATTER_RECONSTRUCTOR, energyStorage = Decimal(100_000), energyThroughput = Decimal(1000), - powerConsumption = Decimal(400), + energyConsumption = Decimal(400), matterCapacity = Decimal(200), workTimeMultiplier = null, ) { @@ -116,7 +122,7 @@ object MachinesConfig : AbstractConfig("machines") { "POWERED_FURNACE", energyStorage = Decimal(40_000), energyThroughput = Decimal(200), - powerConsumption = Decimal(20), + energyConsumption = Decimal(20), workTimeMultiplier = 0.75 ) @@ -124,7 +130,7 @@ object MachinesConfig : AbstractConfig("machines") { "POWERED_BLAST_FURNACE", energyStorage = Decimal(40_000), energyThroughput = Decimal(200), - powerConsumption = Decimal(20), + energyConsumption = Decimal(20), workTimeMultiplier = 0.75 ) @@ -132,7 +138,7 @@ object MachinesConfig : AbstractConfig("machines") { "POWERED_SMOKER", energyStorage = Decimal(40_000), energyThroughput = Decimal(200), - powerConsumption = Decimal(10), + energyConsumption = Decimal(10), workTimeMultiplier = 0.75 )