more work on sending map
This commit is contained in:
parent
40792b8d94
commit
c3c3f83286
@ -120,13 +120,27 @@ defmodule Amethyst.ConnectionHandler do
|
||||
end
|
||||
|
||||
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)
|
||||
|
||||
# TODO: Actually do heightmaps
|
||||
import Amethyst.NBT.Write
|
||||
heightmaps = compound(%{})
|
||||
|
||||
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
|
||||
|
||||
defp handle_packet(id, data, connstate, version, state) do
|
||||
|
Loading…
Reference in New Issue
Block a user