No longer rely on loose error checking and other minor fixes
All checks were successful
Build & Test / nix-build (push) Successful in 2m42s
Build & Test / nix-build (pull_request) Successful in 2m45s

This commit is contained in:
Kodi Craft 2024-09-19 15:11:59 +02:00
parent 764c4bc387
commit f037f0de02
Signed by: kodi
GPG Key ID: 69D9EED60B242822
5 changed files with 22 additions and 6 deletions

View File

@ -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

View File

@ -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}})

View File

@ -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

View File

@ -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

View File

@ -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