-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(mod): add MixinServerGamePacketListenerImplKt.kt to git
- Loading branch information
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
versions/src/main/kotlin/su/plo/slib/mod/mixinkt/MixinServerGamePacketListenerImplKt.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |