No longer rely on loose error checking and other minor fixes
This commit is contained in:
parent
764c4bc387
commit
f037f0de02
@ -21,7 +21,7 @@ defmodule Amethyst.TCPListener do
|
||||
"""
|
||||
|
||||
def accept(port) do
|
||||
{:ok, socket} = :gen_tcp.listen(port, [:binary, packet: 0, active: false, reuseaddr: true])
|
||||
{:ok, socket} = :gen_tcp.listen(port, [:binary, packet: 0, active: false, reuseaddr: true, nodelay: true])
|
||||
Logger.info("Listening on port #{port}")
|
||||
loop_acceptor(socket)
|
||||
end
|
||||
|
@ -258,6 +258,8 @@ defmodule Amethyst.ConnectionState.Configuration do
|
||||
%{id: "minecraft:stalagmite", data: generic_damage},
|
||||
%{id: "minecraft:outside_border", data: generic_damage},
|
||||
%{id: "minecraft:generic_kill", data: generic_damage},
|
||||
%{id: "minecraft:hot_floor", data: generic_damage},
|
||||
%{id: "minecraft:in_wall", data: generic_damage},
|
||||
]
|
||||
}})
|
||||
send(self(), {:send_packet, %{packet_type: :finish_configuration}})
|
||||
|
@ -70,7 +70,7 @@ defmodule Amethyst.ConnectionState.Login do
|
||||
uuid: player_uuid,
|
||||
username: name,
|
||||
properties: [],
|
||||
strict_error_handling: false
|
||||
strict_error_handling: true
|
||||
}})
|
||||
:ok
|
||||
end
|
||||
|
@ -49,19 +49,28 @@ defmodule Amethyst.ConnectionState.Play do
|
||||
portal_cooldown: :varint,
|
||||
enforces_secure_chat: :bool,
|
||||
]
|
||||
Macros.defpacket_clientbound :synchronize_player_position, 0x40, 747, [
|
||||
Macros.defpacket_clientbound :synchronize_player_position, 0x40, 767, [
|
||||
x: :double,
|
||||
y: :double,
|
||||
z: :double,
|
||||
yaw: :float,
|
||||
pitch: :double,
|
||||
pitch: :float,
|
||||
flags: :byte,
|
||||
teleport_id: :varint
|
||||
]
|
||||
|
||||
Macros.defpacket_serverbound :confirm_teleportation, 0x00, 747, [teleport_id: :varint]
|
||||
Macros.defpacket_serverbound :confirm_teleportation, 0x00, 767, [teleport_id: :varint]
|
||||
|
||||
def handle(%{packet_type: :confirm_teleportation, teleport_id: id}, 747, state) do
|
||||
@spec handle(
|
||||
%{
|
||||
:packet_type => :confirm_teleportation,
|
||||
:teleport_id => any(),
|
||||
optional(any()) => any()
|
||||
},
|
||||
767,
|
||||
nil | maybe_improper_list() | map()
|
||||
) :: :ok
|
||||
def handle(%{packet_type: :confirm_teleportation, teleport_id: id}, 767, state) do
|
||||
Amethyst.API.Game.accept_teleport(state[:game], id)
|
||||
:ok
|
||||
end
|
||||
|
@ -12,6 +12,11 @@ defmodule Example.Game do
|
||||
def login(from, cfg, refs) do
|
||||
Logger.info("Player logged in from #{inspect(from)}: #{inspect(cfg)}")
|
||||
Logger.info("The refs for this game are #{inspect(refs)}")
|
||||
#send(from, {:send_packet, %{
|
||||
# packet_type: :synchronize_player_position,
|
||||
# x: 0.0, y: 0.0, z: 0.0, yaw: 0.0, pitch: 0.0, flags: 0x00,
|
||||
# teleport_id: 0
|
||||
#}})
|
||||
:accept
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user