Implement Mojang authentication #4
@ -310,6 +310,16 @@ defmodule Amethyst.ConnectionState.Configuration do
|
|||||||
chunk_z: div(floor(z), 16)
|
chunk_z: div(floor(z), 16)
|
||||||
}})
|
}})
|
||||||
send(self(), {:set_position, {x, y, z}})
|
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
|
# Begin keepalive loop
|
||||||
# TODO: Put it under some supervisor
|
# TODO: Put it under some supervisor
|
||||||
me = self()
|
me = self()
|
||||||
|
@ -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),
|
Enum.map(fn prop -> %{name: prop["name"], value: prop["value"], signature: Map.get(prop, "signature")} end),
|
||||||
strict_error_handling: true
|
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
|
end
|
||||||
else
|
else
|
||||||
raise RuntimeError, "Invalid verify token. Broken encryption?"
|
raise RuntimeError, "Invalid verify token. Broken encryption?"
|
||||||
|
@ -95,7 +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])
|
{: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)
|
||||||
|
@ -71,8 +71,8 @@ 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, [
|
Macros.defpacket_clientbound :player_info_update_add_player, 0x3E, 767, [
|
||||||
actions: {:literal, 0x01},
|
actions: {:literal, :byte, 0x01},
|
||||||
players: {:array, [
|
players: {:array, [
|
||||||
uuid: :uuid,
|
uuid: :uuid,
|
||||||
name: :string,
|
name: :string,
|
||||||
@ -83,8 +83,8 @@ defmodule Amethyst.ConnectionState.Play do
|
|||||||
]}
|
]}
|
||||||
]}
|
]}
|
||||||
]
|
]
|
||||||
Macros.defpacket_clientbound :player_info_update_initialize_chat, 0x2E, 767, [
|
Macros.defpacket_clientbound :player_info_update_initialize_chat, 0x3E, 767, [
|
||||||
actions: {:literal, 0x02},
|
actions: {:literal, :byte, 0x02},
|
||||||
players: {:array, [
|
players: {:array, [
|
||||||
uuid: :uuid,
|
uuid: :uuid,
|
||||||
data: {:optional, {:compound, [
|
data: {:optional, {:compound, [
|
||||||
@ -95,29 +95,29 @@ defmodule Amethyst.ConnectionState.Play do
|
|||||||
]}}
|
]}}
|
||||||
]}
|
]}
|
||||||
]
|
]
|
||||||
Macros.defpacket_clientbound :player_info_update_update_game_mode, 0x2E, 767, [
|
Macros.defpacket_clientbound :player_info_update_update_game_mode, 0x3E, 767, [
|
||||||
actions: {:literal, 0x04},
|
actions: {:literal, :byte, 0x04},
|
||||||
players: {:array, [
|
players: {:array, [
|
||||||
uuid: :uuid,
|
uuid: :uuid,
|
||||||
gamemode: :varint
|
gamemode: :varint
|
||||||
]}
|
]}
|
||||||
]
|
]
|
||||||
Macros.defpacket_clientbound :player_info_update_update_listed, 0x2E, 767, [
|
Macros.defpacket_clientbound :player_info_update_update_listed, 0x3E, 767, [
|
||||||
actions: {:literal, 0x08},
|
actions: {:literal, :byte, 0x08},
|
||||||
players: {:array, [
|
players: {:array, [
|
||||||
uuid: :uuid,
|
uuid: :uuid,
|
||||||
listed: :bool
|
listed: :bool
|
||||||
]}
|
]}
|
||||||
]
|
]
|
||||||
Macros.defpacket_clientbound :player_info_update_update_latency, 0x2E, 767, [
|
Macros.defpacket_clientbound :player_info_update_update_latency, 0x3E, 767, [
|
||||||
actions: {:literal, 0x10},
|
actions: {:literal, :byte, 0x10},
|
||||||
players: {:array, [
|
players: {:array, [
|
||||||
uuid: :uuid,
|
uuid: :uuid,
|
||||||
ping: :varint, # Milliseconds
|
ping: :varint, # Milliseconds
|
||||||
]}
|
]}
|
||||||
]
|
]
|
||||||
Macros.defpacket_clientbound :player_info_update_update_display_name, 0x2E, 767, [
|
Macros.defpacket_clientbound :player_info_update_update_display_name, 0x3E, 767, [
|
||||||
actions: {:literal, 0x20},
|
actions: {:literal, :byte, 0x20},
|
||||||
players: {:array, [
|
players: {:array, [
|
||||||
uuid: :uuid,
|
uuid: :uuid,
|
||||||
display_name: {:optional, :nbt}
|
display_name: {:optional, :nbt}
|
||||||
|
Loading…
Reference in New Issue
Block a user