diff --git a/apps/amethyst/lib/states/play.ex b/apps/amethyst/lib/states/play.ex index 297cc65..92447b3 100644 --- a/apps/amethyst/lib/states/play.ex +++ b/apps/amethyst/lib/states/play.ex @@ -135,6 +135,10 @@ defmodule Amethyst.ConnectionState.Play do Macros.defpacket_clientbound :set_center_chunk, 0x54, 767, [ chunk_x: :varint, chunk_z: :varint ] + Macros.defpacket_clientbound :system_chat_message, 0x6C, 767, [ + content: :nbt, + overlay: :bool + ] Macros.defpacket_clientbound :game_event, 0x22, 767, [ event: :ubyte, value: :float diff --git a/apps/example_game/lib/example/game.ex b/apps/example_game/lib/example/game.ex index b71f404..e179b2a 100644 --- a/apps/example_game/lib/example/game.ex +++ b/apps/example_game/lib/example/game.ex @@ -5,6 +5,8 @@ defmodule Example.Game do @moduledoc """ Example game used for testing Amethyst. """ +require Amethyst.NBT.Write +alias Amethyst.NBT @impl true def instantiate(supervisor) do @@ -42,6 +44,11 @@ defmodule Example.Game do @impl true def chat(from, message, _state_refs) do Logger.info("Player at #{inspect(from)} said: #{inspect(message)}") + send(from, {:send_packet, %{ + packet_type: :system_chat_message, + content: NBT.Write.compound(%{"text" => NBT.Write.string("You said: #{message}")}), + overlay: false + }}) :ok end