store multiple comments
This commit is contained in:
parent
d9944bd37c
commit
0f1ef82fcd
@ -492,7 +492,7 @@ object MatterManager {
|
|||||||
|
|
||||||
if (recipes == null || recipes.isEmpty() || !recipes.all { it.allowBacktrack } || !recipes.all { it.inputs.all { it.all { it.item == item } } }) {
|
if (recipes == null || recipes.isEmpty() || !recipes.all { it.allowBacktrack } || !recipes.all { it.inputs.all { it.all { it.item == item } } }) {
|
||||||
if (makeCommentary)
|
if (makeCommentary)
|
||||||
commentary[item] = TextComponent("Item '${item.registryName}' has no recipes")
|
comment(item, TextComponent("Item '${item.registryName}' has no recipes"))
|
||||||
|
|
||||||
return Result.MISSING
|
return Result.MISSING
|
||||||
}
|
}
|
||||||
@ -519,7 +519,7 @@ object MatterManager {
|
|||||||
|
|
||||||
if (minimal == null) {
|
if (minimal == null) {
|
||||||
if (makeCommentary)
|
if (makeCommentary)
|
||||||
commentary[item] = TextComponent("Item '${item.registryName}' has no valid backtracking recipes, and no output recipes")
|
comment(item, TextComponent("Item '${item.registryName}' has no valid backtracking recipes, and no output recipes"))
|
||||||
|
|
||||||
return Result.MISSING
|
return Result.MISSING
|
||||||
}
|
}
|
||||||
@ -528,7 +528,7 @@ object MatterManager {
|
|||||||
|
|
||||||
changes = true
|
changes = true
|
||||||
determinedValues[item] = result
|
determinedValues[item] = result
|
||||||
commentary[item] = TextComponent("Matter value backtracked from ${foundRecipe!!.formattedName}")
|
comment(item, TextComponent("Matter value backtracked from ${foundRecipe!!.formattedName}"))
|
||||||
return Result(result)
|
return Result(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -588,7 +588,7 @@ object MatterManager {
|
|||||||
recipesLoop@ for (recipe in recipes) {
|
recipesLoop@ for (recipe in recipes) {
|
||||||
if (recipe.inputs.isEmpty()) {
|
if (recipe.inputs.isEmpty()) {
|
||||||
// TODO: should we ignore empty recipes?
|
// TODO: should we ignore empty recipes?
|
||||||
commentary[item] = TextComponent("${recipe.formattedName} is empty")
|
comment(item, TextComponent("${recipe.formattedName} is empty"))
|
||||||
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -604,8 +604,8 @@ object MatterManager {
|
|||||||
val ivalue = determineValue(input.item)
|
val ivalue = determineValue(input.item)
|
||||||
|
|
||||||
if (ivalue.isMissing) {
|
if (ivalue.isMissing) {
|
||||||
if (recipe.isCritical || item !in commentary)
|
if (recipe.isCritical)
|
||||||
commentary[item] = TextComponent("Input '${input.item.registryName}' at input slot $i in ${recipe.formattedName} has no matter value")
|
comment(item, TextComponent("Input '${input.item.registryName}' at input slot $i in ${recipe.formattedName} has no matter value"))
|
||||||
|
|
||||||
if (recipe.isCritical) {
|
if (recipe.isCritical) {
|
||||||
return Result.MISSING
|
return Result.MISSING
|
||||||
@ -613,8 +613,8 @@ object MatterManager {
|
|||||||
continue@recipesLoop
|
continue@recipesLoop
|
||||||
}
|
}
|
||||||
} else if (ivalue.isSkipped) {
|
} else if (ivalue.isSkipped) {
|
||||||
if (recipe.isCritical || item !in commentary)
|
if (recipe.isCritical)
|
||||||
commentary[item] = TextComponent("Input '${input.item.registryName}' at input slot $i in ${recipe.formattedName} is recursive")
|
comment(item, TextComponent("Input '${input.item.registryName}' at input slot $i in ${recipe.formattedName} is recursive"))
|
||||||
|
|
||||||
hadSkips = true
|
hadSkips = true
|
||||||
continue@recipesLoop
|
continue@recipesLoop
|
||||||
@ -627,7 +627,7 @@ object MatterManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (minimal == null || !minimal.hasMatterValue) {
|
if (minimal == null || !minimal.hasMatterValue) {
|
||||||
commentary[item] = TextComponent("'${recipe.formattedName}' has invalid input at slot $i (possible inputs: ${inputs.joinToString(", ", transform = { it.item.registryName.toString() }) }) (???)")
|
comment(item, TextComponent("'${recipe.formattedName}' has invalid input at slot $i (possible inputs: ${inputs.joinToString(", ", transform = { it.item.registryName.toString() }) }) (???)"))
|
||||||
return Result.MISSING
|
return Result.MISSING
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -645,7 +645,7 @@ object MatterManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!accumulatedMatter.isPositive || accumulatedComplexity <= 0.0) {
|
if (!accumulatedMatter.isPositive || accumulatedComplexity <= 0.0) {
|
||||||
commentary[item] = TextComponent("${recipe.formattedName} ended up with negative matter value and/or complexity (???)")
|
comment(item, TextComponent("${recipe.formattedName} ended up with negative matter value and/or complexity (???)"))
|
||||||
return Result.MISSING
|
return Result.MISSING
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -667,8 +667,7 @@ object MatterManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item !in commentary)
|
comment(item, TextComponent("'${item.registryName}' ended up with no valid recipes (???)"))
|
||||||
commentary[item] = TextComponent("'${item.registryName}' ended up with no valid recipes (???)")
|
|
||||||
|
|
||||||
return Result.MISSING
|
return Result.MISSING
|
||||||
}
|
}
|
||||||
@ -677,7 +676,7 @@ object MatterManager {
|
|||||||
|
|
||||||
changes = true
|
changes = true
|
||||||
determinedValues[item] = result
|
determinedValues[item] = result
|
||||||
commentary[item] = TextComponent("Matter value derived from ${minimalRecipe!!.formattedName}")
|
comment(item, TextComponent("Matter value derived from ${minimalRecipe!!.formattedName}"))
|
||||||
|
|
||||||
return Result(result)
|
return Result(result)
|
||||||
}
|
}
|
||||||
@ -811,8 +810,8 @@ object MatterManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (item in toDetermine) {
|
for (item in toDetermine) {
|
||||||
if (item !in commentary) {
|
if (item !in commentary || commentary[item]!!.isEmpty()) {
|
||||||
commentary[item] = TextComponent("Item ${item.registryName} was never visited")
|
comment(item, TextComponent("Item ${item.registryName} was never visited"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -977,10 +976,12 @@ object MatterManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (event.flags.isAdvanced) {
|
if (event.flags.isAdvanced) {
|
||||||
val commentary = getCommentary(event.itemStack.item)?.withStyle(ChatFormatting.DARK_GRAY)
|
val commentary = getCommentary(event.itemStack.item)
|
||||||
|
|
||||||
if (commentary != null) {
|
if (commentary != null) {
|
||||||
event.toolTip.add(commentary)
|
for (value in commentary) {
|
||||||
|
event.toolTip.add(value.withStyle(ChatFormatting.DARK_GRAY))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1060,11 +1061,22 @@ object MatterManager {
|
|||||||
@JvmStatic val recipeFinders get() = Resolver.delegate.get()
|
@JvmStatic val recipeFinders get() = Resolver.delegate.get()
|
||||||
@JvmStatic val recipeFindersKey get() = Resolver.delegate.key
|
@JvmStatic val recipeFindersKey get() = Resolver.delegate.key
|
||||||
|
|
||||||
private val commentary = Reference2ObjectOpenHashMap<Item, Component>()
|
private val commentary = Reference2ObjectOpenHashMap<Item, ArrayList<Component>>()
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun getCommentary(item: Item): MutableComponent? {
|
fun getCommentary(item: Item): List<MutableComponent>? {
|
||||||
return commentary[item]?.copy()
|
return commentary[item]?.let { source ->
|
||||||
|
ArrayList<MutableComponent>(source.size)
|
||||||
|
.also { for (value in source) it.add(value.copy()) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun comment(item: Item, comment: Component) {
|
||||||
|
val target = commentary.computeIfAbsent(item, Reference2ObjectFunction { ArrayList(1) })
|
||||||
|
|
||||||
|
if (comment !in target) {
|
||||||
|
target.add(comment)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun reloadEvent(event: AddReloadListenerEvent) {
|
fun reloadEvent(event: AddReloadListenerEvent) {
|
||||||
@ -1121,9 +1133,9 @@ object MatterManager {
|
|||||||
val (key, item) = entry
|
val (key, item) = entry
|
||||||
|
|
||||||
if (!value.hasMatterValue) {
|
if (!value.hasMatterValue) {
|
||||||
writer.write(arrayOf(key.location().toString(), "", "", commentary[item]?.string ?: "").joinToString(";", transform = ::transformQuotes))
|
writer.write(arrayOf(key.location().toString(), "", "", commentary[item]?.joinToString("\n", transform = { transformQuotes(it.string) }) ?: "").joinToString(";", transform = ::transformQuotes))
|
||||||
} else {
|
} else {
|
||||||
writer.write(arrayOf(key.location().toString(), value.matter.toString(), value.complexity.toString(), commentary[item]?.string ?: "").joinToString(";", transform = ::transformQuotes))
|
writer.write(arrayOf(key.location().toString(), value.matter.toString(), value.complexity.toString(), commentary[item]?.joinToString("\n", transform = { transformQuotes(it.string) }) ?: "").joinToString(";", transform = ::transformQuotes))
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.write("\n")
|
writer.write("\n")
|
||||||
|
Loading…
Reference in New Issue
Block a user