diff --git a/apps/amethyst/lib/states/configuration.ex b/apps/amethyst/lib/states/configuration.ex index a8bb380..5c38294 100644 --- a/apps/amethyst/lib/states/configuration.ex +++ b/apps/amethyst/lib/states/configuration.ex @@ -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() diff --git a/apps/amethyst/lib/states/login.ex b/apps/amethyst/lib/states/login.ex index de0aeb3..14f005b 100644 --- a/apps/amethyst/lib/states/login.ex +++ b/apps/amethyst/lib/states/login.ex @@ -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?" diff --git a/apps/amethyst/lib/states/macros.ex b/apps/amethyst/lib/states/macros.ex index 5f7a134..a21ce1f 100644 --- a/apps/amethyst/lib/states/macros.ex +++ b/apps/amethyst/lib/states/macros.ex @@ -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) diff --git a/apps/amethyst/lib/states/play.ex b/apps/amethyst/lib/states/play.ex index 69d70d7..b1730e7 100644 --- a/apps/amethyst/lib/states/play.ex +++ b/apps/amethyst/lib/states/play.ex @@ -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}