more work on sending map
All checks were successful
Build & Test / nix-build (push) Successful in 2m39s
Build & Test / nix-build (pull_request) Successful in 2m40s

This commit is contained in:
Kodi Craft 2024-10-01 20:01:14 +02:00
parent 40792b8d94
commit c3c3f83286
Signed by: kodi
GPG Key ID: 69D9EED60B242822

View File

@ -120,13 +120,27 @@ defmodule Amethyst.ConnectionHandler do
end end
defp process_chunk(chunk, state) do defp process_chunk(chunk, state) do
import Amethyst.NBT.Write
alias Amethyst.Minecraft.Write
chunk_array = Amethyst.API.Game.chunk(Map.get(state, :game), chunk) chunk_array = Amethyst.API.Game.chunk(Map.get(state, :game), chunk)
# TODO: Actually do heightmaps # TODO: Actually do heightmaps
import Amethyst.NBT.Write
heightmaps = compound(%{}) heightmaps = compound(%{})
data = Enum.chunk_every(chunk_array, 16, 16, 0) # 0 -> air data = Enum.chunk_every(chunk_array, 16, 16, 0) # 0 -> air
|> Enum.reduce(fn chunk_section, acc ->
blocks = chunk_section |> List.flatten()
block_count = blocks
|> Enum.map(&(if &1 == 0, do: 0, else: 1))
|> Enum.sum()
# TODO: Proper paletting
acc <> Write.short(block_count) <> Write.ubyte(15)
end)
# TODO: Use paletting
end end
defp handle_packet(id, data, connstate, version, state) do defp handle_packet(id, data, connstate, version, state) do