aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/features/chat
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/features/chat')
-rw-r--r--src/main/kotlin/features/chat/AutoCompletions.kt2
-rw-r--r--src/main/kotlin/features/chat/ChatLinks.kt48
-rw-r--r--src/main/kotlin/features/chat/CopyChat.kt4
-rw-r--r--src/main/kotlin/features/chat/PartyCommands.kt4
-rw-r--r--src/main/kotlin/features/chat/QuickCommands.kt26
5 files changed, 42 insertions, 42 deletions
diff --git a/src/main/kotlin/features/chat/AutoCompletions.kt b/src/main/kotlin/features/chat/AutoCompletions.kt
index c9fd133..f13fe7e 100644
--- a/src/main/kotlin/features/chat/AutoCompletions.kt
+++ b/src/main/kotlin/features/chat/AutoCompletions.kt
@@ -9,7 +9,7 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType
import kotlin.concurrent.thread
import net.minecraft.SharedConstants
-import net.minecraft.command.TranslatableBuiltInExceptions
+import net.minecraft.commands.BrigadierExceptions
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.commands.get
import moe.nea.firmament.commands.suggestsList
diff --git a/src/main/kotlin/features/chat/ChatLinks.kt b/src/main/kotlin/features/chat/ChatLinks.kt
index 76eb48d..aca7af8 100644
--- a/src/main/kotlin/features/chat/ChatLinks.kt
+++ b/src/main/kotlin/features/chat/ChatLinks.kt
@@ -9,15 +9,15 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.async
import kotlinx.coroutines.future.await
import kotlin.math.min
-import net.minecraft.client.gui.screen.ChatScreen
-import net.minecraft.client.texture.NativeImage
-import net.minecraft.client.texture.NativeImageBackedTexture
-import net.minecraft.text.ClickEvent
-import net.minecraft.text.HoverEvent
-import net.minecraft.text.Style
-import net.minecraft.text.Text
-import net.minecraft.util.Formatting
-import net.minecraft.util.Identifier
+import net.minecraft.client.gui.screens.ChatScreen
+import com.mojang.blaze3d.platform.NativeImage
+import net.minecraft.client.renderer.texture.DynamicTexture
+import net.minecraft.network.chat.ClickEvent
+import net.minecraft.network.chat.HoverEvent
+import net.minecraft.network.chat.Style
+import net.minecraft.network.chat.Component
+import net.minecraft.ChatFormatting
+import net.minecraft.resources.ResourceLocation
import moe.nea.firmament.Firmament
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ModifyChatEvent
@@ -54,7 +54,7 @@ object ChatLinks {
val nextTexId = AtomicInteger(0)
data class Image(
- val texture: Identifier,
+ val texture: ResourceLocation,
val width: Int,
val height: Int,
)
@@ -76,9 +76,9 @@ object ChatLinks {
.await()
val image = NativeImage.read(inputStream)
val texId = Firmament.identifier("dynamic_image_preview${nextTexId.getAndIncrement()}")
- MC.textureManager.registerTexture(
+ MC.textureManager.register(
texId,
- NativeImageBackedTexture({ texId.path }, image)
+ DynamicTexture({ texId.path }, image)
)
Image(texId, image.width, image.height)
} catch (exc: Exception) {
@@ -99,7 +99,7 @@ object ChatLinks {
if (!TConfig.imageEnabled) return
if (it.screen !is ChatScreen) return
val hoveredComponent =
- MC.inGameHud.chatHud.getTextStyleAt(it.mouseX.toDouble(), it.mouseY.toDouble()) ?: return
+ MC.inGameHud.chat.getClickedComponentStyleAt(it.mouseX.toDouble(), it.mouseY.toDouble()) ?: return
val hoverEvent = hoveredComponent.hoverEvent as? HoverEvent.ShowText ?: return
val value = hoverEvent.value
val url = urlRegex.matchEntire(value.unformattedString)?.groupValues?.get(0) ?: return
@@ -107,11 +107,11 @@ object ChatLinks {
val imageFuture = imageCache[url] ?: return
if (!imageFuture.isCompleted) return
val image = imageFuture.getCompleted() ?: return
- it.drawContext.matrices.pushMatrix()
+ it.drawContext.pose().pushMatrix()
val pos = TConfig.position
- pos.applyTransformations(JarvisIntegration.jarvis, it.drawContext.matrices)
+ pos.applyTransformations(JarvisIntegration.jarvis, it.drawContext.pose())
val scale = min(1F, min((9 * 20F) / image.height, (16 * 20F) / image.width))
- it.drawContext.matrices.scale(scale, scale)
+ it.drawContext.pose().scale(scale, scale)
it.drawContext.drawTexture(
image.texture,
0,
@@ -123,7 +123,7 @@ object ChatLinks {
image.width,
image.height,
)
- it.drawContext.matrices.popMatrix()
+ it.drawContext.pose().popMatrix()
}
@Subscribe
@@ -132,23 +132,23 @@ object ChatLinks {
it.replaceWith = it.replaceWith.transformEachRecursively { child ->
val text = child.string
if ("://" !in text) return@transformEachRecursively child
- val s = Text.empty().setStyle(child.style)
+ val s = Component.empty().setStyle(child.style)
var index = 0
while (index < text.length) {
val nextMatch = urlRegex.find(text, index)
val url = nextMatch?.groupValues[0]
val uri = runCatching { url?.let(::URI) }.getOrNull()
if (nextMatch == null || url == null || uri == null) {
- s.append(Text.literal(text.substring(index, text.length)))
+ s.append(Component.literal(text.substring(index, text.length)))
break
}
val range = nextMatch.groups[0]!!.range
- s.append(Text.literal(text.substring(index, range.first)))
+ s.append(Component.literal(text.substring(index, range.first)))
s.append(
- Text.literal(url).setStyle(
- Style.EMPTY.withUnderline(true).withColor(
- Formatting.AQUA
- ).withHoverEvent(HoverEvent.ShowText(Text.literal(url)))
+ Component.literal(url).setStyle(
+ Style.EMPTY.withUnderlined(true).withColor(
+ ChatFormatting.AQUA
+ ).withHoverEvent(HoverEvent.ShowText(Component.literal(url)))
.withClickEvent(ClickEvent.OpenUrl(uri))
)
)
diff --git a/src/main/kotlin/features/chat/CopyChat.kt b/src/main/kotlin/features/chat/CopyChat.kt
index 5c46465..6bef99f 100644
--- a/src/main/kotlin/features/chat/CopyChat.kt
+++ b/src/main/kotlin/features/chat/CopyChat.kt
@@ -1,6 +1,6 @@
package moe.nea.firmament.features.chat
-import net.minecraft.text.OrderedText
+import net.minecraft.util.FormattedCharSequence
import moe.nea.firmament.util.data.Config
import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.util.reconstitute
@@ -15,7 +15,7 @@ object CopyChat {
val copyChat by toggle("copy-chat") { false }
}
- fun orderedTextToString(orderedText: OrderedText): String {
+ fun orderedTextToString(orderedText: FormattedCharSequence): String {
return orderedText.reconstitute().string
}
}
diff --git a/src/main/kotlin/features/chat/PartyCommands.kt b/src/main/kotlin/features/chat/PartyCommands.kt
index 1b34946..85daf51 100644
--- a/src/main/kotlin/features/chat/PartyCommands.kt
+++ b/src/main/kotlin/features/chat/PartyCommands.kt
@@ -5,7 +5,7 @@ import com.mojang.brigadier.StringReader
import com.mojang.brigadier.exceptions.CommandSyntaxException
import com.mojang.brigadier.tree.LiteralCommandNode
import kotlin.time.Duration.Companion.seconds
-import net.minecraft.util.math.BlockPos
+import net.minecraft.core.BlockPos
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.commands.CaseInsensitiveLiteralCommandNode
import moe.nea.firmament.commands.thenExecute
@@ -80,7 +80,7 @@ object PartyCommands {
register("coords") {
executes {
- val p = MC.player?.blockPos ?: BlockPos.ORIGIN
+ val p = MC.player?.blockPosition() ?: BlockPos.ZERO
MC.sendCommand("pc x: ${p.x}, y: ${p.y}, z: ${p.z}")
0
}
diff --git a/src/main/kotlin/features/chat/QuickCommands.kt b/src/main/kotlin/features/chat/QuickCommands.kt
index 5221205..b857f8a 100644
--- a/src/main/kotlin/features/chat/QuickCommands.kt
+++ b/src/main/kotlin/features/chat/QuickCommands.kt
@@ -5,9 +5,9 @@ import com.mojang.brigadier.context.CommandContext
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource
import net.fabricmc.fabric.impl.command.client.ClientCommandInternals
-import net.minecraft.command.CommandRegistryAccess
-import net.minecraft.network.packet.s2c.play.CommandTreeS2CPacket
-import net.minecraft.text.Text
+import net.minecraft.commands.CommandBuildContext
+import net.minecraft.network.protocol.game.ClientboundCommandsPacket
+import net.minecraft.network.chat.Component
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.commands.DefaultSource
import moe.nea.firmament.commands.RestArgumentType
@@ -45,13 +45,13 @@ object QuickCommands {
ClientCommandInternals.setActiveDispatcher(dispatcher)
ClientCommandRegistrationCallback.EVENT.invoker()
.register(
- dispatcher, CommandRegistryAccess.of(
- network.combinedDynamicRegistries,
- network.enabledFeatures
+ dispatcher, CommandBuildContext.simple(
+ network.registryAccess,
+ network.enabledFeatures()
)
)
ClientCommandInternals.finalizeInit()
- network.onCommandTree(lastPacket)
+ network.handleCommands(lastPacket)
} catch (ex: Exception) {
ClientCommandInternals.setActiveDispatcher(fallback)
throw ex
@@ -69,7 +69,7 @@ object QuickCommands {
return lf
}
- var lastReceivedTreePacket: CommandTreeS2CPacket? = null
+ var lastReceivedTreePacket: ClientboundCommandsPacket? = null
val kuudraLevelNames = listOf("NORMAL", "HOT", "BURNING", "FIERY", "INFERNAL")
val dungeonLevelNames = listOf("ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN")
@@ -103,10 +103,10 @@ object QuickCommands {
}
val joinName = getNameForFloor(what.replace(" ", "").lowercase())
if (joinName == null) {
- source.sendFeedback(Text.stringifiedTranslatable("firmament.quick-commands.join.unknown", what))
+ source.sendFeedback(Component.translatableEscape("firmament.quick-commands.join.unknown", what))
} else {
source.sendFeedback(
- Text.stringifiedTranslatable(
+ Component.translatableEscape(
"firmament.quick-commands.join.success",
joinName
)
@@ -116,7 +116,7 @@ object QuickCommands {
}
}
thenExecute {
- source.sendFeedback(Text.translatable("firmament.quick-commands.join.explain"))
+ source.sendFeedback(Component.translatable("firmament.quick-commands.join.explain"))
}
}
}
@@ -132,7 +132,7 @@ object QuickCommands {
}
if (l !in kuudraLevelNames.indices) {
source.sendFeedback(
- Text.stringifiedTranslatable(
+ Component.translatableEscape(
"firmament.quick-commands.join.unknown-kuudra",
kuudraLevel
)
@@ -157,7 +157,7 @@ object QuickCommands {
}
if (l !in dungeonLevelNames.indices) {
source.sendFeedback(
- Text.stringifiedTranslatable(
+ Component.translatableEscape(
"firmament.quick-commands.join.unknown-catacombs",
kuudraLevel
)