Skip to content

Commit

Permalink
fix(mod): add MixinServerGamePacketListenerImplKt.kt to git
Browse files Browse the repository at this point in the history
  • Loading branch information
Apehum committed Feb 6, 2024
1 parent 739994a commit ecd07d6
Showing 1 changed file with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package su.plo.slib.mod.mixinkt

//#if FORGE
//#if MC<12002
//$$ import io.netty.util.AsciiString
//$$ import net.minecraft.network.FriendlyByteBuf
//$$ import net.minecraft.network.protocol.game.ServerboundCustomPayloadPacket
//$$ import net.minecraft.resources.ResourceLocation
//$$ import net.minecraft.server.level.ServerPlayer
//$$ import su.plo.slib.mod.channel.RegisterChannelHandler
//$$
//$$ object MixinServerGamePacketListenerImplKt {
//$$
//$$ private val REGISTER = ResourceLocation("minecraft:register")
//$$
//$$ fun handleCustomPayload(player: ServerPlayer, packet: ServerboundCustomPayloadPacket) {
//$$ val packetId = packet.identifier
//$$ if (packetId != REGISTER) return
//$$
//$$ val channels = parseChannels(packet.data)
//$$ RegisterChannelHandler.firePlayerRegisterChannels(player, channels)
//$$ }
//$$
//$$ private fun parseChannels(buf: FriendlyByteBuf): List<String> {
//$$ val channels = ArrayList<String>()
//$$ val active = StringBuilder()
//$$
//$$ while (buf.isReadable) {
//$$ val byte = buf.readByte()
//$$
//$$ if (byte != 0.toByte()) {
//$$ active.append(AsciiString.b2c(byte))
//$$ continue
//$$ }
//$$
//$$ val channel = active.toString()
//$$ if (ResourceLocation.isValidResourceLocation(channel)) {
//$$ channels.add(channel)
//$$ }
//$$
//$$ active.clear()
//$$ }
//$$
//$$ return channels
//$$ }
//$$ }
//#endif
//#endif

0 comments on commit ecd07d6

Please sign in to comment.