More consistent config names

This commit is contained in:
DBotThePony 2023-07-27 20:53:36 +07:00
parent 43d14486b7
commit d7332f4720
Signed by: DBot
GPG Key ID: DCC23B5715498507
9 changed files with 22 additions and 30 deletions

View File

@ -40,7 +40,7 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState)
val toDust: Boolean, val toDust: Boolean,
var matterValue: Decimal, var matterValue: Decimal,
ticks: Double, ticks: Double,
) : Job(ticks, MachinesConfig.MATTER_DECOMPOSER.powerConsumption) { ) : Job(ticks, MachinesConfig.MATTER_DECOMPOSER.energyConsumption) {
companion object { companion object {
val CODEC: Codec<DecomposerJob> by lazy { val CODEC: Codec<DecomposerJob> by lazy {
RecordCodecBuilder.create { RecordCodecBuilder.create {

View File

@ -10,36 +10,28 @@ import net.minecraft.world.item.Item
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
import net.minecraft.world.level.Level import net.minecraft.world.level.Level
import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.BlockState
import net.minecraftforge.common.ForgeConfigSpec
import net.minecraftforge.common.ForgeConfigSpec.ConfigValue
import net.minecraftforge.registries.ForgeRegistries import net.minecraftforge.registries.ForgeRegistries
import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity
import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.FlowDirection
import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.MatteryCapability
import ru.dbotthepony.mc.otm.capability.UpgradeType import ru.dbotthepony.mc.otm.capability.UpgradeType
import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl
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.matter.IMatterStorage import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage
import ru.dbotthepony.mc.otm.capability.matter.PatternState import ru.dbotthepony.mc.otm.capability.matter.PatternState
import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl
import ru.dbotthepony.mc.otm.capability.matter.ProfiledMatterStorage import ru.dbotthepony.mc.otm.capability.matter.ProfiledMatterStorage
import ru.dbotthepony.mc.otm.config.EnergyBalanceValues
import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.config.MachinesConfig
import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.container.HandlerFilter
import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.MatteryContainer
import ru.dbotthepony.mc.otm.container.UpgradeContainer import ru.dbotthepony.mc.otm.container.UpgradeContainer
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.defineDecimal
import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.core.registryName
import ru.dbotthepony.mc.otm.core.util.WriteOnce
import ru.dbotthepony.mc.otm.graph.matter.MatterNode import ru.dbotthepony.mc.otm.graph.matter.MatterNode
import ru.dbotthepony.mc.otm.matter.IMatterValue import ru.dbotthepony.mc.otm.matter.IMatterValue
import ru.dbotthepony.mc.otm.matter.MatterManager import ru.dbotthepony.mc.otm.matter.MatterManager
import ru.dbotthepony.mc.otm.menu.matter.MatterReconstructorMenu import ru.dbotthepony.mc.otm.menu.matter.MatterReconstructorMenu
import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MBlockEntities
import ru.dbotthepony.mc.otm.registry.MNames
class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.MATTER_RECONSTRUCTOR, blockPos, blockState) { class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.MATTER_RECONSTRUCTOR, blockPos, blockState) {
val repairContainer = MatteryContainer(::containerChanged, 1).also(::addDroppableContainer) val repairContainer = MatteryContainer(::containerChanged, 1).also(::addDroppableContainer)
@ -225,7 +217,7 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState)
val thisProgressPerTick = progressPerTick * (1.0 + upgrades.speedBonus) val thisProgressPerTick = progressPerTick * (1.0 + upgrades.speedBonus)
val matterPerTick = matterPerTick * (1.0 + upgrades.speedBonus) val matterPerTick = matterPerTick * (1.0 + upgrades.speedBonus)
val energyConsumption = MachinesConfig.MatterReconstructor.VALUES.powerConsumption * (1.0 + upgrades.speedBonus) * (upgrades.energyConsumed + Decimal.ONE) val energyConsumption = MachinesConfig.MatterReconstructor.VALUES.energyConsumption * (1.0 + upgrades.speedBonus) * (upgrades.energyConsumed + Decimal.ONE)
if (!item.isEmpty && matterPerTick.isPositive && thisProgressPerTick > 0.0 && item.isRepairable && item.isDamaged) { if (!item.isEmpty && matterPerTick.isPositive && thisProgressPerTick > 0.0 && item.isRepairable && item.isDamaged) {
var progressPerTick = (repairProgress + thisProgressPerTick).coerceAtMost(item.damageValue.toDouble()) - repairProgress var progressPerTick = (repairProgress + thisProgressPerTick).coerceAtMost(item.damageValue.toDouble()) - repairProgress

View File

@ -118,7 +118,7 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState)
return JobContainer.success( return JobContainer.success(
RecyclerJob( RecyclerJob(
(actualMatter / MachinesConfig.MatterRecycler.MATTER_PER_TICK).toDouble(), (actualMatter / MachinesConfig.MatterRecycler.MATTER_PER_TICK).toDouble(),
MachinesConfig.MatterRecycler.VALUES.powerConsumption, MachinesConfig.MatterRecycler.VALUES.energyConsumption,
actualMatter actualMatter
) )
) )

View File

@ -144,7 +144,7 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
stack.shrink(1) stack.shrink(1)
container.setChanged() container.setChanged()
val complexity = MatterManager.get(copy).complexity val complexity = MatterManager.get(copy).complexity
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.success(ItemJob(copy, (if (complexity > 1.0) complexity.pow(1.25) else complexity.pow(0.5)) * MachinesConfig.MATTER_SCANNER.workTimeMultiplier, MachinesConfig.MATTER_SCANNER.energyConsumption))
} }
return JobContainer.noItem() return JobContainer.noItem()

View File

@ -102,7 +102,7 @@ class PlatePressBlockEntity(
ItemJob( ItemJob(
recipe.getResultItem(level.registryAccess()).copyWithCount(toProcess), recipe.getResultItem(level.registryAccess()).copyWithCount(toProcess),
recipe.workTime * MachinesConfig.PLATE_PRESS.workTimeMultiplier, recipe.workTime * MachinesConfig.PLATE_PRESS.workTimeMultiplier,
MachinesConfig.PLATE_PRESS.powerConsumption * toProcess, MachinesConfig.PLATE_PRESS.energyConsumption * toProcess,
experience = recipe.experience.sample(level.random) * toProcess)) experience = recipe.experience.sample(level.random) * toProcess))
} }

View File

@ -107,7 +107,7 @@ class PoweredFurnaceBlockEntity(
inputs[id][0].shrink(toProcess) inputs[id][0].shrink(toProcess)
JobContainer.success(ItemJob( JobContainer.success(ItemJob(
output.copyWithCount(toProcess), it.cookingTime * config.workTimeMultiplier, config.powerConsumption * toProcess, it.experience * toProcess output.copyWithCount(toProcess), it.cookingTime * config.workTimeMultiplier, config.energyConsumption * toProcess, it.experience * toProcess
)) ))
}.orElse(JobContainer.noItem()) }.orElse(JobContainer.noItem())
} }

