Files
mc/server/session/handler_emote.go
TarnaWijaya 26ed99fda6
Build and deploy / Build (push) Has been cancelled
Build and deploy / Update Contributors (push) Has been cancelled
Build and deploy / Deploy (push) Has been cancelled
up3
2026-07-09 08:33:57 +08:00

35 lines
729 B
Go

package session
import (
"github.com/df-mc/dragonfly/server/world"
"github.com/google/uuid"
"github.com/sandertv/gophertunnel/minecraft/protocol/packet"
"time"
)
// EmoteHandler handles the Emote packet.
type EmoteHandler struct {
LastEmote time.Time
}
// Handle ...
func (h *EmoteHandler) Handle(p packet.Packet, _ *Session, tx *world.Tx, c Controllable) error {
pk := p.(*packet.Emote)
if pk.EntityRuntimeID != selfEntityRuntimeID {
return errSelfRuntimeID
}
if time.Since(h.LastEmote) < time.Second {
return nil
}
h.LastEmote = time.Now()
emote, err := uuid.Parse(pk.EmoteID)
if err != nil {
return err
}
for _, viewer := range tx.Viewers(c.Position()) {
viewer.ViewEmote(c, emote)
}
return nil
}