Render the player's skin when possible
Some checks failed
Build & Test / nix-build (push) Failing after 18s

This commit is contained in:
Kodi Craft 2024-10-06 19:03:12 +02:00
parent 4ecf2d432f
commit c29f95a647
Signed by: kodi
GPG Key ID: 69D9EED60B242822
4 changed files with 24 additions and 14 deletions

View File

@ -310,6 +310,16 @@ defmodule Amethyst.ConnectionState.Configuration do
chunk_z: div(floor(z), 16)
}})
send(self(), {:set_position, {x, y, z}})
send(self(), {:send_packet, %{packet_type: :player_info_update_add_player,
players: [
%{
uuid: Map.get(state, :uuid),
name: Map.get(state, :name),
properties: Map.get(state, :properties) |>
Enum.map(fn prop -> %{name: prop["name"], value: prop["value"], signature: Map.get(prop, "signature")} end)
}
]
}})
# Begin keepalive loop
# TODO: Put it under some supervisor
me = self()

View File

@ -130,7 +130,7 @@ defmodule Amethyst.ConnectionState.Login do
Enum.map(fn prop -> %{name: prop["name"], value: prop["value"], signature: Map.get(prop, "signature")} end),
strict_error_handling: true
}})
Map.put(state, :authenticated, true)
Map.put(state, :authenticated, true) |> Map.put(:uuid, uuid) |> Map.put(:name, response["name"]) |> Map.put(:properties, response["properties"])
end
else
raise RuntimeError, "Invalid verify token. Broken encryption?"

View File

@ -95,7 +95,7 @@ defmodule Amethyst.ConnectionState.Macros do
Enum.reduce(Map.get(packet, name), "", fn item, acc ->
acc <> write_signature(item, signature)
end)
{:literal, {type, value}} -> acc <> apply(Write, type, [value])
{:literal, type, value} -> acc <> apply(Write, type, [value])
t -> acc <> apply(Write, t, [Map.get(packet, name)])
end
end)

View File

@ -71,8 +71,8 @@ defmodule Amethyst.ConnectionState.Play do
portal_cooldown: :varint,
enforces_secure_chat: :bool,
]
Macros.defpacket_clientbound :player_info_update_add_player, 0x2E, 767, [
actions: {:literal, 0x01},
Macros.defpacket_clientbound :player_info_update_add_player, 0x3E, 767, [
actions: {:literal, :byte, 0x01},
players: {:array, [
uuid: :uuid,
name: :string,
@ -83,8 +83,8 @@ defmodule Amethyst.ConnectionState.Play do
]}
]}
]
Macros.defpacket_clientbound :player_info_update_initialize_chat, 0x2E, 767, [
actions: {:literal, 0x02},
Macros.defpacket_clientbound :player_info_update_initialize_chat, 0x3E, 767, [
actions: {:literal, :byte, 0x02},
players: {:array, [
uuid: :uuid,
data: {:optional, {:compound, [
@ -95,29 +95,29 @@ defmodule Amethyst.ConnectionState.Play do
]}}
]}
]
Macros.defpacket_clientbound :player_info_update_update_game_mode, 0x2E, 767, [
actions: {:literal, 0x04},
Macros.defpacket_clientbound :player_info_update_update_game_mode, 0x3E, 767, [
actions: {:literal, :byte, 0x04},
players: {:array, [
uuid: :uuid,
gamemode: :varint
]}
]
Macros.defpacket_clientbound :player_info_update_update_listed, 0x2E, 767, [
actions: {:literal, 0x08},
Macros.defpacket_clientbound :player_info_update_update_listed, 0x3E, 767, [
actions: {:literal, :byte, 0x08},
players: {:array, [
uuid: :uuid,
listed: :bool
]}
]
Macros.defpacket_clientbound :player_info_update_update_latency, 0x2E, 767, [
actions: {:literal, 0x10},
Macros.defpacket_clientbound :player_info_update_update_latency, 0x3E, 767, [
actions: {:literal, :byte, 0x10},
players: {:array, [
uuid: :uuid,
ping: :varint, # Milliseconds
]}
]
Macros.defpacket_clientbound :player_info_update_update_display_name, 0x2E, 767, [
actions: {:literal, 0x20},
Macros.defpacket_clientbound :player_info_update_update_display_name, 0x3E, 767, [
actions: {:literal, :byte, 0x20},
players: {:array, [
uuid: :uuid,
display_name: {:optional, :nbt}