1.14.3 protocol support (490) (#194)

* Copy v1_14_3 from v1_14_2

* Add protocol 490 for v1_14_3

* Add missing 1.14 release TradeList packet fields

TradeList only had fields from the prerelease:
19w02a (452): https://wiki.vg/index.php?title=Pre-release_protocol&oldid=14515#Trade_List

add the six missing fields present in the 1.14 release:
1.14 (477): https://wiki.vg/index.php?title=Pre-release_protocol&oldid=14752#Trade_List

Note this breaks 19w02a TradeList parsing, can be fixed by splitting the
packet for 19w02a/1.14 if needed later.

* Add TradeList_WithRestock variant with new can_restock field
This commit is contained in:
iceiix 2019-07-07 14:58:49 -07:00 committed by GitHub
parent 2a3be38407
commit 95a9920cb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 206 additions and 6 deletions

View File

@ -23,6 +23,7 @@ Join with your favorite IRC client or [Matrix](https://matrix.to/#/#_espernet_#s
| Game version | Protocol version | Supported? |
| ------ | --- | --- |
| 1.14.3 | 490 | ✓ |
| 1.14.2 | 485 | ✓ |
| 1.14.1 | 480 | ✓ |
| 1.14 | 477 | ✓ |

View File

@ -42,7 +42,7 @@ use std::time::{Instant, Duration};
use crate::shared::Position;
use log::debug;
pub const SUPPORTED_PROTOCOLS: [i32; 15] = [485, 480, 477, 452, 451, 404, 340, 316, 315, 210, 109, 107, 74, 47, 5];
pub const SUPPORTED_PROTOCOLS: [i32; 16] = [490, 485, 480, 477, 452, 451, 404, 340, 316, 315, 210, 109, 107, 74, 47, 5];
// TODO: switch to using thread_local storage?, see https://doc.rust-lang.org/std/macro.thread_local.html
pub static mut CURRENT_PROTOCOL_VERSION: i32 = SUPPORTED_PROTOCOLS[0];

View File

@ -1760,9 +1760,20 @@ state_packets!(
field empty_sky_light_mask: VarInt =,
field light_arrays: Vec<u8> =,
}
packet TradeList {
packet TradeList_WithoutRestock {
field id: VarInt =,
field trades: LenPrefixed<u8, packet::Trade> =,
field villager_level: VarInt =,
field experience: VarInt =,
field is_regular_villager: bool =,
}
packet TradeList_WithRestock {
field id: VarInt =,
field trades: LenPrefixed<u8, packet::Trade> =,
field villager_level: VarInt =,
field experience: VarInt =,
field is_regular_villager: bool =,
field can_restock: bool =,
}
packet CoFHLib_SendUUID {
field player_uuid: UUID =,
@ -2611,6 +2622,9 @@ pub struct Trade {
pub trades_disabled: bool,
pub tool_uses: i32,
pub max_trade_uses: i32,
pub xp: i32,
pub special_price: i32,
pub price_multiplier: f32,
}
impl Serializable for Trade {
@ -2623,6 +2637,9 @@ impl Serializable for Trade {
trades_disabled: Serializable::read_from(buf)?,
tool_uses: Serializable::read_from(buf)?,
max_trade_uses: Serializable::read_from(buf)?,
xp: Serializable::read_from(buf)?,
special_price: Serializable::read_from(buf)?,
price_multiplier: Serializable::read_from(buf)?,
})
}

View File

@ -1,5 +1,6 @@
use super::*;
mod v1_14_3;
mod v1_14_2;
mod v1_14_1;
mod v1_14;
@ -21,6 +22,7 @@ mod v1_7_10;
pub fn protocol_name_to_protocol_version(s: String) -> i32 {
match s.as_ref() {
"" => SUPPORTED_PROTOCOLS[0],
"1.14.3" => 490,
"1.14.2" => 485,
"1.14.1" => 480,
"1.14" => 477,
@ -48,6 +50,7 @@ pub fn protocol_name_to_protocol_version(s: String) -> i32 {
pub fn translate_internal_packet_id_for_version(version: i32, state: State, dir: Direction, id: i32, to_internal: bool) -> i32 {
match version {
490 => v1_14_3::translate_internal_packet_id(state, dir, id, to_internal),
485 => v1_14_2::translate_internal_packet_id(state, dir, id, to_internal),
480 => v1_14_1::translate_internal_packet_id(state, dir, id, to_internal),
477 => v1_14::translate_internal_packet_id(state, dir, id, to_internal),

View File

@ -142,7 +142,7 @@ protocol_packet_ids!(
0x57 => TagsWithEntities
0x58 => UpdateLight
0x59 => WindowOpen_VarInt
0x5a => TradeList
0x5a => TradeList_WithoutRestock // TODO: without 1.14 added fields
}
}
login Login {

View File

@ -95,7 +95,7 @@ protocol_packet_ids!(
0x24 => UpdateLight
0x25 => JoinGame_i32_ViewDistance
0x26 => Maps
0x27 => TradeList
0x27 => TradeList_WithoutRestock
0x28 => EntityMove_i16
0x29 => EntityLookAndMove_i16
0x2a => EntityLook_VarInt

View File

@ -95,7 +95,7 @@ protocol_packet_ids!(
0x24 => UpdateLight
0x25 => JoinGame_i32_ViewDistance
0x26 => Maps
0x27 => TradeList
0x27 => TradeList_WithoutRestock
0x28 => EntityMove_i16
0x29 => EntityLookAndMove_i16
0x2a => EntityLook_VarInt

View File

@ -95,7 +95,7 @@ protocol_packet_ids!(
0x24 => UpdateLight
0x25 => JoinGame_i32_ViewDistance
0x26 => Maps
0x27 => TradeList
0x27 => TradeList_WithoutRestock
0x28 => EntityMove_i16
0x29 => EntityLookAndMove_i16
0x2a => EntityLook_VarInt

View File

@ -0,0 +1,179 @@
protocol_packet_ids!(
handshake Handshaking {
serverbound Serverbound {
0x00 => Handshake
}
clientbound Clientbound {
}
}
play Play {
serverbound Serverbound {
0x00 => TeleportConfirm
0x01 => QueryBlockNBT
0x02 => SetDifficulty
0x03 => ChatMessage
0x04 => ClientStatus
0x05 => ClientSettings
0x06 => TabComplete
0x07 => ConfirmTransactionServerbound
0x08 => ClickWindowButton
0x09 => ClickWindow
0x0a => CloseWindow
0x0b => PluginMessageServerbound
0x0c => EditBook
0x0d => QueryEntityNBT
0x0e => UseEntity
0x0f => KeepAliveServerbound_i64
0x10 => LockDifficulty
0x11 => PlayerPosition
0x12 => PlayerPositionLook
0x13 => PlayerLook
0x14 => Player
0x15 => VehicleMove
0x16 => SteerBoat
0x17 => PickItem
0x18 => CraftRecipeRequest
0x19 => ClientAbilities
0x1a => PlayerDigging
0x1b => PlayerAction
0x1c => SteerVehicle
0x1d => CraftingBookData
0x1e => NameItem
0x1f => ResourcePackStatus
0x20 => AdvancementTab
0x21 => SelectTrade
0x22 => SetBeaconEffect
0x23 => HeldItemChange
0x24 => UpdateCommandBlock
0x25 => UpdateCommandBlockMinecart
0x26 => CreativeInventoryAction
0x27 => UpdateJigsawBlock
0x28 => UpdateStructureBlock
0x29 => SetSign
0x2a => ArmSwing
0x2b => SpectateTeleport
0x2c => PlayerBlockPlacement_f32
0x2d => UseItem
}
clientbound Clientbound {
0x00 => SpawnObject
0x01 => SpawnExperienceOrb
0x02 => SpawnGlobalEntity
0x03 => SpawnMob
0x04 => SpawnPainting
0x05 => SpawnPlayer_f64
0x06 => Animation
0x07 => Statistics
0x08 => BlockBreakAnimation
0x09 => UpdateBlockEntity
0x0a => BlockAction
0x0b => BlockChange_VarInt
0x0c => BossBar
0x0d => ServerDifficulty_Locked
0x0e => ServerMessage
0x0f => MultiBlockChange_VarInt
0x10 => TabCompleteReply
0x11 => DeclareCommands
0x12 => ConfirmTransaction
0x13 => WindowClose
0x14 => WindowItems
0x15 => WindowProperty
0x16 => WindowSetSlot
0x17 => SetCooldown
0x18 => PluginMessageClientbound
0x19 => NamedSoundEffect
0x1a => Disconnect
0x1b => EntityAction
0x1c => Explosion
0x1d => ChunkUnload
0x1e => ChangeGameState
0x1f => WindowOpenHorse
0x20 => KeepAliveClientbound_i64
0x21 => ChunkData_HeightMap
0x22 => Effect
0x23 => Particle_Data
0x24 => UpdateLight
0x25 => JoinGame_i32_ViewDistance
0x26 => Maps
0x27 => TradeList_WithRestock
0x28 => EntityMove_i16
0x29 => EntityLookAndMove_i16
0x2a => EntityLook_VarInt
0x2b => Entity
0x2c => VehicleTeleport
0x2d => OpenBook
0x2e => WindowOpen_VarInt
0x2f => SignEditorOpen
0x30 => CraftRecipeResponse
0x31 => PlayerAbilities
0x32 => CombatEvent
0x33 => PlayerInfo
0x34 => FacePlayer
0x35 => TeleportPlayer_WithConfirm
0x36 => UnlockRecipes_WithSmelting
0x37 => EntityDestroy
0x38 => EntityRemoveEffect
0x39 => ResourcePackSend
0x3a => Respawn
0x3b => EntityHeadLook
0x3c => SelectAdvancementTab
0x3d => WorldBorder
0x3e => Camera
0x3f => SetCurrentHotbarSlot
0x40 => UpdateViewPosition
0x41 => UpdateViewDistance
0x42 => ScoreboardDisplay
0x43 => EntityMetadata
0x44 => EntityAttach
0x45 => EntityVelocity
0x46 => EntityEquipment
0x47 => SetExperience
0x48 => UpdateHealth
0x49 => ScoreboardObjective
0x4a => SetPassengers
0x4b => Teams
0x4c => UpdateScore
0x4d => SpawnPosition
0x4e => TimeUpdate
0x4f => Title
0x50 => EntitySoundEffect
0x51 => SoundEffect
0x52 => StopSound
0x53 => PlayerListHeaderFooter
0x54 => NBTQueryResponse
0x55 => CollectItem
0x56 => EntityTeleport_f64
0x57 => Advancements
0x58 => EntityProperties
0x59 => EntityEffect
0x5a => DeclareRecipes
0x5b => TagsWithEntities
}
}
login Login {
serverbound Serverbound {
0x00 => LoginStart
0x01 => EncryptionResponse
0x02 => LoginPluginResponse
}
clientbound Clientbound {
0x00 => LoginDisconnect
0x01 => EncryptionRequest
0x02 => LoginSuccess
0x03 => SetInitialCompression
0x04 => LoginPluginRequest
}
}
status Status {
serverbound Serverbound {
0x00 => StatusRequest
0x01 => StatusPing
}
clientbound Clientbound {
0x00 => StatusResponse
0x01 => StatusPong
}
}
);