Implement handling confirm_teleportation
This commit is contained in:
parent
0fdc00148e
commit
53fe25043d
@ -64,6 +64,9 @@ defmodule Amethyst.ConnectionHandler do
|
|||||||
Logger.debug("Sending packet #{inspect(packet)}")
|
Logger.debug("Sending packet #{inspect(packet)}")
|
||||||
send_packet(socket, connstate, packet, version)
|
send_packet(socket, connstate, packet, version)
|
||||||
loop(socket, connstate, version, state)
|
loop(socket, connstate, version, state)
|
||||||
|
{:tp_done, id} ->
|
||||||
|
# TODO: Implement a proper teleportation API
|
||||||
|
Logger.debug("Accepted teleportation #{inspect(id)}")
|
||||||
after 0 ->
|
after 0 ->
|
||||||
receive do
|
receive do
|
||||||
{:packet, id, data} ->
|
{:packet, id, data} ->
|
||||||
|
@ -49,6 +49,28 @@ defmodule Amethyst.ConnectionState.Play do
|
|||||||
portal_cooldown: :varint,
|
portal_cooldown: :varint,
|
||||||
enforces_secure_chat: :bool,
|
enforces_secure_chat: :bool,
|
||||||
]
|
]
|
||||||
|
Macros.defpacket_clientbound :synchronize_player_position, 0x40, 747, [
|
||||||
|
x: :double,
|
||||||
|
y: :double,
|
||||||
|
z: :double,
|
||||||
|
yaw: :float,
|
||||||
|
pitch: :double,
|
||||||
|
flags: :byte,
|
||||||
|
teleport_id: :varint
|
||||||
|
]
|
||||||
|
|
||||||
|
Macros.defpacket_serverbound :confirm_teleportation, 0x00, 747, [teleport_id: :varint]
|
||||||
|
|
||||||
|
def handle(%{packet_type: :confirm_teleportation, teleport_id: id}, 747, state) do
|
||||||
|
if state[:teleport_id] == id do
|
||||||
|
# The client has accepted our teleportation, we can let the connection process know
|
||||||
|
send(self(), {:tp_done, id})
|
||||||
|
state |> Map.put(:teleport_id, nil)
|
||||||
|
else
|
||||||
|
# The client has not yet accepted our teleportation, we aren't done yet
|
||||||
|
state
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def disconnect(reason) do
|
def disconnect(reason) do
|
||||||
%{
|
%{
|
||||||
|
Loading…
Reference in New Issue
Block a user