From ee8c641a61a768d991a7f08dff53e8e5ec2a8256 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 25 Jul 2023 20:16:55 +0700 Subject: [PATCH] Matter scanner rebalanced values and added upgrades support --- .../entity/matter/MatterScannerBlockEntity.kt | 37 +++++-------------- .../mc/otm/config/MachinesConfig.kt | 8 +++- 2 files changed, 16 insertions(+), 29 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt index 577220d47..6869bd9e5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt @@ -14,14 +14,18 @@ import ru.dbotthepony.mc.otm.block.entity.ItemJob import ru.dbotthepony.mc.otm.block.entity.MachineJobEventLoop import ru.dbotthepony.mc.otm.config.EnergyBalanceValues import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity +import ru.dbotthepony.mc.otm.capability.IMatteryUpgrade import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.capability.UpgradeType import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.IPatternState import ru.dbotthepony.mc.otm.capability.matter.PatternState +import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.HandlerFilter +import ru.dbotthepony.mc.otm.container.UpgradeContainer import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.math.defineDecimal @@ -37,8 +41,9 @@ import kotlin.math.pow class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryWorkerBlockEntity(MBlockEntities.MATTER_SCANNER, p_155229_, p_155230_, ItemJob.CODEC) { + override val upgrades = UpgradeContainer(this::setChangedLight, 2, UpgradeType.BASIC) val container = MatteryContainer(::itemContainerUpdated, 1).also(::addDroppableContainer) - val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::energyLevelUpdated, ENERGY_VALUES)) + val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::energyLevelUpdated, upgrades.transform(MachinesConfig.MATTER_SCANNER))) val itemConfig = ConfigurableItemHandler(inputOutput = container.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { @@ -149,7 +154,7 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : stack.shrink(1) container.setChanged() val complexity = MatterManager.get(copy).complexity - return JobContainer.success(ItemJob(copy, (if (complexity > 1.0) complexity.pow(1.25) else complexity.pow(0.5)), BASE_CONSUMPTION)) + return JobContainer.success(ItemJob(copy, (if (complexity > 1.0) complexity.pow(1.25) else complexity.pow(0.5)) * MachinesConfig.MATTER_SCANNER.workTimeMultiplier, MachinesConfig.MATTER_SCANNER.powerConsumption)) } return JobContainer.noItem() @@ -172,31 +177,7 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : var visualProgress by synchronizer.float().property private set - override fun onJobTick( - status: JobStatus, - id: Int - ) { - val result = super.onJobTick(status, id) - - visualProgress = jobEventLoops[0].workProgress - - return result - } - - companion object { - private val BASE_CONSUMPTION get() = _BASE_CONSUMPTION.get() - - private var _BASE_CONSUMPTION: DecimalConfigValue by WriteOnce() - var ENERGY_VALUES: EnergyBalanceValues by WriteOnce() - private set - - fun registerConfig(builder: ForgeConfigSpec.Builder) { - builder.push(MNames.MATTER_SCANNER) - - ENERGY_VALUES = BlockEnergyStorageImpl.makeConfigEntry(builder, capacity = Decimal(80_000), throughput = Decimal(400)) - _BASE_CONSUMPTION = builder.defineDecimal("baseConsumption", Decimal(40), Decimal.ONE) - - builder.pop() - } + override fun onJobTick(status: JobStatus, id: Int) { + visualProgress = status.workProgress } } 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 cb9e1c4d7..23b7d6238 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt @@ -20,7 +20,6 @@ object MachinesConfig : AbstractConfig("machines") { ChemicalGeneratorBlockEntity.registerConfig(builder) MatterBottlerBlockEntity.registerConfig(builder) MatterReplicatorBlockEntity.registerConfig(builder) - MatterScannerBlockEntity.registerConfig(builder) MatterReconstructorBlockEntity.registerConfig(builder) } @@ -39,6 +38,13 @@ object MachinesConfig : AbstractConfig("machines") { matterCapacity = Decimal(400), ) + val MATTER_SCANNER = workerValues( + MNames.MATTER_SCANNER, + energyStorage = Decimal(40_000), + energyThroughput = Decimal(200), + powerConsumption = Decimal(80), + ) + var MATTER_RECYCLER_MATTER_PER_TICK: DecimalConfigValue by WriteOnce() private set