Add warning for missing REI

This commit is contained in:
Linnea Gräf
2024-10-30 16:35:19 +01:00
parent c38dcee2c5
commit c9c25b6156
8 changed files with 374 additions and 233 deletions

View File

@@ -128,7 +128,7 @@ runtime_required = [
]
runtime_optional = [
"devauth",
"freecammod",
# "freecammod",
"sodium",
# "qolify",
"ncr",

View File

@@ -0,0 +1,83 @@
package moe.nea.firmament.features.inventory
import net.fabricmc.loader.api.FabricLoader
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlin.time.Duration.Companion.seconds
import net.minecraft.SharedConstants
import net.minecraft.text.ClickEvent
import net.minecraft.text.Text
import moe.nea.firmament.Firmament
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.commands.thenExecute
import moe.nea.firmament.events.CommandEvent
import moe.nea.firmament.events.SkyblockServerUpdateEvent
import moe.nea.firmament.repo.RepoManager
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.SBData
import moe.nea.firmament.util.aqua
import moe.nea.firmament.util.bold
import moe.nea.firmament.util.clickCommand
import moe.nea.firmament.util.grey
import moe.nea.firmament.util.lime
import moe.nea.firmament.util.red
import moe.nea.firmament.util.white
import moe.nea.firmament.util.yellow
object REIDependencyWarner {
val reiModId = "roughlyenoughitems"
val hasREI = FabricLoader.getInstance().isModLoaded(reiModId)
var sentWarning = false
fun modrinthLink(slug: String) =
"https://modrinth.com/mod/$slug/versions?g=${SharedConstants.getGameVersion().name}&l=fabric"
fun downloadButton(modName: String, modId: String, slug: String): Text {
val alreadyDownloaded = FabricLoader.getInstance().isModLoaded(modId)
return Text.literal(" - ")
.white()
.append(Text.literal("[").aqua())
.append(Text.translatable("firmament.download", modName)
.styled { it.withClickEvent(ClickEvent(ClickEvent.Action.OPEN_URL, modrinthLink(slug))) }
.yellow()
.also {
if (alreadyDownloaded)
it.append(Text.translatable("firmament.download.already", modName)
.lime())
})
.append(Text.literal("]").aqua())
}
@Subscribe
fun checkREIDependency(event: SkyblockServerUpdateEvent) {
if (!SBData.isOnSkyblock) return
if (hasREI) return
if (sentWarning) return
sentWarning = true
Firmament.coroutineScope.launch {
delay(2.seconds)
// TODO: should we offer an automatic install that actually downloads the JARs and places them into the mod folder?
MC.sendChat(
Text.translatable("firmament.reiwarning").red().bold().append("\n")
.append(downloadButton("RoughlyEnoughItems", reiModId, "rei")).append("\n")
.append(downloadButton("Architectury API", "architectury", "architectury-api")).append("\n")
.append(downloadButton("Cloth Config API", "cloth-config", "cloth-config")).append("\n")
.append(Text.translatable("firmament.reiwarning.disable")
.clickCommand("/firm disablereiwarning")
.grey())
)
}
}
@Subscribe
fun onSubcommand(event: CommandEvent.SubCommand) {
if (hasREI) return
event.subcommand("disablereiwarning") {
thenExecute {
RepoManager.Config.warnForMissingItemListMod = false
RepoManager.Config.save()
MC.sendChat(Text.translatable("firmament.reiwarning.disabled").yellow())
}
}
}
}

View File

@@ -40,7 +40,7 @@ object RepoManager {
RepoManager.launchAsyncUpdate(true)
}
val alwaysSuperCraft by toggle("enable-super-craft") { true }
var warnForMissingItemListMod by toggle("warn-for-missing-item-list-mod") { true }
}
val currentDownloadedSha by RepoDownloadManager::latestSavedVersionHash

View File

