A Minecraft Fabric mod that connects the game with ATProtocol ⛏️
8
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: add sync preferences network packet

- Add SyncPreferencesPacket for C2S communication
- Packet includes all sync settings: stats, sessions, achievements, server status
- Includes sync frequencies for each data type
- Serializable with StreamCodec for Fabric networking
- Allows client to send preference updates to server

+46
+46
src/main/kotlin/com/jollywhoppers/network/AtProtoPackets.kt
··· 21 21 val AUTHENTICATE_C2S_ID = ResourceLocation.fromNamespaceAndPath("atproto-connect", "authenticate") 22 22 val AUTHENTICATE_RESPONSE_S2C_ID = ResourceLocation.fromNamespaceAndPath("atproto-connect", "authenticate_response") 23 23 val LOGOUT_C2S_ID = ResourceLocation.fromNamespaceAndPath("atproto-connect", "logout") 24 + val SYNC_PREFERENCES_C2S_ID = ResourceLocation.fromNamespaceAndPath("atproto-connect", "sync_preferences") 24 25 25 26 /** 26 27 * Client -> Server: Authenticated session data ··· 114 115 { buf -> 115 116 buf.readBoolean() 116 117 LogoutPacket() 118 + } 119 + ) 120 + } 121 + } 122 + 123 + /** 124 + * Client -> Server: Sync preferences update 125 + * Sent when player changes sync consent in ModMenu 126 + */ 127 + @Serializable 128 + data class SyncPreferencesPacket( 129 + val syncStatsEnabled: Boolean, 130 + val syncSessionsEnabled: Boolean, 131 + val syncAchievementsEnabled: Boolean, 132 + val syncServerStatusEnabled: Boolean, 133 + val statsSyncFrequency: Int, 134 + val sessionSyncFrequency: Int, 135 + val achievementSyncFrequency: Int, 136 + ) : CustomPacketPayload { 137 + override fun type(): CustomPacketPayload.Type<out CustomPacketPayload> = TYPE 138 + 139 + companion object { 140 + val TYPE: CustomPacketPayload.Type<SyncPreferencesPacket> = 141 + CustomPacketPayload.Type(SYNC_PREFERENCES_C2S_ID) 142 + 143 + val CODEC: StreamCodec<FriendlyByteBuf, SyncPreferencesPacket> = StreamCodec.of( 144 + { buf, packet -> 145 + buf.writeBoolean(packet.syncStatsEnabled) 146 + buf.writeBoolean(packet.syncSessionsEnabled) 147 + buf.writeBoolean(packet.syncAchievementsEnabled) 148 + buf.writeBoolean(packet.syncServerStatusEnabled) 149 + buf.writeInt(packet.statsSyncFrequency) 150 + buf.writeInt(packet.sessionSyncFrequency) 151 + buf.writeInt(packet.achievementSyncFrequency) 152 + }, 153 + { buf -> 154 + SyncPreferencesPacket( 155 + syncStatsEnabled = buf.readBoolean(), 156 + syncSessionsEnabled = buf.readBoolean(), 157 + syncAchievementsEnabled = buf.readBoolean(), 158 + syncServerStatusEnabled = buf.readBoolean(), 159 + statsSyncFrequency = buf.readInt(), 160 + sessionSyncFrequency = buf.readInt(), 161 + achievementSyncFrequency = buf.readInt(), 162 + ) 117 163 } 118 164 ) 119 165 }