Skip to content

Commit 2451e78

Browse files
authored
Forge 1.8.9-1.12.2 handshake protocol support (#144)
Adds support for connecting to Forge servers from 1.8.9 up to 1.12.2. (1.7.10 was already supported with #134 #88) Tested on: - 1.8.9 + forge 11.15.1.2318 + ironchest - 1.10.2 + forge 12.18.3.2511 + ironchest - 1.11.2 + forge 13.20.1.2588 + ironchest - 1.12.2 + forge 14.23.5.2837 + ironchest Changes: * Parse and handle FmlHs::RegistryData packet for 1.8+ * Fix RegistryData acknowledgement phase WaitingServerComplete * Fix acknowledgement phase for 1.7.10 ModIdData too, somehow it worked accidentally * Append \0FML\0 to end of server hostname if Forge mods detected https://wiki.vg/Minecraft_Forge_Handshake#Connection_to_a_forge_server
1 parent a081c73 commit 2451e78

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

protocol/src/protocol/forge.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,13 @@ pub enum FmlHs {
9797
ModList {
9898
mods: LenPrefixed<VarInt, ForgeMod>,
9999
},
100-
/* TODO: 1.8+ https://wiki.vg/Minecraft_Forge_Handshake#Differences_from_Forge_1.7.10
101100
RegistryData {
102101
has_more: bool,
103102
name: String,
104103
ids: LenPrefixed<VarInt, ModIdMapping>,
105104
substitutions: LenPrefixed<VarInt, String>,
106105
dummies: LenPrefixed<VarInt, String>,
107106
},
108-
*/
109107
ModIdData {
110108
mappings: LenPrefixed<VarInt, ModIdMapping>,
111109
block_substitutions: LenPrefixed<VarInt, String>,
@@ -145,11 +143,23 @@ impl Serializable for FmlHs {
145143
})
146144
},
147145
3 => {
148-
Ok(FmlHs::ModIdData {
149-
mappings: Serializable::read_from(buf)?,
150-
block_substitutions: Serializable::read_from(buf)?,
151-
item_substitutions: Serializable::read_from(buf)?,
152-
})
146+
let protocol_version = unsafe { crate::protocol::CURRENT_PROTOCOL_VERSION };
147+
148+
if protocol_version >= 47 {
149+
Ok(FmlHs::RegistryData {
150+
has_more: Serializable::read_from(buf)?,
151+
name: Serializable::read_from(buf)?,
152+
ids: Serializable::read_from(buf)?,
153+
substitutions: Serializable::read_from(buf)?,
154+
dummies: Serializable::read_from(buf)?,
155+
})
156+
} else {
157+
Ok(FmlHs::ModIdData {
158+
mappings: Serializable::read_from(buf)?,
159+
block_substitutions: Serializable::read_from(buf)?,
160+
item_substitutions: Serializable::read_from(buf)?,
161+
})
162+
}
153163
},
154164
255 => {
155165
Ok(FmlHs::HandshakeAck {

0 commit comments

Comments
 (0)