aboutsummaryrefslogtreecommitdiff
path: root/src/v1_19_3.rs
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-02-03 12:56:44 +0100
committernea <nea@nea.moe>2023-02-03 12:56:44 +0100
commitf9835f4c382a07bab36a4b156e332e1c0c3b371c (patch)
tree2b15f23b34d069ad3fa4af4769dd1218d4612ba1 /src/v1_19_3.rs
parent2572b329cc18a0413dea19297bab805be2b9f2ab (diff)
downloadmcproto-rs-f9835f4c382a07bab36a4b156e332e1c0c3b371c.tar.gz
mcproto-rs-f9835f4c382a07bab36a4b156e332e1c0c3b371c.tar.bz2
mcproto-rs-f9835f4c382a07bab36a4b156e332e1c0c3b371c.zip
wip
Diffstat (limited to 'src/v1_19_3.rs')
-rw-r--r--src/v1_19_3.rs349
1 files changed, 349 insertions, 0 deletions
diff --git a/src/v1_19_3.rs b/src/v1_19_3.rs
new file mode 100644
index 0000000..ee51d04
--- /dev/null
+++ b/src/v1_19_3.rs
@@ -0,0 +1,349 @@
+use alloc::{
+ borrow::ToOwned,
+ string::{String, ToString},
+ vec::Vec,
+};
+use alloc::fmt;
+use fmt::Debug;
+
+use crate::{*, types::*, uuid::*};
+pub use crate::v1_19::CommandNode;
+#[cfg(all(test, feature = "std"))]
+use crate::protocol::TestRandom;
+
+define_protocol!(760, Packet760, RawPacket760, RawPacket760Body, Packet760Kind => {
+ // Handshaking
+ Handshake, 0x00, Handshaking, ServerBound => HandshakeSpec {
+ version: VarInt,
+ server_address: String,
+ server_port: u16,
+ next_state: HandshakeNextState
+ },
+
+ // Status - ClientBound
+ StatusRespone, 0x00, Status, ClientBound => StatusResponseSpec {
+ response: super::status::StatusSpec
+ },
+ PingResponse, 0x01, Status, ClientBound => PingResponseSpec {
+ payload: i64
+ },
+
+ // Status - ServerBound
+ StatusRequest, 0x00, Status, ServerBound => StatusRequestSpec {
+ },
+ PingRequest, 0x01, Status, ServerBound => PingRequestSpec {
+ payload: i64
+ },
+
+ // Login - ClientBound
+ DisconnectLogin, 0x00, Login, ClientBound => DisconnectLoginSpec {
+ payloadreason: Chat
+ },
+ EncryptionRequest, 0x01, Login, ClientBound => EncryptionRequestSpec {
+ server_id: String,
+ public_key: CountedArray<u8, VarInt>,
+ verify_token: CountedArray<u8, VarInt>
+ },
+ LoginSuccess, 0x02, Login, ClientBound => LoginSuccessSpec {
+ uuid: UUID4,
+ username: String,
+ properties: CountedArray<LoginProperty, VarInt>
+ },
+ SetCompression, 0x03, Login, ClientBound => SetCompressionSpec {
+ threshold: VarInt
+ },
+ LoginPluginRequest, 0x04, Login, ClientBound => LoginPluginRequestSpec {
+ message_id: VarInt,
+ channel: String,
+ data: RemainingBytes
+ },
+
+ // Login - ServerBound
+ LoginStart, 0x00, Login, ServerBound => LoginStartSpec {
+ name: String,
+ player_uuid: Option<UUID4>
+ },
+ EncryptionResponse, 0x01, Login, ServerBound => EncryptionResponseSpec {
+ shared_secret: CountedArray<u8, VarInt>,
+ verfiy_token: CountedArray<u8, VarInt>
+ },
+ LoginPluginResponse, 0x02, Login, ServerBound => LoginPluginResponseSpec {
+ message_id: VarInt,
+ successful: bool,
+ data: RemainingBytes
+ },
+
+ // Play - ClientBound
+ SpawnEntity, 0x00, Play, ClientBound => SpawnEntitySpec {
+ entity_id: VarInt,
+ entity_uuid: UUID4,
+ entity_type: VarInt, // TODO enumerate mob types
+ position: Vec3<f64>,
+ pitch: Angle,
+ yaw: Angle,
+ data: i32,
+ velocity: Vec3<i16>
+ },
+ SpawnExperienceOrb, 0x01, Play, ClientBound => SpawnExperienceOrbSpec {
+ entity_id: VarInt,
+ position: Vec3<f64>,
+ count: i16
+ },
+ SpawnPlayer, 0x02, Play, ClientBound => SpawnPlayerSpec {
+ entity_id: VarInt,
+ player_uuid: UUID4,
+ position: Vec3<f64>,
+ yaw: Angle,
+ pitch: Angle
+ },
+ EntityAnimation, 0x03, Play, ClientBound => EntityAnimationSpec {
+ entity_id: VarInt,
+ animation: u8 // TODO: enumerate animation id
+ },
+ AwardStatistics, 0x04, Play, ClientBound => AwardStatisticsSpec {
+ statistics: CountedArray<StatisticValue, VarInt>
+ },
+ AcknowledgeBlockChange, 0x05, Play, ClientBound => AcknowledgeBlockChangeSpec {
+ sequence_id: VarInt
+ },
+ SetBlockDestroyStage, 0x06, Play, ClientBound => SetBlockDestroyStageSpec {
+ entity_id: VarInt,
+ location: IntPosition,
+ destroy_stage: u8
+ },
+ BlockEntityData, 0x07, Play, ClientBound => BlockEntityDataSpec {
+ location: IntPosition,
+ block_entity_type: VarInt,
+ nbt_data: NamedNbtTag
+ },
+ BlockAction, 0x08, Play, ClientBound => BlockActionSpec {
+ location: IntPosition,
+ action_id: u8,
+ action_parameter: u8,
+ block_type: VarInt
+ },
+ BlockUpdate, 0x09, Play, ClientBound => BlockUpdateSpec {
+ location: IntPosition,
+ block_id: VarInt
+ },
+ BossBar, 0x0A, Play, ClientBound => BossBarSpec {
+ uuid: UUID4,
+ action: BossBarAction
+ },
+ ChangeDifficulty, 0x0B, Play, ClientBound => ChangeDifficultySpec {
+ difficulty: Difficulty,
+ difficulty_locked: bool
+ },
+ ClearTitles, 0x0C, Play, ClientBound => ClearTitlesSpec {
+ reset: bool
+ },
+ CommandSuggestionResponse, 0x0D, Play, ClientBound => CommandSuggestionResponseSpec {
+ transaction_id: VarInt,
+ start: VarInt,
+ length: VarInt,
+ suggestions: CountedArray<CommandSuggestion, VarInt>
+ },
+ Commands, 0x0E, Play, ClientBound => CommandsSpec {
+ nodes: CountedArray<CommandNode, VarInt>,
+ root_index: VarInt
+ },
+ CloseContainer, 0x0F, Play, ClientBound => CloseContainerSpec {
+ window_id: u8
+ },
+ SetContainerContent, 0x10, Play, ClientBound => SetContainerContentSpec {
+ window_id: u8,
+ state_id: VarInt,
+ slot_data: CountedArray<Slot, VarInt>,
+ carried_item: Slot
+ },
+ SetContainerProperty, 0x11, Play, ClientBound => SetContainerPropertySpec {
+ window_id: u8,
+ property: i16,
+ value: i16
+ },
+ SetContainerSlot, 0x12, Play, ClientBound => SetContainerSlotSpec {
+ window_id: u8,
+ state_id: VarInt,
+ slot_index: i16,
+ slot_data: Slot
+ },
+ SetCooldown, 0x13, Play, ClientBound => SetCooldownSpec {
+ item_id: VarInt,
+ cooldown_ticks: VarInt
+ },
+ ChatSuggestions, 0x14, Play, ClientBound => ChatSuggestionsSpec {
+ action: VarInt,
+ entries: CountedArray<String, VarInt>
+ },
+ PluginMessage, 0x15, Play, ClientBound => PluginMessageSpec {
+ channel: String,
+ data: RemainingBytes
+ },
+ DeleteMessage, 0x16, Play, ClientBound => DeleteMessageSpec {
+ signature: CountedArray<u8, VarInt>
+ },
+ DisconnectPlay, 0x17, Play, ClientBound => DisconnectPlaySpec {
+ reason: Chat
+ },
+ DisguisedChatMessage, 0x18, Play, ClientBound => DisguisedChatMessageSpec {
+ message: Chat,
+ chat_type: VarInt,
+ chat_type_name: Chat,
+ target_name: Option<Chat>
+ },
+ EntityEvent, 0x19, Play, ClientBound => EntityEventSpec {
+ entity_id: i32,
+ entity_status: u8
+ },
+ Explosion, 0x1A, Play, ClientBound => ExplosionSpec {
+ position: Vec3<f64>,
+ strength: f32,
+ affected_blocks: CountedArray<Vec3<i8>, VarInt>,
+ player_motion: Vec3<f32>
+ },
+ UnloadChunk, 0x1B, Play, ClientBound => UnloadChunkSpec {
+ chunk_x: i32,
+ chunk_z: i32
+ },
+ GameEvent, 0x1C, Play, ClientBound => GameEventSpec {
+ event: GameEventType,
+ data: f32
+ },
+ OpenHorseScreen, 0x1D, Play, ClientBound => OpenHorseScreenSpec {
+ window_id: u8,
+ slot_count: VarInt,
+ entity_id: i32
+ },
+ InitializeWorldBorder, 0x1E, Play, ClientBound => InitializeWorldBorderSpec {
+ x: f32,
+ z: f32,
+ old_diameter: f32,
+ new_diameter: f32,
+ speed: VarLong,
+ portal_teleport_boundary: VarInt,
+ warning_blocks: VarInt,
+ warning_time: VarInt
+ },
+ KeepAlive, 0x1f, Play, ClientBound => KeepAliveSpec {
+ keep_alive_id: i64
+ },
+ ChunkDataAndUpdateLight, 0x20, Play, ClientBound => ChunkDataAndUpdateLightSpec {
+ chunk_x: i32,
+ chunk_z: i32,
+ heightmaps: NamedNbtTag,
+ chunk_data: CountedArray<u8, VarInt>,
+ block_entities: CountedArray<BlockEntity, VarInt>,
+ trust_edges: bool // TODO: HEEELP
+ }
+});
+
+
+// Helper types
+
+proto_struct!(BlockEntity {
+ packed_xz: u8,
+ y: i16,
+ block_entity_type: VarInt,
+ data: NamedNbtTag
+});
+proto_byte_enum!(GameEventType,
+ 0 :: NoRespawnBlockAvailable,
+ 1 :: EndRaining,
+ 2 :: BeginRaining,
+ 3 :: ChangeGamemode,
+ 4 :: WinGame,
+ 5 :: DemoEvent,
+ 6 :: ArrowHitPlayer,
+ 7 :: RainLevelChange,
+ 8 :: ThunderLevelChange,
+ 9 :: PlayPufferfishStingSound,
+ 10 :: PlayElderGuardianMobAppearance,
+ 11 :: SetImmediateRespawn
+);
+
+proto_struct!(CommandSuggestion {
+ match_text: String,
+ tooltip: Option<Chat>
+});
+
+proto_byte_enum!(Difficulty,
+ 0 :: Peaceful,
+ 1 :: Easy,
+ 2 :: Normal,
+ 3 :: Hard
+);
+
+proto_byte_enum!(HandshakeNextState,
+ 0x01 :: Status,
+ 0x02 :: Login
+);
+
+proto_struct!(LoginProperty {
+ name: String,
+ value: String,
+ signature: Option<String>
+});
+
+proto_struct!(StatisticValue {
+ category_id: StatisticCategory,
+ statistic_id: VarInt,
+ value: VarInt
+});
+
+proto_varint_enum!(StatisticCategory,
+ 0 :: Mined,
+ 1 :: Crafted,
+ 2 :: Used,
+ 3 :: Broken,
+ 4 :: PickedUp,
+ 5 :: Dropped,
+ 6 :: Killed,
+ 7 :: KilledBy,
+ 8 :: Custom
+);
+
+proto_varint_enum!(BossBarAction,
+ 0 :: Add(BossBarAddSpec),
+ 1 :: Remove,
+ 2 :: UpdateHealth(f32),
+ 3 :: UpdateTitle(Chat),
+ 4 :: UpdateStyle(BossBarUpdateStyleSpec),
+ 5 :: UpdateFlags(BossBarFlags)
+);
+
+proto_struct!(BossBarAddSpec {
+ title: Chat,
+ health: f32,
+ color: BossBarColor,
+ division: BossBarDivision,
+ flags: BossBarFlags
+});
+
+proto_struct!(BossBarUpdateStyleSpec {
+ color: BossBarColor,
+ dividers: BossBarDivision
+});
+
+proto_varint_enum!(BossBarColor,
+ 0 :: Pink,
+ 1 :: Blue,
+ 2 :: Red,
+ 3 :: Green,
+ 4 :: Yellow,
+ 5 :: Purple,
+ 6 :: White
+);
+proto_varint_enum!(BossBarDivison,
+ 0 :: NoDivision,
+ 1 :: SixNotches,
+ 2 :: TenNotches,
+ 3 :: TwelveNotches,
+ 4 :: TwentyNotches
+);
+
+proto_byte_flag!(BossBarFlags,
+ 0x01 :: is_darken_sky set_darken_sky,
+ 0x02 :: is_dragon_bar set_dragon_bar,
+ 0x03 :: is_create_fog set_create_fog
+);
+