aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/util
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-10-21 17:28:00 +0200
committernea <nea@nea.moe>2023-10-21 17:28:00 +0200
commite887067b7ecfa9d8e040008cca8d26c194f8c1a5 (patch)
tree8c558ed23edabd7722bf869ce24d5561b6644e44 /src/main/kotlin/moe/nea/firmament/util
parentbc758d17e2ac5c507117f85bf76b081a05f2baca (diff)
downloadfirmament-e887067b7ecfa9d8e040008cca8d26c194f8c1a5.tar.gz
firmament-e887067b7ecfa9d8e040008cca8d26c194f8c1a5.tar.bz2
firmament-e887067b7ecfa9d8e040008cca8d26c194f8c1a5.zip
Add tab completion to /warp
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/util')
-rw-r--r--src/main/kotlin/moe/nea/firmament/util/MC.kt20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/util/MC.kt b/src/main/kotlin/moe/nea/firmament/util/MC.kt
index 50462f7..347a15e 100644
--- a/src/main/kotlin/moe/nea/firmament/util/MC.kt
+++ b/src/main/kotlin/moe/nea/firmament/util/MC.kt
@@ -7,13 +7,16 @@
package moe.nea.firmament.util
import io.github.moulberry.repo.data.Coordinate
+import java.time.Instant
import java.util.concurrent.ConcurrentLinkedQueue
import net.minecraft.client.MinecraftClient
import net.minecraft.client.gui.screen.ingame.HandledScreen
+import net.minecraft.network.message.ArgumentSignatureDataMap
+import net.minecraft.network.message.LastSeenMessagesCollector.LastSeenMessages
+import net.minecraft.network.packet.c2s.play.CommandExecutionC2SPacket
import net.minecraft.text.Text
import net.minecraft.util.math.BlockPos
import moe.nea.firmament.events.TickEvent
-import moe.nea.firmament.mixins.accessor.AccessorHandledScreen
object MC {
@@ -34,10 +37,25 @@ object MC {
messageQueue.add(text)
}
+ fun sendServerCommand(command: String) {
+ val nh = player?.networkHandler ?: return
+ val lastSeenMessages: LastSeenMessages = nh.lastSeenMessagesCollector.collect()
+ nh.sendPacket(
+ CommandExecutionC2SPacket(
+ command,
+ Instant.now(),
+ 0L,
+ ArgumentSignatureDataMap.EMPTY,
+ lastSeenMessages.update()
+ )
+ )
+ }
+
fun sendCommand(command: String) {
player?.networkHandler?.sendCommand(command)
}
+ inline val networkHandler get() = player?.networkHandler
inline val instance get() = MinecraftClient.getInstance()
inline val keyboard get() = MinecraftClient.getInstance().keyboard
inline val textureManager get() = MinecraftClient.getInstance().textureManager