Properly implement light... I think
All checks were successful
Build & Test / nix-build (push) Successful in 1m47s
All checks were successful
Build & Test / nix-build (push) Successful in 1m47s
This commit is contained in:
parent
b44784e9ef
commit
c2cbfdf888
@ -220,6 +220,7 @@ defmodule Amethyst.ConnectionHandler do
|
||||
block_light_array = non_empty_block_light_sections |> Enum.map(&(Enum.reduce(&1, <<>>, fn light, acc ->
|
||||
<<acc::bitstring, light::size(4)>>
|
||||
end)))
|
||||
Logger.debug("#{length(block_light_array)} block light sections to send")
|
||||
|
||||
send(to, {:send_packet, %{
|
||||
packet_type: :chunk_data_and_update_light,
|
||||
|
@ -142,14 +142,12 @@ defmodule Amethyst.Minecraft.Write do
|
||||
end
|
||||
|
||||
def bitset(list) do
|
||||
Logger.debug("Writing bitset #{inspect(list)}")
|
||||
unaligned = Enum.reduce(list, <<>>, &(if &1 do <<&2::bitstring, 1::1>> else <<&2::bitstring, 0::1>> end))
|
||||
aligned = if rem(bit_size(unaligned), 64) == 0 do
|
||||
unaligned
|
||||
else
|
||||
<<unaligned::bitstring, 0::size(64 - rem(bit_size(unaligned), 64))>>
|
||||
<<0::size(64 - rem(bit_size(unaligned), 64)), unaligned::bitstring>>
|
||||
end
|
||||
Logger.debug("Writing as #{inspect(aligned)}")
|
||||
varint(div(byte_size(aligned), 8)) <> aligned
|
||||
end
|
||||
end
|
||||
|
@ -50,9 +50,9 @@ defmodule Example.Game do
|
||||
gz = cz * 16 + z
|
||||
gy = y
|
||||
if rem(gx, 4) == 0 && rem(gy, 4) == 0 && rem(gz, 4) == 0 do
|
||||
{abs(rem(div(gx + gy + gz, 4), 1000)), 15, 0}
|
||||
{abs(rem(div(gx + gy + gz, 4), 1000)), 15, 15}
|
||||
else
|
||||
{0, 15, 0}
|
||||
{0, 15, 15}
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user