Update android station config values

This commit is contained in:
DBotThePony 2023-08-04 14:54:30 +07:00
parent cef79cbe36
commit e169012d01
Signed by: DBot
GPG Key ID: DCC23B5715498507
5 changed files with 37 additions and 46 deletions

View File

@ -16,6 +16,7 @@ import ru.dbotthepony.mc.otm.capability.MatteryCapability
import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage
import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage
import ru.dbotthepony.mc.otm.capability.moveEnergy import ru.dbotthepony.mc.otm.capability.moveEnergy
import ru.dbotthepony.mc.otm.config.MachinesConfig
import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.Decimal
import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue
import ru.dbotthepony.mc.otm.core.math.defineDecimal import ru.dbotthepony.mc.otm.core.math.defineDecimal
@ -25,7 +26,6 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities
import ru.dbotthepony.mc.otm.registry.MNames import ru.dbotthepony.mc.otm.registry.MNames
import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.core.util.WriteOnce
@Suppress("ObjectPropertyName")
class AndroidStationBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : class AndroidStationBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
MatteryPoweredBlockEntity(MBlockEntities.ANDROID_STATION, p_155229_, p_155230_), MenuProvider { MatteryPoweredBlockEntity(MBlockEntities.ANDROID_STATION, p_155229_, p_155230_), MenuProvider {
@ -33,7 +33,7 @@ class AndroidStationBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
return AndroidStationMenu(containerID, inventory, this) return AndroidStationMenu(containerID, inventory, this)
} }
val energy: ProfiledEnergyStorage<WorkerEnergyStorage> = ProfiledEnergyStorage(object : WorkerEnergyStorage(this@AndroidStationBlockEntity::setChangedLight, ::CAPACITY, ::MAX_IO, { null }) { val energy: ProfiledEnergyStorage<WorkerEnergyStorage> = ProfiledEnergyStorage(object : WorkerEnergyStorage(::setChangedLight, MachinesConfig.AndroidStation.VALUES) {
override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal {
return super.extractEnergy(howMuch, simulate).also { return super.extractEnergy(howMuch, simulate).also {
if (!simulate && this.batteryLevel.isZero) { if (!simulate && this.batteryLevel.isZero) {
@ -92,27 +92,4 @@ class AndroidStationBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
} }
} }
} }
companion object {
private var _CAPACITY: DecimalConfigValue by WriteOnce()
private var _MAX_IO: DecimalConfigValue by WriteOnce()
private var _ENERGY_PER_OPERATION: DecimalConfigValue by WriteOnce()
private var _ENERGY_PER_RESEARCH: DecimalConfigValue by WriteOnce()
val CAPACITY get() = _CAPACITY.get()
val MAX_IO get() = _MAX_IO.get()
val ENERGY_PER_OPERATION get() = _ENERGY_PER_OPERATION.get()
val ENERGY_PER_RESEARCH get() = _ENERGY_PER_RESEARCH.get()
fun registerConfig(builder: ForgeConfigSpec.Builder) {
builder.push(MNames.ANDROID_STATION)
_CAPACITY = builder.defineDecimal("capacity", Decimal(100_000), Decimal.ONE)
_MAX_IO = builder.defineDecimal("throughput", Decimal.valueOf(2048), Decimal.ONE)
_ENERGY_PER_OPERATION = builder.comment("Swapping parts, etc").defineDecimal("energyPerOperation", Decimal.valueOf(2048), Decimal.ONE)
_ENERGY_PER_RESEARCH = builder.defineDecimal("energyPerResearch", Decimal.valueOf(16384), Decimal.ONE)
builder.pop()
}
}
} }

View File

@ -32,6 +32,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel
import ru.dbotthepony.mc.otm.client.screen.panels.slot.EquipmentBatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.EquipmentBatterySlotPanel
import ru.dbotthepony.mc.otm.client.screen.panels.util.DraggableCanvasPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.DraggableCanvasPanel
import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel
import ru.dbotthepony.mc.otm.config.MachinesConfig
import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.RGBAColor
import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.ifPresentK
import ru.dbotthepony.mc.otm.menu.tech.AndroidStationMenu import ru.dbotthepony.mc.otm.menu.tech.AndroidStationMenu
@ -384,7 +385,7 @@ private class AndroidResearchButton(
override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean {
if (button == InputConstants.MOUSE_BUTTON_LEFT && minecraft.player?.isSpectator != true) { if (button == InputConstants.MOUSE_BUTTON_LEFT && minecraft.player?.isSpectator != true) {
if (node.canResearch && !node.isResearched && (parent?.screen as AndroidStationScreen).menu.energyWidget.level >= AndroidStationBlockEntity.ENERGY_PER_RESEARCH) { if (node.canResearch && !node.isResearched && (parent?.screen as AndroidStationScreen).menu.energyWidget.level >= MachinesConfig.AndroidStation.ENERGY_PER_RESEARCH) {
if (node.type.flatBlocking.isNotEmpty()) { if (node.type.flatBlocking.isNotEmpty()) {
queryUser( queryUser(
TranslatableComponent("otm.android_station.research.confirm", node.type.displayName), TranslatableComponent("otm.android_station.research.confirm", node.type.displayName),
@ -411,7 +412,7 @@ private class AndroidResearchButton(
if (isHovered) { if (isHovered) {
val list = ArrayList<Component>().also { it.addAll(node.screenTooltipLines) } val list = ArrayList<Component>().also { it.addAll(node.screenTooltipLines) }
val enoughPower = (parent?.screen as AndroidStationScreen).menu.energyWidget.level >= AndroidStationBlockEntity.ENERGY_PER_RESEARCH val enoughPower = (parent?.screen as AndroidStationScreen).menu.energyWidget.level >= MachinesConfig.AndroidStation.ENERGY_PER_RESEARCH
if (node.isResearched) { if (node.isResearched) {
list.add(TranslatableComponent("otm.android_station.research.researched").withStyle(ChatFormatting.DARK_AQUA)) list.add(TranslatableComponent("otm.android_station.research.researched").withStyle(ChatFormatting.DARK_AQUA))
@ -648,10 +649,10 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I
} }
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
if (menu.energyWidget.level >= AndroidStationBlockEntity.ENERGY_PER_RESEARCH) { if (menu.energyWidget.level >= MachinesConfig.AndroidStation.ENERGY_PER_RESEARCH) {
text = POWER_OK text = POWER_OK
color = RGBAColor.LIGHT_GREEN color = RGBAColor.LIGHT_GREEN
} else if (menu.energyWidget.level >= AndroidStationBlockEntity.ENERGY_PER_OPERATION) { } else if (menu.energyWidget.level >= MachinesConfig.AndroidStation.ENERGY_PER_OPERATION) {
text = LOW_POWER_1 text = LOW_POWER_1
color = RGBAColor.DARK_RED color = RGBAColor.DARK_RED
} else { } else {

View File

@ -49,7 +49,7 @@ abstract class AbstractConfig(private val configName: String, private val type:
energyStorage: Decimal, energyStorage: Decimal,
energyThroughput: Decimal, energyThroughput: Decimal,
workTimeMultiplier: Double? = 1.0, workTimeMultiplier: Double? = 1.0,
energyConsumption: Decimal, energyConsumption: Decimal?,
matterCapacity: Decimal? = null, matterCapacity: Decimal? = null,
configurator: ForgeConfigSpec.Builder.() -> Unit = {} configurator: ForgeConfigSpec.Builder.() -> Unit = {}
): WorkerBalanceValues { ): WorkerBalanceValues {
@ -58,7 +58,7 @@ abstract class AbstractConfig(private val configName: String, private val type:
val obj = object : WorkerBalanceValues { val obj = object : WorkerBalanceValues {
override val energyCapacity: Decimal by builder.defineDecimal("ENERGY_CAPACITY", energyStorage, minimum = Decimal.ONE) 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 energyThroughput: Decimal by builder.defineDecimal("ENERGY_THROUGHPUT", energyThroughput, minimum = Decimal.ONE)
override val energyConsumption: Decimal by builder.defineDecimal("ENERGY_CONSUMPTION", energyConsumption, minimum = Decimal.ONE) override val energyConsumption: Decimal by (if (energyConsumption == null) GetterSetter.box(Decimal.ZERO) else 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 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)) override val workTimeMultiplier: Double by (if (workTimeMultiplier == null) GetterSetter.box(1.0) else builder.defineInRange("WORK_TIME_MULTIPLIER", workTimeMultiplier, 0.0))
} }

View File

@ -1,17 +1,11 @@
package ru.dbotthepony.mc.otm.config package ru.dbotthepony.mc.otm.config
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 import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl
import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.Decimal
import ru.dbotthepony.mc.otm.core.math.defineDecimal import ru.dbotthepony.mc.otm.core.math.defineDecimal
import ru.dbotthepony.mc.otm.registry.MNames import ru.dbotthepony.mc.otm.registry.MNames
object MachinesConfig : AbstractConfig("machines") { object MachinesConfig : AbstractConfig("machines") {
init {
AndroidStationBlockEntity.registerConfig(builder)
}
val PLATE_PRESS = workerValues( val PLATE_PRESS = workerValues(
MNames.PLATE_PRESS, MNames.PLATE_PRESS,
energyStorage = Decimal(40_000), energyStorage = Decimal(40_000),
@ -58,7 +52,8 @@ object MachinesConfig : AbstractConfig("machines") {
energyStorage = Decimal(40_000), energyStorage = Decimal(40_000),
energyConsumption = Decimal(10), energyConsumption = Decimal(10),
energyThroughput = Decimal(200), energyThroughput = Decimal(200),
matterCapacity = Decimal(400) matterCapacity = Decimal(400),
workTimeMultiplier = null
) { ) {
MatterBottler MatterBottler
} }
@ -67,7 +62,8 @@ object MachinesConfig : AbstractConfig("machines") {
MNames.CHEMICAL_GENERATOR, MNames.CHEMICAL_GENERATOR,
energyStorage = Decimal(24_000), energyStorage = Decimal(24_000),
energyThroughput = Decimal(160), energyThroughput = Decimal(160),
energyConsumption = Decimal(40) energyConsumption = Decimal(40),
workTimeMultiplier = null
) { ) {
ChemicalGenerator ChemicalGenerator
} }
@ -87,6 +83,22 @@ object MachinesConfig : AbstractConfig("machines") {
val MATTER_PER_TICK by builder.defineDecimal("MATTER_PER_TICK", Decimal("0.5")) val MATTER_PER_TICK by builder.defineDecimal("MATTER_PER_TICK", Decimal("0.5"))
} }
private val ANDROID_STATION = workerValues(
MNames.ANDROID_STATION,
energyStorage = Decimal(40_000),
energyThroughput = Decimal(8_000),
energyConsumption = null,
workTimeMultiplier = null,
) {
AndroidStation
}
object AndroidStation {
val VALUES by ::ANDROID_STATION
val ENERGY_PER_OPERATION by builder.comment("Swapping parts").defineDecimal("ENERGY_PER_OPERATION", Decimal(2_000), Decimal.ZERO)
val ENERGY_PER_RESEARCH by builder.comment("Researching android stuff").defineDecimal("ENERGY_PER_RESEARCH", Decimal(16_000), Decimal.ZERO)
}
private val MATTER_RECONSTRUCTOR = workerValues( private val MATTER_RECONSTRUCTOR = workerValues(
MNames.MATTER_RECONSTRUCTOR, MNames.MATTER_RECONSTRUCTOR,
energyStorage = Decimal(100_000), energyStorage = Decimal(100_000),

View File

@ -10,6 +10,7 @@ import net.minecraftforge.common.capabilities.ForgeCapabilities
import ru.dbotthepony.mc.otm.block.entity.tech.AndroidStationBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.AndroidStationBlockEntity
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability
import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.capability.matteryPlayer
import ru.dbotthepony.mc.otm.config.MachinesConfig
import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu
import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.MatterySlot
import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput
@ -52,10 +53,10 @@ class AndroidStationMenu @JvmOverloads constructor(
} }
override fun removeItem(p_18942_: Int, p_18943_: Int): ItemStack { override fun removeItem(p_18942_: Int, p_18943_: Int): ItemStack {
if (p_18942_ != 0 || energyWidget.level < AndroidStationBlockEntity.ENERGY_PER_OPERATION || item.isEmpty) if (p_18942_ != 0 || energyWidget.level < MachinesConfig.AndroidStation.ENERGY_PER_OPERATION || item.isEmpty)
return ItemStack.EMPTY return ItemStack.EMPTY
(tile as AndroidStationBlockEntity).energy.extractEnergy(AndroidStationBlockEntity.ENERGY_PER_OPERATION, false) (tile as AndroidStationBlockEntity).energy.extractEnergy(MachinesConfig.AndroidStation.ENERGY_PER_OPERATION, false)
return removeItemNoUpdate(p_18942_) return removeItemNoUpdate(p_18942_)
} }
@ -72,7 +73,7 @@ class AndroidStationMenu @JvmOverloads constructor(
if (p_18944_ != 0) if (p_18944_ != 0)
return return
(tile as AndroidStationBlockEntity).energy.extractEnergy(AndroidStationBlockEntity.ENERGY_PER_OPERATION, false) (tile as AndroidStationBlockEntity).energy.extractEnergy(MachinesConfig.AndroidStation.ENERGY_PER_OPERATION, false)
item = p_18945_ item = p_18945_
} }
@ -92,18 +93,18 @@ class AndroidStationMenu @JvmOverloads constructor(
private inner class AndroidSlot(container: Container, private val condition: (ItemStack) -> Boolean) : MatterySlot(container, 0) { private inner class AndroidSlot(container: Container, private val condition: (ItemStack) -> Boolean) : MatterySlot(container, 0) {
override fun mayPickup(player: Player): Boolean { override fun mayPickup(player: Player): Boolean {
if (tile is AndroidStationBlockEntity) { if (tile is AndroidStationBlockEntity) {
return super.mayPickup(player) && tile.energy.batteryLevel >= AndroidStationBlockEntity.ENERGY_PER_OPERATION return super.mayPickup(player) && tile.energy.batteryLevel >= MachinesConfig.AndroidStation.ENERGY_PER_OPERATION
} }
return super.mayPickup(player) && energyWidget.level >= AndroidStationBlockEntity.ENERGY_PER_OPERATION return super.mayPickup(player) && energyWidget.level >= MachinesConfig.AndroidStation.ENERGY_PER_OPERATION
} }
override fun mayPlace(itemStack: ItemStack): Boolean { override fun mayPlace(itemStack: ItemStack): Boolean {
if (tile is AndroidStationBlockEntity) { if (tile is AndroidStationBlockEntity) {
return tile.energy.batteryLevel >= AndroidStationBlockEntity.ENERGY_PER_OPERATION && condition.invoke(itemStack) return tile.energy.batteryLevel >= MachinesConfig.AndroidStation.ENERGY_PER_OPERATION && condition.invoke(itemStack)
} }
return energyWidget.level >= AndroidStationBlockEntity.ENERGY_PER_OPERATION && condition.invoke(itemStack) return energyWidget.level >= MachinesConfig.AndroidStation.ENERGY_PER_OPERATION && condition.invoke(itemStack)
} }
} }