feat: Allow skipping DFU for REI lore cache generation
This commit is contained in:
@@ -21,6 +21,7 @@ import net.minecraft.item.tooltip.TooltipType
|
|||||||
import net.minecraft.text.Text
|
import net.minecraft.text.Text
|
||||||
import moe.nea.firmament.compat.rei.FirmamentReiPlugin.Companion.asItemEntry
|
import moe.nea.firmament.compat.rei.FirmamentReiPlugin.Companion.asItemEntry
|
||||||
import moe.nea.firmament.events.ItemTooltipEvent
|
import moe.nea.firmament.events.ItemTooltipEvent
|
||||||
|
import moe.nea.firmament.repo.RepoManager
|
||||||
import moe.nea.firmament.repo.SBItemStack
|
import moe.nea.firmament.repo.SBItemStack
|
||||||
import moe.nea.firmament.util.ErrorUtil
|
import moe.nea.firmament.util.ErrorUtil
|
||||||
import moe.nea.firmament.util.FirmFormatters
|
import moe.nea.firmament.util.FirmFormatters
|
||||||
@@ -44,9 +45,12 @@ object NEUItemEntryRenderer : EntryRenderer<SBItemStack> {
|
|||||||
context.matrices.scale(bounds.width.toFloat() / 16F, bounds.height.toFloat() / 16F, 1f)
|
context.matrices.scale(bounds.width.toFloat() / 16F, bounds.height.toFloat() / 16F, 1f)
|
||||||
val item = entry.asItemEntry().value
|
val item = entry.asItemEntry().value
|
||||||
context.drawItemWithoutEntity(item, -8, -8)
|
context.drawItemWithoutEntity(item, -8, -8)
|
||||||
context.drawStackOverlay(minecraft.textRenderer, item, -8, -8,
|
context.drawStackOverlay(
|
||||||
if (entry.value.getStackSize() > 1000) FirmFormatters.shortFormat(entry.value.getStackSize()
|
minecraft.textRenderer, item, -8, -8,
|
||||||
.toDouble())
|
if (entry.value.getStackSize() > 1000) FirmFormatters.shortFormat(
|
||||||
|
entry.value.getStackSize()
|
||||||
|
.toDouble()
|
||||||
|
)
|
||||||
else null
|
else null
|
||||||
)
|
)
|
||||||
context.matrices.pop()
|
context.matrices.pop()
|
||||||
@@ -56,6 +60,16 @@ object NEUItemEntryRenderer : EntryRenderer<SBItemStack> {
|
|||||||
var canUseVanillaTooltipEvents = true
|
var canUseVanillaTooltipEvents = true
|
||||||
|
|
||||||
override fun getTooltip(entry: EntryStack<SBItemStack>, tooltipContext: TooltipContext): Tooltip? {
|
override fun getTooltip(entry: EntryStack<SBItemStack>, tooltipContext: TooltipContext): Tooltip? {
|
||||||
|
if (!entry.value.isWarm() && !RepoManager.Config.perfectTooltips) {
|
||||||
|
val neuItem = entry.value.neuItem
|
||||||
|
if (neuItem != null) {
|
||||||
|
val lore = mutableListOf<Text>()
|
||||||
|
lore.add(Text.literal(neuItem.displayName))
|
||||||
|
neuItem.lore.mapTo(mutableListOf()) { Text.literal(it) }
|
||||||
|
return Tooltip.create(lore)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val stack = entry.value.asImmutableItemStack()
|
val stack = entry.value.asImmutableItemStack()
|
||||||
|
|
||||||
val lore = mutableListOf(stack.displayNameAccordingToNbt)
|
val lore = mutableListOf(stack.displayNameAccordingToNbt)
|
||||||
@@ -70,12 +84,14 @@ object NEUItemEntryRenderer : EntryRenderer<SBItemStack> {
|
|||||||
ErrorUtil.softError("Failed to use vanilla tooltips", ex)
|
ErrorUtil.softError("Failed to use vanilla tooltips", ex)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ItemTooltipEvent.publish(ItemTooltipEvent(
|
ItemTooltipEvent.publish(
|
||||||
|
ItemTooltipEvent(
|
||||||
stack,
|
stack,
|
||||||
tooltipContext.vanillaContext(),
|
tooltipContext.vanillaContext(),
|
||||||
TooltipType.BASIC,
|
TooltipType.BASIC,
|
||||||
lore
|
lore
|
||||||
))
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
if (entry.value.getStackSize() > 1000 && lore.isNotEmpty())
|
if (entry.value.getStackSize() > 1000 && lore.isNotEmpty())
|
||||||
lore.add(1, Text.literal("${entry.value.getStackSize()}x").darkGrey())
|
lore.add(1, Text.literal("${entry.value.getStackSize()}x").darkGrey())
|
||||||
|
|||||||
@@ -42,7 +42,12 @@ object SBItemEntryDefinition : EntryDefinition<SBItemStack> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun asFormattedText(entry: EntryStack<SBItemStack>, value: SBItemStack): Text {
|
override fun asFormattedText(entry: EntryStack<SBItemStack>, value: SBItemStack): Text {
|
||||||
return VanillaEntryTypes.ITEM.definition.asFormattedText(entry.asItemEntry(), value.asImmutableItemStack())
|
val neuItem = entry.value.neuItem
|
||||||
|
return if (RepoManager.Config.perfectTooltips || entry.value.isWarm() || neuItem == null) {
|
||||||
|
VanillaEntryTypes.ITEM.definition.asFormattedText(entry.asItemEntry(), value.asImmutableItemStack())
|
||||||
|
} else {
|
||||||
|
Text.literal(neuItem.displayName)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun hash(entry: EntryStack<SBItemStack>, value: SBItemStack, context: ComparisonContext): Long {
|
override fun hash(entry: EntryStack<SBItemStack>, value: SBItemStack, context: ComparisonContext): Long {
|
||||||
@@ -51,8 +56,10 @@ object SBItemEntryDefinition : EntryDefinition<SBItemStack> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun wildcard(entry: EntryStack<SBItemStack>?, value: SBItemStack): SBItemStack {
|
override fun wildcard(entry: EntryStack<SBItemStack>?, value: SBItemStack): SBItemStack {
|
||||||
return value.copy(stackSize = 1, petData = RepoManager.getPotentialStubPetData(value.skyblockId),
|
return value.copy(
|
||||||
stars = 0, extraLore = listOf(), reforge = null)
|
stackSize = 1, petData = RepoManager.getPotentialStubPetData(value.skyblockId),
|
||||||
|
stars = 0, extraLore = listOf(), reforge = null
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun normalize(entry: EntryStack<SBItemStack>?, value: SBItemStack): SBItemStack {
|
override fun normalize(entry: EntryStack<SBItemStack>?, value: SBItemStack): SBItemStack {
|
||||||
|
|||||||
@@ -146,6 +146,10 @@ object ItemCache : IReloadable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun hasCacheFor(skyblockId: SkyblockId): Boolean {
|
||||||
|
return skyblockId.neuItem in cache
|
||||||
|
}
|
||||||
|
|
||||||
fun NEUItem?.asItemStack(idHint: SkyblockId? = null, loreReplacements: Map<String, String>? = null): ItemStack {
|
fun NEUItem?.asItemStack(idHint: SkyblockId? = null, loreReplacements: Map<String, String>? = null): ItemStack {
|
||||||
if (this == null) return brokenItemStack(null, idHint)
|
if (this == null) return brokenItemStack(null, idHint)
|
||||||
var s = cache[this.skyblockItemId]
|
var s = cache[this.skyblockItemId]
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ object RepoManager {
|
|||||||
}
|
}
|
||||||
val alwaysSuperCraft by toggle("enable-super-craft") { true }
|
val alwaysSuperCraft by toggle("enable-super-craft") { true }
|
||||||
var warnForMissingItemListMod by toggle("warn-for-missing-item-list-mod") { true }
|
var warnForMissingItemListMod by toggle("warn-for-missing-item-list-mod") { true }
|
||||||
|
val perfectTooltips by toggle("perfect-tooltips") { false }
|
||||||
}
|
}
|
||||||
|
|
||||||
val currentDownloadedSha by RepoDownloadManager::latestSavedVersionHash
|
val currentDownloadedSha by RepoDownloadManager::latestSavedVersionHash
|
||||||
|
|||||||
@@ -225,14 +225,21 @@ data class SBItemStack constructor(
|
|||||||
Text.literal(
|
Text.literal(
|
||||||
buffKind.prefix + formattedAmount +
|
buffKind.prefix + formattedAmount +
|
||||||
statFormatting.postFix +
|
statFormatting.postFix +
|
||||||
buffKind.postFix + " ")
|
buffKind.postFix + " "
|
||||||
.withColor(buffKind.color)))
|
)
|
||||||
|
.withColor(buffKind.color)
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun formatValue() =
|
fun formatValue() =
|
||||||
Text.literal(FirmFormatters.formatCommas(valueNum ?: 0.0,
|
Text.literal(
|
||||||
|
FirmFormatters.formatCommas(
|
||||||
|
valueNum ?: 0.0,
|
||||||
1,
|
1,
|
||||||
includeSign = true) + statFormatting.postFix + " ")
|
includeSign = true
|
||||||
|
) + statFormatting.postFix + " "
|
||||||
|
)
|
||||||
.setStyle(Style.EMPTY.withColor(statFormatting.color))
|
.setStyle(Style.EMPTY.withColor(statFormatting.color))
|
||||||
|
|
||||||
val statFormatting = formattingOverrides[statName] ?: StatFormatting("", Formatting.GREEN)
|
val statFormatting = formattingOverrides[statName] ?: StatFormatting("", Formatting.GREEN)
|
||||||
@@ -413,13 +420,26 @@ data class SBItemStack constructor(
|
|||||||
.append(starString(stars))
|
.append(starString(stars))
|
||||||
val isDungeon = ItemType.fromItemStack(itemStack)?.isDungeon ?: true
|
val isDungeon = ItemType.fromItemStack(itemStack)?.isDungeon ?: true
|
||||||
val truncatedStarCount = if (isDungeon) minOf(5, stars) else stars
|
val truncatedStarCount = if (isDungeon) minOf(5, stars) else stars
|
||||||
appendEnhancedStats(itemStack,
|
appendEnhancedStats(
|
||||||
|
itemStack,
|
||||||
baseStats
|
baseStats
|
||||||
.filter { it.statFormatting.isStarAffected }
|
.filter { it.statFormatting.isStarAffected }
|
||||||
.associate {
|
.associate {
|
||||||
it.statName to ((it.valueNum ?: 0.0) * (truncatedStarCount * 0.02))
|
it.statName to ((it.valueNum ?: 0.0) * (truncatedStarCount * 0.02))
|
||||||
},
|
},
|
||||||
BuffKind.STAR_BUFF)
|
BuffKind.STAR_BUFF
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun isWarm(): Boolean {
|
||||||
|
if (itemStack_ != null) return true
|
||||||
|
if (ItemCache.hasCacheFor(skyblockId)) return true
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
fun asLazyImmutableItemStack(): ItemStack? {
|
||||||
|
if (isWarm()) return asImmutableItemStack()
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun asImmutableItemStack(): ItemStack {
|
fun asImmutableItemStack(): ItemStack {
|
||||||
|
|||||||
Reference in New Issue
Block a user