From 2e920a7bf0da5c835f24f5e45c4faf287ffbfd65 Mon Sep 17 00:00:00 2001 From: olebeck <31539311+olebeck@users.noreply.github.com> Date: Wed, 5 Apr 2023 16:07:49 +0200 Subject: [PATCH] fix shadows on entities --- handlers/worlds/entity.go | 2 +- handlers/worlds/items.go | 2 +- handlers/worlds/world.go | 2 +- utils/behaviourpack/entity.go | 22 +++++++++++++++++----- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/handlers/worlds/entity.go b/handlers/worlds/entity.go index fb823c1..0969c53 100644 --- a/handlers/worlds/entity.go +++ b/handlers/worlds/entity.go @@ -197,7 +197,7 @@ func (s *entityState) ToServerEntity() serverEntity { Encoded: s.EntityType, NBT: map[string]any{ "Pos": vec3float32(s.Position), - "Rotation": []float32{s.Yaw, s.Pitch}, + "Rotation": []float32{s.HeadYaw, s.Pitch}, "Motion": vec3float32(s.Velocity), "UniqueID": int64(s.UniqueID), }, diff --git a/handlers/worlds/items.go b/handlers/worlds/items.go index 63adf24..56e23cf 100644 --- a/handlers/worlds/items.go +++ b/handlers/worlds/items.go @@ -367,7 +367,7 @@ func (w *worldsHandler) playerData() (ret map[string]any) { ret["Tags"] = []string{} ret["OnGround"] = true - spawn := w.proxy.Server.GameData().PlayerPosition + spawn := w.serverState.PlayerPos.Position ret["SpawnX"] = int32(spawn.X()) ret["SpawnY"] = int32(spawn.Y()) diff --git a/handlers/worlds/world.go b/handlers/worlds/world.go index af73781..42aaaac 100644 --- a/handlers/worlds/world.go +++ b/handlers/worlds/world.go @@ -318,7 +318,7 @@ func (w *worldsHandler) SaveAndReset() { logrus.Error(err) } - playerPos := w.proxy.Server.GameData().PlayerPosition + playerPos := w.serverState.PlayerPos.Position spawnPos := cube.Pos{int(playerPos.X()), int(playerPos.Y()), int(playerPos.Z())} // write metadata diff --git a/utils/behaviourpack/entity.go b/utils/behaviourpack/entity.go index d55c9dc..d878536 100644 --- a/utils/behaviourpack/entity.go +++ b/utils/behaviourpack/entity.go @@ -72,11 +72,23 @@ func (bp *BehaviourPack) AddEntity(entity EntityIn) { "value": scale, } } - AlwaysShowName := entity.Meta.Flag(protocol.EntityDataKeyFlags, protocol.EntityDataFlagAlwaysShowName) - if AlwaysShowName { - entry.MinecraftEntity.Components["minecraft:nameable"] = map[string]any{ - "always_show": true, - "allow_name_tag_renaming": false, + + width, widthOk := entity.Meta[protocol.EntityDataKeyWidth].(float32) + height, heightOk := entity.Meta[protocol.EntityDataKeyHeight].(float32) + if widthOk || heightOk { + entry.MinecraftEntity.Components["minecraft:collision_box"] = map[string]any{ + "width": width, + "height": height, + } + } + + if _, ok := entity.Meta[protocol.EntityDataKeyFlags]; ok { + AlwaysShowName := entity.Meta.Flag(protocol.EntityDataKeyFlags, protocol.EntityDataFlagAlwaysShowName) + if AlwaysShowName { + entry.MinecraftEntity.Components["minecraft:nameable"] = map[string]any{ + "always_show": true, + "allow_name_tag_renaming": false, + } } }