Matter reconstructor rebalanced values

This commit is contained in:
DBotThePony 2023-07-27 20:49:01 +07:00
parent 8567e75b6f
commit 7bc58bb7ff
Signed by: DBot
GPG Key ID: DCC23B5715498507
2 changed files with 55 additions and 79 deletions

View File

@ -25,6 +25,7 @@ import ru.dbotthepony.mc.otm.capability.matter.PatternState
import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl
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.container.HandlerFilter
import ru.dbotthepony.mc.otm.container.MatteryContainer
import ru.dbotthepony.mc.otm.container.UpgradeContainer
@ -60,8 +61,8 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState)
private set
val upgrades = UpgradeContainer(this::setChangedLight, 3, UpgradeType.REPLICATOR)
val matter = ProfiledMatterStorage(MatterStorageImpl(::setChangedLight, FlowDirection.INPUT, upgrades.matterCapacity(::CAPACITY)))
val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::setChangedLight, upgrades.transform(ENERGY_VALUES)))
val matter = ProfiledMatterStorage(MatterStorageImpl(::setChangedLight, FlowDirection.INPUT, upgrades.matterCapacity(MachinesConfig.MatterReconstructor.VALUES::matterCapacity)))
val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::setChangedLight, upgrades.transform(MachinesConfig.MatterReconstructor.VALUES)))
val matterNode = object : MatterNode() {
override fun getMatterHandler(): IMatterStorage {
@ -107,7 +108,7 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState)
return false
}
if (ALLOW_TO_SKIP_ANVIL && !ONLY_ANVIL) {
if (MachinesConfig.MatterReconstructor.ALLOW_TO_SKIP_ANVIL && !MachinesConfig.MatterReconstructor.ONLY_ANVIL) {
if (MatterManager.get(stack.item).hasMatterValue) {
return true
}
@ -172,13 +173,13 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState)
visualItemStack = item
visualProgress = 0f
} else {
if (ALLOW_TO_SKIP_ANVIL && !ONLY_ANVIL) {
if (MachinesConfig.MatterReconstructor.ALLOW_TO_SKIP_ANVIL && !MachinesConfig.MatterReconstructor.ONLY_ANVIL) {
val matter = MatterManager.get(item.item)
if (matter.hasMatterValue) {
failureChance = FAILURE_CHANCE
progressPerTick = (item.maxDamage / matter.complexity) / DIVISOR
matterPerTick = (matter.matter / matter.complexity) / DIVISOR
failureChance = MachinesConfig.MatterReconstructor.FAILURE_CHANCE
progressPerTick = (item.maxDamage / matter.complexity) / MachinesConfig.MatterReconstructor.DIVISOR
matterPerTick = (matter.matter / matter.complexity) / MachinesConfig.MatterReconstructor.DIVISOR
return@once
}
}
@ -186,14 +187,14 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState)
val found = matterNode.graph.patterns.filter { item.item.isValidRepairItem(item, ItemStack(it.item, 1)) }.findFirst().orElse(null)
if (found != null) {
failureChance = (1.0 - found.researchPercent) + FAILURE_CHANCE
failureChance = (1.0 - found.researchPercent) + MachinesConfig.MatterReconstructor.FAILURE_CHANCE
if (!ONLY_ANVIL) {
if (!MachinesConfig.MatterReconstructor.ONLY_ANVIL) {
val matter = MatterManager.get(item.item)
if (matter.hasMatterValue) {
progressPerTick = (item.maxDamage / matter.complexity) / DIVISOR
matterPerTick = (matter.matter / matter.complexity) / DIVISOR
progressPerTick = (item.maxDamage / matter.complexity) / MachinesConfig.MatterReconstructor.DIVISOR
matterPerTick = (matter.matter / matter.complexity) / MachinesConfig.MatterReconstructor.DIVISOR
return@once
}
}
@ -201,8 +202,8 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState)
@Suppress("name_shadowing")
val matter = MatterManager.get(found.item) * 2
progressPerTick = (item.maxDamage / matter.complexity) / DIVISOR
matterPerTick = (matter.matter / matter.complexity) / DIVISOR
progressPerTick = (item.maxDamage / matter.complexity) / MachinesConfig.MatterReconstructor.DIVISOR
matterPerTick = (matter.matter / matter.complexity) / MachinesConfig.MatterReconstructor.DIVISOR
} else {
matterPerTick = Decimal.ZERO
progressPerTick = 0.0
@ -224,7 +225,7 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState)
val thisProgressPerTick = progressPerTick * (1.0 + upgrades.speedBonus)
val matterPerTick = matterPerTick * (1.0 + upgrades.speedBonus)
val energyConsumption = ENERGY_CONSUMPTION * (1.0 + upgrades.speedBonus) * (upgrades.energyConsumed + Decimal.ONE)
val energyConsumption = MachinesConfig.MatterReconstructor.VALUES.powerConsumption * (1.0 + upgrades.speedBonus) * (upgrades.energyConsumed + Decimal.ONE)
if (!item.isEmpty && matterPerTick.isPositive && thisProgressPerTick > 0.0 && item.isRepairable && item.isDamaged) {
var progressPerTick = (repairProgress + thisProgressPerTick).coerceAtMost(item.damageValue.toDouble()) - repairProgress
@ -242,7 +243,7 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState)
}
if (matter.storedMatter < matterPerTick) {
val toDrain = (matterPerTick * EXTRACT_TICKS
val toDrain = (matterPerTick * 200
.coerceAtMost(item.damageValue) - matter.storedMatter)
.coerceAtLeast(Decimal.ZERO)
.coerceAtMost(matter.missingMatter)
@ -289,67 +290,4 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState)
}
}
}
companion object {
val CAPACITY get() = _CAPACITY.get()
val ENERGY_CONSUMPTION get() = _ENERGY_CONSUMPTION.get()
val DIVISOR: Double get() = _DIVISOR.get()
val EXTRACT_TICKS: Int get() = _EXTRACT_TICKS.get()
val FAILURE_CHANCE: Double get() = _FAILURE_CHANCE.get()
val ONLY_ANVIL: Boolean get() = _ONLY_ANVIL.get()
val ALLOW_TO_SKIP_ANVIL: Boolean get() = _ALLOW_TO_SKIP_ANVIL.get()
private var _CAPACITY: DecimalConfigValue by WriteOnce()
private var _ENERGY_CONSUMPTION: DecimalConfigValue by WriteOnce()
private var _DIVISOR: ConfigValue<Double> by WriteOnce()
private var _FAILURE_CHANCE: ConfigValue<Double> by WriteOnce()
private var _EXTRACT_TICKS: ConfigValue<Int> by WriteOnce()
private var _ONLY_ANVIL: ConfigValue<Boolean> by WriteOnce()
private var _ALLOW_TO_SKIP_ANVIL: ConfigValue<Boolean> by WriteOnce()
var ENERGY_VALUES: EnergyBalanceValues by WriteOnce()
private set
fun registerConfig(builder: ForgeConfigSpec.Builder) {
builder.push(MNames.MATTER_RECONSTRUCTOR)
ENERGY_VALUES = BlockEnergyStorageImpl.makeConfigEntry(builder, capacity = Decimal(400_000), throughput = Decimal(2_000))
_CAPACITY = builder.defineDecimal("matterCapacity", Decimal(800), Decimal.ONE_TENTH)
_ENERGY_CONSUMPTION = builder.defineDecimal("energyConsumption", Decimal(600), Decimal.ONE)
_ALLOW_TO_SKIP_ANVIL = builder
.comment("Allow to repair tools without having their anvil-repair items researched")
.comment("Ignored if onlyAnvil is true")
.define("allowToSkipAnvil", false)
_ONLY_ANVIL = builder
.comment("Force repairing only by matter value of anvil materials")
.comment("Doesn't make logical sense but might be good for balancing")
.define("onlyAnvil", false)
_EXTRACT_TICKS = builder
.comment("How much ticks of matter work will be attempted to be extracted from matter network")
.comment("on matter starvation")
.comment("---")
.comment("This is a performance tuning value, do not change it if you don't know what you are doing!")
.defineInRange("extractTicks", 200, 1, Int.MAX_VALUE)
_FAILURE_CHANCE = builder
.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, wasting resources")
.defineInRange("failureChance", 0.01, 0.0, 0.99)
_DIVISOR = builder
.comment("Magnitute of **slowdown** of repairer.")
.comment("If this value is 1, repairer will repair item from 0% to 100% in COMPLEXITY (of tool) ticks")
.comment("(or twice the complexity of anvil repair ingredients if tool itself has no matter value)")
.comment("---")
.comment("If value is smaller than 1, repairer will repair items faster")
.comment("If value is bigger than 1, repairer will repair items slower")
.defineInRange("divisor", 3.0, 0.1, Double.MAX_VALUE)
builder.pop()
}
}
}

