From 45cf3f1affd8cbc8428734e8f2d3346e241686b8 Mon Sep 17 00:00:00 2001 From: Darya Markova <122279000+Dasciam@users.noreply.github.com> Date: Sat, 3 Aug 2024 20:24:21 +0500 Subject: [PATCH] session/entity_metadata.go: Display mob effects with new EntityDataKeyVisibleMobEffects (#906) --- go.mod | 2 +- go.sum | 4 ++-- server/session/entity_metadata.go | 23 ++++++++++------------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/go.mod b/go.mod index 4e3e0407b..0b37a1769 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/google/uuid v1.6.0 github.com/pelletier/go-toml v1.9.5 github.com/rogpeppe/go-internal v1.11.0 - github.com/sandertv/gophertunnel v1.39.0 + github.com/sandertv/gophertunnel v1.39.3 github.com/segmentio/fasthash v1.0.3 github.com/sirupsen/logrus v1.9.3 golang.org/x/exp v0.0.0-20230206171751-46f607a40771 diff --git a/go.sum b/go.sum index 0aa4ad0fa..824e845b4 100644 --- a/go.sum +++ b/go.sum @@ -44,8 +44,8 @@ github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDN github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/sandertv/go-raknet v1.14.1 h1:V2Gslo+0x4jfj+p0PM48mWxmMbYkxSlgeKy//y3ZrzI= github.com/sandertv/go-raknet v1.14.1/go.mod h1:/yysjwfCXm2+2OY8mBazLzcxJ3irnylKCyG3FLgUPVU= -github.com/sandertv/gophertunnel v1.39.0 h1:Am2NhSQjxscAVihRG/Qz7cfyJJp91RIl/5DpSLbwXp0= -github.com/sandertv/gophertunnel v1.39.0/go.mod h1:uSaX7RbVaCcxsGAx2vyZnkT0M6kZFGCdAqLn0+wuKyY= +github.com/sandertv/gophertunnel v1.39.3 h1:oc0PPOhrB9utScy8SEYJTWQIFexzf8CVizmB5MLsb6A= +github.com/sandertv/gophertunnel v1.39.3/go.mod h1:uSaX7RbVaCcxsGAx2vyZnkT0M6kZFGCdAqLn0+wuKyY= github.com/segmentio/fasthash v1.0.3 h1:EI9+KE1EwvMLBWwjpRDc+fEM+prwxDYbslddQGtrmhM= github.com/segmentio/fasthash v1.0.3/go.mod h1:waKX8l2N8yckOgmSsXJi7x1ZfdKZ4x7KRMzBtS3oedY= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= diff --git a/server/session/entity_metadata.go b/server/session/entity_metadata.go index f75783d85..530487cee 100644 --- a/server/session/entity_metadata.go +++ b/server/session/entity_metadata.go @@ -141,22 +141,19 @@ func (s *Session) addSpecificMetadata(e any, m protocol.EntityMetadata) { m[protocol.EntityDataKeyCustomDisplay] = tip + 1 } } - if eff, ok := e.(effectBearer); ok && len(eff.Effects()) > 0 { - visibleEffects := make([]effect.Effect, 0, len(eff.Effects())) - for _, ef := range eff.Effects() { + if eff, ok := e.(effectBearer); ok { + var packedEffects int64 + + for i, ef := range eff.Effects() { if !ef.ParticlesHidden() { - visibleEffects = append(visibleEffects, ef) - } - } - if len(visibleEffects) > 0 { - colour, am := effect.ResultingColour(visibleEffects) - m[protocol.EntityDataKeyEffectColor] = nbtconv.Int32FromRGBA(colour) - if am { - m[protocol.EntityDataKeyEffectAmbience] = byte(1) - } else { - m[protocol.EntityDataKeyEffectAmbience] = byte(0) + id, found := effect.ID(ef.Type()) + if !found { + continue + } + packedEffects = (packedEffects << (i * 7)) | int64(id<<1) } } + m[protocol.EntityDataKeyVisibleMobEffects] = packedEffects } if v, ok := e.(variable); ok { m[protocol.EntityDataKeyVariant] = v.Variant()