Make matter reconstructor work only with anvil repair items by default
This commit is contained in:
parent
2f770e6e70
commit
917a498e1e
@ -31,7 +31,6 @@ import ru.dbotthepony.mc.otm.core.registryName
|
|||||||
import ru.dbotthepony.mc.otm.core.util.WriteOnce
|
import ru.dbotthepony.mc.otm.core.util.WriteOnce
|
||||||
import ru.dbotthepony.mc.otm.graph.matter.MatterGraph
|
import ru.dbotthepony.mc.otm.graph.matter.MatterGraph
|
||||||
import ru.dbotthepony.mc.otm.graph.matter.MatterNode
|
import ru.dbotthepony.mc.otm.graph.matter.MatterNode
|
||||||
import ru.dbotthepony.mc.otm.graph.matter.SimpleMatterNode
|
|
||||||
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.ItemRepairerMenu
|
import ru.dbotthepony.mc.otm.menu.matter.ItemRepairerMenu
|
||||||
@ -95,7 +94,7 @@ class ItemRepairerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matt
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ONLY_ANVIL) {
|
if (ALLOW_TO_SKIP_ANVIL && !ONLY_ANVIL) {
|
||||||
if (MatterManager.get(stack.item).hasMatterValue) {
|
if (MatterManager.get(stack.item).hasMatterValue) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -149,10 +148,11 @@ class ItemRepairerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matt
|
|||||||
matterPerTick = Decimal.ZERO
|
matterPerTick = Decimal.ZERO
|
||||||
progressPerTick = 0.0
|
progressPerTick = 0.0
|
||||||
} else {
|
} else {
|
||||||
if (!ONLY_ANVIL) {
|
if (ALLOW_TO_SKIP_ANVIL && !ONLY_ANVIL) {
|
||||||
val matter = MatterManager.get(item.item)
|
val matter = MatterManager.get(item.item)
|
||||||
|
|
||||||
if (matter.hasMatterValue) {
|
if (matter.hasMatterValue) {
|
||||||
|
failureChance = FAILURE_CHANCE
|
||||||
progressPerTick = (item.maxDamage / matter.complexity) / DIVISOR
|
progressPerTick = (item.maxDamage / matter.complexity) / DIVISOR
|
||||||
matterPerTick = (matter.matter / matter.complexity) / DIVISOR
|
matterPerTick = (matter.matter / matter.complexity) / DIVISOR
|
||||||
return@once
|
return@once
|
||||||
@ -162,12 +162,23 @@ class ItemRepairerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matt
|
|||||||
val found = matterNode.graph.patterns.filter { item.item.isValidRepairItem(item, ItemStack(it.item, 1)) }.findFirst().orElse(null)
|
val found = matterNode.graph.patterns.filter { item.item.isValidRepairItem(item, ItemStack(it.item, 1)) }.findFirst().orElse(null)
|
||||||
|
|
||||||
if (found != null) {
|
if (found != null) {
|
||||||
|
failureChance = (1.0 - found.researchPercent) + FAILURE_CHANCE
|
||||||
|
|
||||||
|
if (!ONLY_ANVIL) {
|
||||||
|
val matter = MatterManager.get(item.item)
|
||||||
|
|
||||||
|
if (matter.hasMatterValue) {
|
||||||
|
progressPerTick = (item.maxDamage / matter.complexity) / DIVISOR
|
||||||
|
matterPerTick = (matter.matter / matter.complexity) / DIVISOR
|
||||||
|
return@once
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Suppress("name_shadowing")
|
@Suppress("name_shadowing")
|
||||||
val matter = MatterManager.get(found.item) * 2
|
val matter = MatterManager.get(found.item) * 2
|
||||||
|
|
||||||
progressPerTick = (item.maxDamage / matter.complexity) / DIVISOR
|
progressPerTick = (item.maxDamage / matter.complexity) / DIVISOR
|
||||||
matterPerTick = (matter.matter / matter.complexity) / DIVISOR
|
matterPerTick = (matter.matter / matter.complexity) / DIVISOR
|
||||||
failureChance = (1.0 - found.researchPercent) + FAILURE_CHANCE
|
|
||||||
} else {
|
} else {
|
||||||
matterPerTick = Decimal.ZERO
|
matterPerTick = Decimal.ZERO
|
||||||
progressPerTick = 0.0
|
progressPerTick = 0.0
|
||||||
@ -242,6 +253,7 @@ class ItemRepairerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matt
|
|||||||
val EXTRACT_TICKS: Int get() = _EXTRACT_TICKS.get()
|
val EXTRACT_TICKS: Int get() = _EXTRACT_TICKS.get()
|
||||||
val FAILURE_CHANCE: Double get() = _FAILURE_CHANCE.get()
|
val FAILURE_CHANCE: Double get() = _FAILURE_CHANCE.get()
|
||||||
val ONLY_ANVIL: Boolean get() = _ONLY_ANVIL.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 _CAPACITY: DecimalConfigValue by WriteOnce()
|
||||||
private var _ENERGY_CONSUMPTION: DecimalConfigValue by WriteOnce()
|
private var _ENERGY_CONSUMPTION: DecimalConfigValue by WriteOnce()
|
||||||
@ -249,6 +261,7 @@ class ItemRepairerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matt
|
|||||||
private var _FAILURE_CHANCE: ConfigValue<Double> by WriteOnce()
|
private var _FAILURE_CHANCE: ConfigValue<Double> by WriteOnce()
|
||||||
private var _EXTRACT_TICKS: ConfigValue<Int> by WriteOnce()
|
private var _EXTRACT_TICKS: ConfigValue<Int> by WriteOnce()
|
||||||
private var _ONLY_ANVIL: ConfigValue<Boolean> by WriteOnce()
|
private var _ONLY_ANVIL: ConfigValue<Boolean> by WriteOnce()
|
||||||
|
private var _ALLOW_TO_SKIP_ANVIL: ConfigValue<Boolean> by WriteOnce()
|
||||||
|
|
||||||
var ENERGY_VALUES: ConciseBalanceValues by WriteOnce()
|
var ENERGY_VALUES: ConciseBalanceValues by WriteOnce()
|
||||||
private set
|
private set
|
||||||
@ -261,6 +274,11 @@ class ItemRepairerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matt
|
|||||||
_CAPACITY = builder.defineDecimal("matterCapacity", Decimal(800), Decimal.ONE_TENTH)
|
_CAPACITY = builder.defineDecimal("matterCapacity", Decimal(800), Decimal.ONE_TENTH)
|
||||||
_ENERGY_CONSUMPTION = builder.defineDecimal("energyConsumption", Decimal(600), Decimal.ONE)
|
_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
|
_ONLY_ANVIL = 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")
|
||||||
@ -274,7 +292,7 @@ class ItemRepairerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matt
|
|||||||
.defineInRange("extractTicks", 200, 1, Int.MAX_VALUE)
|
.defineInRange("extractTicks", 200, 1, Int.MAX_VALUE)
|
||||||
|
|
||||||
_FAILURE_CHANCE = builder
|
_FAILURE_CHANCE = builder
|
||||||
.comment("Chance 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, wasting resources")
|
.comment("In event of failure repair tick is wasted, wasting resources")
|
||||||
.defineInRange("failureChance", 0.01, 0.0, 0.99)
|
.defineInRange("failureChance", 0.01, 0.0, 0.99)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user