View File

@ -19,10 +19,10 @@ abstract class AbstractConfig(private val configName: String, private val type:
builder.push(name) builder.push(name)
val obj = object : BatteryBalanceValues { val obj = object : BatteryBalanceValues {
override val energyCapacity: Decimal by builder.defineDecimal("capacity", storage, minimum = Decimal.ONE) override val energyCapacity: Decimal by builder.defineDecimal("ENERGY_CAPACITY", storage, minimum = Decimal.ONE)
override val maxEnergyReceive: Decimal by builder.defineDecimal("receive", receive, minimum = Decimal.ONE) override val maxEnergyReceive: Decimal by builder.defineDecimal("MAX_RECEIVE", receive, minimum = Decimal.ONE)
override val maxEnergyExtract: Decimal by builder.defineDecimal("extract", extract, minimum = Decimal.ONE) override val maxEnergyExtract: Decimal by builder.defineDecimal("MAX_EXTRACT", extract, minimum = Decimal.ONE)
override val initialBatteryLevel: Decimal by builder.defineDecimal("initialBatteryLevel", initialBatteryLevel, minimum = Decimal.ZERO) override val initialBatteryLevel: Decimal by builder.defineDecimal("INITIAL_BATTERY_LEVEL", initialBatteryLevel, minimum = Decimal.ZERO)
} }
builder.pop() builder.pop()
@ -34,8 +34,8 @@ abstract class AbstractConfig(private val configName: String, private val type:
builder.push(name) builder.push(name)
val obj = object : EnergyBalanceValues { val obj = object : EnergyBalanceValues {
override val energyCapacity: Decimal by builder.defineDecimal("capacity", storage, minimum = Decimal.ONE) override val energyCapacity: Decimal by builder.defineDecimal("ENERGY_CAPACITY", storage, minimum = Decimal.ONE)
override val energyThroughput: Decimal by builder.defineDecimal("throughput", throughput, minimum = Decimal.ONE) override val energyThroughput: Decimal by builder.defineDecimal("ENERGY_THROUGHPUT", throughput, minimum = Decimal.ONE)
} }
configurator.invoke(builder) configurator.invoke(builder)
@ -56,11 +56,11 @@ abstract class AbstractConfig(private val configName: String, private val type:
builder.push(name) builder.push(name)
val obj = object : WorkerBalanceValues { val obj = object : WorkerBalanceValues {
override val energyCapacity: Decimal by builder.defineDecimal("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("throughput", energyThroughput, minimum = Decimal.ONE) override val energyThroughput: Decimal by builder.defineDecimal("ENERGY_THROUGHPUT", energyThroughput, minimum = Decimal.ONE)
override val powerConsumption: Decimal by builder.defineDecimal("powerConsumption", powerConsumption, minimum = Decimal.ONE) override val energyConsumption: Decimal by builder.defineDecimal("ENERGY_CONSUMPTION", powerConsumption, minimum = Decimal.ONE)
override val matterCapacity: Decimal by (if (matterCapacity == null) GetterSetter.box(Decimal.ZERO) else builder.defineDecimal("matterCapacity", 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("workTimeMultiplier", workTimeMultiplier, 0.0)) override val workTimeMultiplier: Double by (if (workTimeMultiplier == null) GetterSetter.box(1.0) else builder.defineInRange("WORK_TIME_MULTIPLIER", workTimeMultiplier, 0.0))
} }
configurator.invoke(builder) configurator.invoke(builder)

View File

@ -9,7 +9,7 @@ interface EnergyBalanceValues {
interface WorkerBalanceValues : EnergyBalanceValues { interface WorkerBalanceValues : EnergyBalanceValues {
val workTimeMultiplier: Double val workTimeMultiplier: Double
val powerConsumption: Decimal val energyConsumption: Decimal
val matterCapacity: Decimal val matterCapacity: Decimal
} }

View File

@ -72,17 +72,17 @@ object MachinesConfig : AbstractConfig("machines") {
val ALLOW_TO_SKIP_ANVIL: Boolean by builder val ALLOW_TO_SKIP_ANVIL: Boolean by builder
.comment("Allow to repair tools without having their anvil-repair items researched") .comment("Allow to repair tools without having their anvil-repair items researched")
.comment("Ignored if onlyAnvil is true") .comment("Ignored if onlyAnvil is true")
.define("allowToSkipAnvil", false) .define("ALLOW_TO_SKIP_ANVIL", false)
val ONLY_ANVIL: Boolean by builder val ONLY_ANVIL: Boolean by builder
.comment("Force repairing only by matter value of anvil materials") .comment("Force repairing only by matter value of anvil materials")
.comment("Doesn't make logical sense but might be good for balancing") .comment("Doesn't make logical sense but might be good for balancing")
.define("onlyAnvil", false) .define("ONLY_ANVIL", false)
val FAILURE_CHANCE: Double by builder val FAILURE_CHANCE: Double by builder
.comment("Constant additional chance (over pattern research factor) that replication will fail at any given tick") .comment("Constant additional chance (over pattern research factor) that replication will fail at any given tick")
.comment("In event of failure repair tick is wasted, as well as resources") .comment("In event of failure repair tick is wasted, as well as resources")
.defineInRange("failureChance", 0.01, 0.0, 0.99) .defineInRange("FAILURE_CHANCE", 0.01, 0.0, 0.99)
val DIVISOR: Double by builder val DIVISOR: Double by builder
.comment("Magnitute of **slowdown** of repairer.") .comment("Magnitute of **slowdown** of repairer.")
@ -91,7 +91,7 @@ object MachinesConfig : AbstractConfig("machines") {
.comment("---") .comment("---")
.comment("If value is smaller than 1, repairer will repair items faster") .comment("If value is smaller than 1, repairer will repair items faster")
.comment("If value is bigger than 1, repairer will repair items slower") .comment("If value is bigger than 1, repairer will repair items slower")
.defineInRange("divisor", 3.0, 0.1, Double.MAX_VALUE) .defineInRange("DIVISOR", 3.0, 0.1, Double.MAX_VALUE)
} }
val STORAGE_POWER_SUPPLIER = BlockEnergyStorageImpl.makeConfigEntry(builder, MNames.STORAGE_POWER_SUPPLIER, capacity = Decimal(100_000), throughput = Decimal(320)) val STORAGE_POWER_SUPPLIER = BlockEnergyStorageImpl.makeConfigEntry(builder, MNames.STORAGE_POWER_SUPPLIER, capacity = Decimal(100_000), throughput = Decimal(320))