Mildly improve readability
All checks were successful
Build & Test / nix-build (push) Successful in 1m13s

This commit is contained in:
Kodi Craft 2024-08-04 08:55:19 +02:00
parent 7348ed5d28
commit 1cfb5384dc
Signed by: kodi
GPG Key ID: 69D9EED60B242822

View File

@ -46,15 +46,26 @@ defmodule Amethyst.Server.Play do
is_debug, is_flat, death_loc, portal_cooldown, enforce_chat}) when byte_size(hashed_seed) == 8 do is_debug, is_flat, death_loc, portal_cooldown, enforce_chat}) when byte_size(hashed_seed) == 8 do
# TODO: This is a big unreadable slab of serialization which makes bugs really hard to catch, it needs a proper rework at some point # TODO: This is a big unreadable slab of serialization which makes bugs really hard to catch, it needs a proper rework at some point
Write.varint(0x2B) <> Write.varint(0x2B) <>
Write.int(eid) <> Write.bool(hardcore) <> Write.int(eid) <>
Write.varint(length(dimensions)) <> Write.list(dimensions, &Write.string/1) <> Write.bool(hardcore) <>
Write.varint(max_players) <> Write.varint(view_distance) <> Write.varint(simulation_distance) <> Write.bool(reduce_debug) <> Write.varint(length(dimensions)) <>
Write.list(dimensions, &Write.string/1) <>
Write.varint(max_players) <>
Write.varint(view_distance) <>
Write.varint(simulation_distance) <>
Write.bool(reduce_debug) <>
Write.bool(enable_respawn_screen) <> Write.bool(enable_respawn_screen) <>
Write.bool(limited_crafting) <> Write.varint(dim_type) <> Write.string(dim_name) <> Write.bool(limited_crafting) <>
hashed_seed <> Write.ubyte(gamemode_id(gamemode)) <> Write.byte(gamemode_id(prev_gm)) <> Write.varint(dim_type) <>
Write.bool(is_debug) <> Write.bool(is_flat) <> Write.string(dim_name) <>
if(death_loc == nil, do: <<0::big-8>>, else: <<1::big-8>> <> Write.string(elem(death_loc, 0)) <> Write.position(elem(death_loc, 1))) <> hashed_seed <>
Write.varint(portal_cooldown) <> Write.bool(enforce_chat) Write.ubyte(gamemode_id(gamemode)) <>
Write.byte(gamemode_id(prev_gm)) <>
Write.bool(is_debug) <>
Write.bool(is_flat) <>
if(death_loc == nil, do: Write.bool(false), else: Write.bool(true) <> Write.string(elem(death_loc, 0)) <> Write.position(elem(death_loc, 1))) <>
Write.varint(portal_cooldown) <>
Write.bool(enforce_chat)
end end
def serialize(packet) do def serialize(packet) do
raise ArgumentError, "Tried serializing unknown packet #{inspect(packet)}" raise ArgumentError, "Tried serializing unknown packet #{inspect(packet)}"