HTTPS
https://git.nageyqma.icu/nageyqma/odin_next.git
SSH
git@git.nageyqma.icu:nageyqma/odin_next.git
HTTPS 链接可直接 git clone;推送代码请使用 SSH。
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
package com.odtheking.odin.utils
import com.odtheking.odin.OdinMod.mc
import com.odtheking.odin.features.impl.render.ClickGUIModule
import net.minecraft.client.gui.components.ChatComponent
import net.minecraft.network.chat.Component
import net.minecraft.network.chat.Style
fun sendChatMessage(message: Any) {
mc.execute { mc.player?.connection?.sendChat(message.toString()) }
}
fun sendCommand(command: String) {
mc.execute { mc.player?.connection?.sendCommand(command) }
}
fun modMessage(message: Any?, prefix: String = "§3Odin §8»§r ", chatStyle: Style? = null) {
val text = Component.literal("$prefix$message")
chatStyle?.let { text.setStyle(chatStyle) }
mc.schedule { mc.gui.hud.chat.addClientSystemMessage(text) }
}
fun modMessage(message: Component, prefix: String = "§3Odin §8»§r ", chatStyle: Style? = null) {
val text = Component.literal(prefix).append(message)
chatStyle?.let { text.setStyle(chatStyle) }
mc.schedule { mc.gui.hud.chat.addClientSystemMessage(text) }
}
fun devMessage(message: Any?) {
if (!ClickGUIModule.devMessage) return println(message)
modMessage(message, "§3Odin§bDev §8»§r ")
}
fun getCenteredText(text: String): String {
val strippedText = text.noControlCodes
if (strippedText.isEmpty()) return text
val textWidth = mc.font.width(strippedText)
val chatWidth = ChatComponent.getWidth(mc.options.chatWidth().get())
if (textWidth >= chatWidth) return text
val spacesNeeded = ((chatWidth - textWidth) / 2 / 4).coerceAtLeast(0)
return " ".repeat(spacesNeeded) + text
}
fun getChatBreak(): String {
return ChatComponent.getWidth(mc.options.chatWidth().get()).let {
"§9§m" + "-".repeat(it / mc.font.width("-"))
}
}