@@ -12,6 +12,7 @@ fun DrawContext.isUntranslatedGuiDrawContext(): Boolean {
fun DrawContext.drawLine(fromX: Int, fromY: Int, toX: Int, toY: Int, color: Color) {
// TODO: push scissors
// TODO: use matrix translations and a different render layer
if (toY < fromY) {
drawLine(toX, toY, fromX, fromY, color)
return

View File

@@ -1,5 +1,6 @@
package moe.nea.firmament.util
import net.minecraft.text.ClickEvent
import net.minecraft.text.MutableText
import net.minecraft.text.PlainTextContent
import net.minecraft.text.Text
@@ -119,7 +120,30 @@ fun Text.iterator(): Sequence<Text> {
fun Text.allSiblings(): List<Text> = listOf(this) + siblings.flatMap { it.allSiblings() }
fun MutableText.withColor(formatting: Formatting) = this.styled { it.withColor(formatting).withItalic(false) }
fun MutableText.withColor(formatting: Formatting): MutableText = this.styled {
it.withColor(formatting)
.withItalic(false)
.withBold(false)
}
fun MutableText.blue() = withColor(Formatting.BLUE)
fun MutableText.aqua() = withColor(Formatting.AQUA)
fun MutableText.lime() = withColor(Formatting.GREEN)
fun MutableText.darkGreen() = withColor(Formatting.DARK_GREEN)
fun MutableText.yellow() = withColor(Formatting.YELLOW)
fun MutableText.grey() = withColor(Formatting.GRAY)
fun MutableText.red() = withColor(Formatting.RED)
fun MutableText.white() = withColor(Formatting.WHITE)
fun MutableText.bold(): MutableText = styled { it.withBold(true) }
fun MutableText.clickCommand(command: String): MutableText {
require(command.startsWith("/"))
return this.styled {
it.withClickEvent(ClickEvent(ClickEvent.Action.RUN_COMMAND,
"/firm disablereiwarning"))
}
}
fun Text.transformEachRecursively(function: (Text) -> Text): Text {
val c = this.content

View File

@@ -43,6 +43,11 @@
"firmament.tooltip.bazaar.buy-order": "Bazaar Buy Order: %s",
"firmament.tooltip.ah.lowestbin": "Lowest BIN: %d",
"firmament.pv.pets": "Pets",
"firmament.reiwarning.disable": "Click here to disable this warning",
"firmament.reiwarning.disabled": "Disabled the RoughlyEnoughItems warning. Keep in mind that you will not have an item list without REI.",
"firmament.download": "Click here to download %s",
"firmament.download.already": " (Already downloaded)",
"firmament.reiwarning": "Firmament needs RoughlyEnoughItems to display its item list!",
"firmament.config.diana": "Diana",
"firmament.config.diana.ancestral-teleport": "Warp near guess",
"firmament.config.diana.ancestral-spade": "Ancestral Spade Solver",

View File

@@ -46,10 +46,7 @@
"depends": {
"fabric": "*",
"fabric-language-kotlin": ">=${fabric_kotlin_version}",
"minecraft": ">=${minecraft_version}",
"roughlyenoughitems": ">=${rei_version}",
"cloth-config": "*",
"architectury": "*"
"minecraft": ">=${minecraft_version}"
},
"custom": {
"configured": {

View File

@@ -0,0 +1,31 @@
{
components: {
"minecraft:custom_data": {
},
"minecraft:custom_name": '{"extra":[{"color":"dark_blue","text":"◆ "},{"bold":true,"color":"dark_blue","text":"Tidal Rune"}],"italic":false,"text":""}',
"minecraft:lore": [
'{"extra":[{"color":"dark_gray","text":"Rune Sack"}],"italic":false,"text":""}',
'{"italic":false,"text":""}',
'{"extra":[{"color":"yellow","text":"I"},{"color":"gray","text":": "},{"color":"yellow","text":"1"},{"color":"gray","text":"/64"}],"italic":false,"text":""}',
'{"extra":[{"color":"yellow","text":"II"},{"color":"gray","text":": "},{"color":"dark_gray","text":"0"},{"color":"gray","text":"/64"}],"italic":false,"text":""}',
'{"extra":[{"color":"yellow","text":"III"},{"color":"gray","text":": "},{"color":"dark_gray","text":"0"},{"color":"gray","text":"/64"}],"italic":false,"text":""}',
'{"italic":false,"text":""}',
'{"extra":[{"color":"gray","text":"Tier: "},{"color":"gold","text":"Legendary"}],"italic":false,"text":""}',
'{"italic":false,"text":""}',
'{"extra":[{"color":"yellow","text":"Click to pickup!"}],"italic":false,"text":""}'
],
"minecraft:profile": {
id: "30ea28d50755386a90924ae91af1b7e5",
name: "30ea28d50755386a",
properties: [
{
name: "textures",
signature: "",
value: "ewogICJ0aW1lc3RhbXAiIDogMTcxOTUwMzQ3NzI1MSwKICAicHJvZmlsZUlkIiA6ICIxOWY1YzkwMWEzMjQ0YzVmYTM4NThjZGVhNDk5ZWMwYSIsCiAgInByb2ZpbGVOYW1lIiA6ICJzb2RpdW16aXAiLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNjk2NzEwNDdjNmFkZThhOWM0ZDZhNTgxYmMyNmQyODRhNTRhZTMyZTg1YzM0Y2U2OWQ4MWY5Mjc5OWJmM2ZiYiIsCiAgICAgICJtZXRhZGF0YSIgOiB7CiAgICAgICAgIm1vZGVsIiA6ICJzbGltIgogICAgICB9CiAgICB9CiAgfQp9"
}
]
}
},
count: 1,
id: "minecraft:player_head"
}