Some corrections and additions of defined but defunct logic
This commit is contained in:
parent
a14a702f39
commit
778dd400f6
@ -45,9 +45,9 @@ object RecipeResolverManager : SimpleJsonResourceReloadListener(GsonBuilder().se
|
|||||||
*/
|
*/
|
||||||
data class ImmutableStack(
|
data class ImmutableStack(
|
||||||
val item: Item,
|
val item: Item,
|
||||||
val count: Long = 1L
|
val multiplier: Double = 1.0
|
||||||
) {
|
) {
|
||||||
constructor(item: Item, count: Int) : this(item, count.toLong())
|
constructor(item: Item, count: Int) : this(item, 1.0 / count.toDouble())
|
||||||
constructor(item: ItemStack) : this(item.item, item.count)
|
constructor(item: ItemStack) : this(item.item, item.count)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ object RecipeResolverManager : SimpleJsonResourceReloadListener(GsonBuilder().se
|
|||||||
val isCritical: Boolean = true,
|
val isCritical: Boolean = true,
|
||||||
) {
|
) {
|
||||||
val inputs: List<List<ImmutableStack>> = inputs
|
val inputs: List<List<ImmutableStack>> = inputs
|
||||||
.map { it.filter { it.count > 0L }.collect(ImmutableList.toImmutableList()) }
|
.map { it.filter { it.multiplier > 0.0 }.collect(ImmutableList.toImmutableList()) }
|
||||||
.filter { it.isNotEmpty() }
|
.filter { it.isNotEmpty() }
|
||||||
.collect(ImmutableList.toImmutableList())
|
.collect(ImmutableList.toImmutableList())
|
||||||
|
|
||||||
@ -223,16 +223,16 @@ object RecipeResolverManager : SimpleJsonResourceReloadListener(GsonBuilder().se
|
|||||||
private data class Result(val type: Type, val value: MatterManager.IMatterValue? = null) {
|
private data class Result(val type: Type, val value: MatterManager.IMatterValue? = null) {
|
||||||
constructor(value: MatterManager.IMatterValue) : this(Type.RESOLVED, value)
|
constructor(value: MatterManager.IMatterValue) : this(Type.RESOLVED, value)
|
||||||
|
|
||||||
val isRecursion get() = type === Type.RECURSION
|
val isSkipped get() = type === Type.SKIPPED
|
||||||
val isMissing get() = type === Type.MISSING
|
val isMissing get() = type === Type.MISSING
|
||||||
|
|
||||||
enum class Type {
|
enum class Type {
|
||||||
RESOLVED, RECURSION, MISSING
|
RESOLVED, SKIPPED, MISSING
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
// recursive recipes should be ignored until we resolve everything else
|
// recursive recipes should be ignored until we resolve everything else
|
||||||
val RECURSION = Result(Type.RECURSION)
|
val RECURSION = Result(Type.SKIPPED)
|
||||||
|
|
||||||
// missing matter values are fatal, whole recipe chain is then considered defunct
|
// missing matter values are fatal, whole recipe chain is then considered defunct
|
||||||
val MISSING = Result(Type.MISSING)
|
val MISSING = Result(Type.MISSING)
|
||||||
@ -245,7 +245,7 @@ object RecipeResolverManager : SimpleJsonResourceReloadListener(GsonBuilder().se
|
|||||||
private fun doDetermineValue(item: Item): Result {
|
private fun doDetermineValue(item: Item): Result {
|
||||||
var minimalMatter: ImpreciseFraction? = null
|
var minimalMatter: ImpreciseFraction? = null
|
||||||
var minimalComplexity: Double? = null
|
var minimalComplexity: Double? = null
|
||||||
var hadRecursion = false
|
var hadSkips = false
|
||||||
|
|
||||||
recipesLoop@ for (recipe in output2Recipes[item] ?: return Result.MISSING) {
|
recipesLoop@ for (recipe in output2Recipes[item] ?: return Result.MISSING) {
|
||||||
if (recipe.inputs.isEmpty()) {
|
if (recipe.inputs.isEmpty()) {
|
||||||
@ -258,7 +258,7 @@ object RecipeResolverManager : SimpleJsonResourceReloadListener(GsonBuilder().se
|
|||||||
|
|
||||||
inputsLoop@ for (inputs in recipe.inputs) {
|
inputsLoop@ for (inputs in recipe.inputs) {
|
||||||
var minimal: MatterManager.IMatterValue? = null
|
var minimal: MatterManager.IMatterValue? = null
|
||||||
var minimalDivisor = 0L
|
var minimalMultiplier = 0.0
|
||||||
|
|
||||||
for (input in inputs) {
|
for (input in inputs) {
|
||||||
val ivalue = determineValue(input.item)
|
val ivalue = determineValue(input.item)
|
||||||
@ -269,14 +269,14 @@ object RecipeResolverManager : SimpleJsonResourceReloadListener(GsonBuilder().se
|
|||||||
} else {
|
} else {
|
||||||
continue@recipesLoop
|
continue@recipesLoop
|
||||||
}
|
}
|
||||||
} else if (ivalue.isRecursion) {
|
} else if (ivalue.isSkipped) {
|
||||||
hadRecursion = true
|
hadSkips = true
|
||||||
break@recipesLoop
|
break@recipesLoop
|
||||||
}
|
}
|
||||||
|
|
||||||
if (minimal == null || minimal > ivalue.value!!) {
|
if (minimal == null || minimal > ivalue.value!!) {
|
||||||
minimal = ivalue.value
|
minimal = ivalue.value
|
||||||
minimalDivisor = input.count
|
minimalMultiplier = input.multiplier
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,11 +284,11 @@ object RecipeResolverManager : SimpleJsonResourceReloadListener(GsonBuilder().se
|
|||||||
return Result.MISSING
|
return Result.MISSING
|
||||||
|
|
||||||
if (accumulatedMatter == null || accumulatedComplexity == null) {
|
if (accumulatedMatter == null || accumulatedComplexity == null) {
|
||||||
accumulatedMatter = minimal.matter / minimalDivisor
|
accumulatedMatter = minimal.matter * minimalMultiplier
|
||||||
accumulatedComplexity = minimal.complexity / minimalDivisor
|
accumulatedComplexity = minimal.complexity * minimalMultiplier
|
||||||
} else {
|
} else {
|
||||||
accumulatedMatter += minimal.matter / minimalDivisor
|
accumulatedMatter += minimal.matter * minimalMultiplier
|
||||||
accumulatedComplexity += minimal.complexity / minimalDivisor
|
accumulatedComplexity += minimal.complexity * minimalMultiplier
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,13 +302,13 @@ object RecipeResolverManager : SimpleJsonResourceReloadListener(GsonBuilder().se
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (minimalMatter == null || minimalMatter > accumulatedMatter) {
|
if (minimalMatter == null || minimalMatter > accumulatedMatter) {
|
||||||
minimalMatter = accumulatedMatter / recipe.output.count
|
minimalMatter = recipe.transformMatterValue(accumulatedMatter * recipe.output.multiplier)
|
||||||
minimalComplexity = accumulatedComplexity / recipe.output.count
|
minimalComplexity = recipe.transformComplexity(accumulatedComplexity * recipe.output.multiplier)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (minimalMatter == null || minimalComplexity == null) {
|
if (minimalMatter == null || minimalComplexity == null) {
|
||||||
if (hadRecursion) {
|
if (hadSkips) {
|
||||||
return Result.RECURSION
|
return Result.RECURSION
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user