Implement player info update packet
This commit is contained in:
parent
f0c2ef80ec
commit
c880ea95f3
@ -95,6 +95,7 @@ defmodule Amethyst.ConnectionState.Macros do
|
|||||||
Enum.reduce(Map.get(packet, name), "", fn item, acc ->
|
Enum.reduce(Map.get(packet, name), "", fn item, acc ->
|
||||||
acc <> write_signature(item, signature)
|
acc <> write_signature(item, signature)
|
||||||
end)
|
end)
|
||||||
|
{:literal, {type, value}} -> acc <> apply(Write, type, [value])
|
||||||
t -> acc <> apply(Write, t, [Map.get(packet, name)])
|
t -> acc <> apply(Write, t, [Map.get(packet, name)])
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
@ -104,7 +105,12 @@ defmodule Amethyst.ConnectionState.Macros do
|
|||||||
try do
|
try do
|
||||||
Enum.all?(signature, fn {name, type} ->
|
Enum.all?(signature, fn {name, type} ->
|
||||||
case Map.get(packet, name, :missing) do
|
case Map.get(packet, name, :missing) do
|
||||||
:missing -> throw {:missing, name}
|
:missing ->
|
||||||
|
if elem(type, 0) == :literal do
|
||||||
|
true
|
||||||
|
else
|
||||||
|
throw {:missing, name}
|
||||||
|
end
|
||||||
value -> case type_matches(value, type) do
|
value -> case type_matches(value, type) do
|
||||||
true -> true
|
true -> true
|
||||||
false -> throw {:mismatch, name, value, type}
|
false -> throw {:mismatch, name, value, type}
|
||||||
|
@ -71,6 +71,58 @@ defmodule Amethyst.ConnectionState.Play do
|
|||||||
portal_cooldown: :varint,
|
portal_cooldown: :varint,
|
||||||
enforces_secure_chat: :bool,
|
enforces_secure_chat: :bool,
|
||||||
]
|
]
|
||||||
|
Macros.defpacket_clientbound :player_info_update_add_player, 0x2E, 767, [
|
||||||
|
actions: {:literal, 0x01},
|
||||||
|
players: {:array, [
|
||||||
|
uuid: :uuid,
|
||||||
|
name: :string,
|
||||||
|
properties: {:array, [
|
||||||
|
name: :string,
|
||||||
|
value: :string,
|
||||||
|
signature: {:optional, :string},
|
||||||
|
]}
|
||||||
|
]}
|
||||||
|
]
|
||||||
|
Macros.defpacket_clientbound :player_info_update_initialize_chat, 0x2E, 767, [
|
||||||
|
actions: {:literal, 0x02},
|
||||||
|
players: {:array, [
|
||||||
|
uuid: :uuid,
|
||||||
|
data: {:optional, {:compound, [
|
||||||
|
chat_session_id: :uuid,
|
||||||
|
public_key_expiry_time: :long,
|
||||||
|
encoded_public_key: :byte_array,
|
||||||
|
public_key_signature: :byte_array
|
||||||
|
]}}
|
||||||
|
]}
|
||||||
|
]
|
||||||
|
Macros.defpacket_clientbound :player_info_update_update_game_mode, 0x2E, 767, [
|
||||||
|
actions: {:literal, 0x04},
|
||||||
|
players: {:array, [
|
||||||
|
uuid: :uuid,
|
||||||
|
gamemode: :varint
|
||||||
|
]}
|
||||||
|
]
|
||||||
|
Macros.defpacket_clientbound :player_info_update_update_listed, 0x2E, 767, [
|
||||||
|
actions: {:literal, 0x08},
|
||||||
|
players: {:array, [
|
||||||
|
uuid: :uuid,
|
||||||
|
listed: :bool
|
||||||
|
]}
|
||||||
|
]
|
||||||
|
Macros.defpacket_clientbound :player_info_update_update_latency, 0x2E, 767, [
|
||||||
|
actions: {:literal, 0x10},
|
||||||
|
players: {:array, [
|
||||||
|
uuid: :uuid,
|
||||||
|
ping: :varint, # Milliseconds
|
||||||
|
]}
|
||||||
|
]
|
||||||
|
Macros.defpacket_clientbound :player_info_update_update_display_name, 0x2E, 767, [
|
||||||
|
actions: {:literal, 0x20},
|
||||||
|
players: {:array, [
|
||||||
|
uuid: :uuid,
|
||||||
|
display_name: {:optional, :nbt}
|
||||||
|
]}
|
||||||
|
]
|
||||||
Macros.defpacket_clientbound :synchronize_player_position, 0x40, 767, [
|
Macros.defpacket_clientbound :synchronize_player_position, 0x40, 767, [
|
||||||
x: :double,
|
x: :double,
|
||||||
y: :double,
|
y: :double,
|
||||||
|
Loading…
Reference in New Issue
Block a user