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
This commit is contained in:
iceiix 2019-05-11 18:37:33 -07:00 committed by GitHub
parent a081c73215
commit 2451e780bd
1 changed files with 17 additions and 7 deletions

View File

@ -97,7 +97,6 @@ pub enum FmlHs {
ModList {
mods: LenPrefixed<VarInt, ForgeMod>,
},
/* TODO: 1.8+ https://wiki.vg/Minecraft_Forge_Handshake#Differences_from_Forge_1.7.10
RegistryData {
has_more: bool,
name: String,
@ -105,7 +104,6 @@ pub enum FmlHs {
substitutions: LenPrefixed<VarInt, String>,
dummies: LenPrefixed<VarInt, String>,
},
*/
ModIdData {
mappings: LenPrefixed<VarInt, ModIdMapping>,
block_substitutions: LenPrefixed<VarInt, String>,
@ -145,11 +143,23 @@ impl Serializable for FmlHs {
})
},
3 => {
Ok(FmlHs::ModIdData {
mappings: Serializable::read_from(buf)?,
block_substitutions: Serializable::read_from(buf)?,
item_substitutions: Serializable::read_from(buf)?,
})
let protocol_version = unsafe { crate::protocol::CURRENT_PROTOCOL_VERSION };
if protocol_version >= 47 {
Ok(FmlHs::RegistryData {
has_more: Serializable::read_from(buf)?,
name: Serializable::read_from(buf)?,
ids: Serializable::read_from(buf)?,
substitutions: Serializable::read_from(buf)?,
dummies: Serializable::read_from(buf)?,
})
} else {
Ok(FmlHs::ModIdData {
mappings: Serializable::read_from(buf)?,
block_substitutions: Serializable::read_from(buf)?,
item_substitutions: Serializable::read_from(buf)?,
})
}
},
255 => {
Ok(FmlHs::HandshakeAck {