fix: dedicated server

This commit is contained in:
xtex 2023-07-27 10:32:33 +08:00
parent e70697fa6a
commit 5beb4d977f
Signed by: xtex
GPG Key ID: B918086ED8045B91

View File

@ -1,7 +1,9 @@
package quaedam.config package quaedam.config
import dev.architectury.networking.NetworkManager import dev.architectury.networking.NetworkManager
import dev.architectury.platform.Platform
import io.netty.buffer.Unpooled import io.netty.buffer.Unpooled
import net.fabricmc.api.EnvType
import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.CompoundTag
import net.minecraft.network.FriendlyByteBuf import net.minecraft.network.FriendlyByteBuf
import net.minecraft.server.level.ServerPlayer import net.minecraft.server.level.ServerPlayer
@ -12,8 +14,10 @@ object SimpleQuaedamConfigPush {
val id = Quaedam.resource("simple_config_push") val id = Quaedam.resource("simple_config_push")
init { init {
if (Platform.getEnv() == EnvType.CLIENT) {
NetworkManager.registerReceiver(NetworkManager.Side.S2C, id, ::handle) NetworkManager.registerReceiver(NetworkManager.Side.S2C, id, ::handle)
} }
}
private fun handle(buf: FriendlyByteBuf, ctx: NetworkManager.PacketContext) { private fun handle(buf: FriendlyByteBuf, ctx: NetworkManager.PacketContext) {
val data = buf.readNbt()!! val data = buf.readNbt()!!