"Implement" "chat"
All checks were successful
Build & Test / nix-build (push) Successful in 1m53s

This commit is contained in:
Kodi Craft 2024-10-09 12:19:50 +02:00
parent 29014aa45f
commit 47bb453178
Signed by: kodi
GPG Key ID: 69D9EED60B242822
2 changed files with 11 additions and 0 deletions

View File

@ -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

View File

@ -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