From 5824f8d7b78969f3548585a6da43e3df6264b28e Mon Sep 17 00:00:00 2001 From: Darya Markova Date: Tue, 28 May 2024 19:11:43 +0500 Subject: [PATCH 1/3] session/world.go: use s.ViewSkin() for player skin rendering on s.ViewEntity(). --- server/session/world.go | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/server/session/world.go b/server/session/world.go index 18d9deab5..146ca452d 100644 --- a/server/session/world.go +++ b/server/session/world.go @@ -76,25 +76,6 @@ func (s *Session) ViewEntity(e world.Entity) { id := e.Type().EncodeEntity() switch v := e.(type) { case Controllable: - actualPlayer := false - - sessionMu.Lock() - for _, s := range sessions { - if s.c.UUID() == v.UUID() { - actualPlayer = true - break - } - } - sessionMu.Unlock() - if !actualPlayer { - s.writePacket(&packet.PlayerList{ActionType: packet.PlayerListActionAdd, Entries: []protocol.PlayerListEntry{{ - UUID: v.UUID(), - EntityUniqueID: int64(runtimeID), - Username: v.Name(), - Skin: skinToProtocol(v.Skin()), - }}}) - } - s.writePacket(&packet.AddPlayer{ EntityMetadata: metadata, EntityRuntimeID: runtimeID, @@ -113,11 +94,8 @@ func (s *Session) ViewEntity(e world.Entity) { }}, }, }) - if !actualPlayer { - s.writePacket(&packet.PlayerList{ActionType: packet.PlayerListActionRemove, Entries: []protocol.PlayerListEntry{{ - UUID: v.UUID(), - }}}) - } + + s.ViewSkin(e) return case *entity.Ent: switch e.Type().(type) { From c83ee29bb2d93a1f908d75fb23a20ea1dc3bad65 Mon Sep 17 00:00:00 2001 From: Darya Markova <122279000+Dasciam@users.noreply.github.com> Date: Tue, 28 May 2024 23:17:46 +0500 Subject: [PATCH 2/3] Revert "session/world.go: use s.ViewSkin() for player skin rendering on s.ViewEntity()." This reverts commit 5824f8d7b78969f3548585a6da43e3df6264b28e. --- server/session/world.go | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/server/session/world.go b/server/session/world.go index 146ca452d..18d9deab5 100644 --- a/server/session/world.go +++ b/server/session/world.go @@ -76,6 +76,25 @@ func (s *Session) ViewEntity(e world.Entity) { id := e.Type().EncodeEntity() switch v := e.(type) { case Controllable: + actualPlayer := false + + sessionMu.Lock() + for _, s := range sessions { + if s.c.UUID() == v.UUID() { + actualPlayer = true + break + } + } + sessionMu.Unlock() + if !actualPlayer { + s.writePacket(&packet.PlayerList{ActionType: packet.PlayerListActionAdd, Entries: []protocol.PlayerListEntry{{ + UUID: v.UUID(), + EntityUniqueID: int64(runtimeID), + Username: v.Name(), + Skin: skinToProtocol(v.Skin()), + }}}) + } + s.writePacket(&packet.AddPlayer{ EntityMetadata: metadata, EntityRuntimeID: runtimeID, @@ -94,8 +113,11 @@ func (s *Session) ViewEntity(e world.Entity) { }}, }, }) - - s.ViewSkin(e) + if !actualPlayer { + s.writePacket(&packet.PlayerList{ActionType: packet.PlayerListActionRemove, Entries: []protocol.PlayerListEntry{{ + UUID: v.UUID(), + }}}) + } return case *entity.Ent: switch e.Type().(type) { From ac453901aad6dc4dbaeed3d9c390dbfbbf247e43 Mon Sep 17 00:00:00 2001 From: Darya Markova <122279000+Dasciam@users.noreply.github.com> Date: Tue, 28 May 2024 23:18:54 +0500 Subject: [PATCH 3/3] session/world.go: use (*session.Session).ViewSkin() for real player skin rendering in (*session.Session).ViewEntity(). --- server/session/world.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/session/world.go b/server/session/world.go index 18d9deab5..0ecc2eec0 100644 --- a/server/session/world.go +++ b/server/session/world.go @@ -117,6 +117,8 @@ func (s *Session) ViewEntity(e world.Entity) { s.writePacket(&packet.PlayerList{ActionType: packet.PlayerListActionRemove, Entries: []protocol.PlayerListEntry{{ UUID: v.UUID(), }}}) + } else { + s.ViewSkin(e) } return case *entity.Ent: