begin implementing the second worst packet of this protocol
This commit is contained in:
parent
930a508ad9
commit
034f21ade7
@ -78,7 +78,7 @@ defmodule Amethyst.ConnectionState.Macros do
|
||||
end
|
||||
|
||||
def write_signature(packet, signature) do
|
||||
data = Enum.reduce(signature, "", fn {name, type}, acc ->
|
||||
Enum.reduce(signature, "", fn {name, type}, acc ->
|
||||
#acc <> apply(Write, type, [Map.get(packet, name)])
|
||||
case type do
|
||||
{:optional, {:compound, signature}} ->
|
||||
@ -145,7 +145,7 @@ defmodule Amethyst.ConnectionState.Macros do
|
||||
_ -> false
|
||||
end
|
||||
end
|
||||
def type_matches(value, {:optional, type}) when is_nil(value), do: true
|
||||
def type_matches(value, {:optional, _type}) when is_nil(value), do: true
|
||||
def type_matches(value, {:optional, type}), do: type_matches(value, type)
|
||||
def type_matches(value, {:array, signature}) when is_list(value), do: Enum.all?(value, fn item -> check_type(item, signature) end)
|
||||
def type_matches(value, {:compound, signature}) when is_map(value), do: check_type(value, signature)
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
defmodule Amethyst.ConnectionState.Play do
|
||||
require Amethyst.ConnectionState.Macros
|
||||
alias Amethyst.Minecraft.Write
|
||||
alias Amethyst.ConnectionState.Macros
|
||||
|
||||
require Logger
|
||||
@ -79,6 +80,19 @@ defmodule Amethyst.ConnectionState.Play do
|
||||
pitch: :float,
|
||||
on_ground: :bool # I don't understand their obsession with this...
|
||||
]
|
||||
# this packet sucks, thoughtful design is for losers anyway
|
||||
def serialize(%{packet_type: :game_event, event: :no_respawn_block_available}, 767), do: Write.ubyte(0)
|
||||
def serialize(%{packet_type: :game_event, event: :begin_raining}, 767), do: Write.ubyte(1)
|
||||
def serialize(%{packet_type: :game_event, event: :end_raining}, 767), do: Write.ubyte(2)
|
||||
def serialize(%{packet_type: :game_event, event: :change_gamemode, value: v}, 767), do: Write.ubyte(3) <> Write.float(v)
|
||||
def serialize(%{packet_type: :game_event, event: :win_game, value: v}, 767), do: Write.ubyte(4) <> Write.float(v)
|
||||
def serialize(%{packet_type: :game_event, event: :demo_event, value: v}, 767), do: Write.ubyte(5) <> Write.float(v)
|
||||
def serialize(%{packet_type: :game_event, event: :arrow_hit_player}, 767), do: Write.ubyte(6)
|
||||
def serialize(%{packet_type: :game_event, event: :rain_level_change, value: v}, 767), do: Write.ubyte(7) <> Write.float(v)
|
||||
def serialize(%{packet_type: :game_event, event: :thunder_level_change, value: v}, 767), do: Write.ubyte(8) <> Write.float(v)
|
||||
def serialize(%{packet_type: :game_event, event: :play_pufferfish_sting_sound}, 767), do: Write.ubyte(9)
|
||||
def serialize(%{packet_type: :game_event, event: :play_elder_guardian_mob_appearance}, 767), do: Write.ubyte(10)
|
||||
|
||||
|
||||
def handle(%{packet_type: :confirm_teleportation, teleport_id: id}, 767, state) do
|
||||
Amethyst.API.Game.accept_teleport(state[:game], id)
|
||||
|
Loading…
Reference in New Issue
Block a user