View File

@ -20,7 +20,6 @@ object MachinesConfig : AbstractConfig("machines") {
ChemicalGeneratorBlockEntity.registerConfig(builder)
MatterBottlerBlockEntity.registerConfig(builder)
MatterReplicatorBlockEntity.registerConfig(builder)
MatterReconstructorBlockEntity.registerConfig(builder)
}
val PLATE_PRESS = workerValues(
@ -62,6 +61,45 @@ object MachinesConfig : AbstractConfig("machines") {
MATTER_RECYCLER_CAPACITY = defineDecimal("MATTER_CAPACITY", Decimal(400), Decimal.ONE)
}
private val MATTER_RECONSTRUCTOR = workerValues(
MNames.MATTER_RECONSTRUCTOR,
energyStorage = Decimal(100_000),
energyThroughput = Decimal(1000),
powerConsumption = Decimal(400),
matterCapacity = Decimal(200),
workTimeMultiplier = null,
) {
MatterReconstructor
}
object MatterReconstructor {
val VALUES by ::MATTER_RECONSTRUCTOR
val ALLOW_TO_SKIP_ANVIL: Boolean by builder
.comment("Allow to repair tools without having their anvil-repair items researched")
.comment("Ignored if onlyAnvil is true")
.define("allowToSkipAnvil", false)
val ONLY_ANVIL: Boolean by builder
.comment("Force repairing only by matter value of anvil materials")
.comment("Doesn't make logical sense but might be good for balancing")
.define("onlyAnvil", false)
val FAILURE_CHANCE: Double by builder
.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")
.defineInRange("failureChance", 0.01, 0.0, 0.99)
val DIVISOR: Double by builder
.comment("Magnitute of **slowdown** of repairer.")
.comment("If this value is 1, repairer will repair item from 0% to 100% in COMPLEXITY (of tool) ticks")
.comment("(or twice the complexity of anvil repair ingredients if tool itself has no matter value)")
.comment("---")
.comment("If value is smaller than 1, repairer will repair items faster")
.comment("If value is bigger than 1, repairer will repair items slower")
.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_INTERFACES = BlockEnergyStorageImpl.makeConfigEntry(builder, "STORAGE_INTERFACES", capacity = Decimal(10_000))
val ITEM_MONITOR = BlockEnergyStorageImpl.makeConfigEntry(builder, MNames.ITEM_MONITOR)