properly apply entity scale

This commit is contained in:
olebeck 2023-03-15 12:51:30 +01:00
parent a746dee75b
commit 04293a74c5
2 changed files with 8 additions and 3 deletions

View File

@ -71,6 +71,7 @@ func (w *WorldState) processAddActor(pk *packet.AddActor) {
w.bp.AddEntity(behaviourpack.EntityIn{
Identifier: pk.EntityType,
Attr: pk.Attributes,
Meta: pk.EntityMetadata,
})
}
@ -103,9 +104,6 @@ func entityMetadataToNBT(metadata protocol.EntityMetadata, nbt map[string]any) {
nbt["CustomNameVisible"] = false
}
}
if scale, ok := metadata[protocol.EntityDataKeyScale].(float32); ok {
nbt["Scale"] = scale
}
}
func vec3float32(x mgl32.Vec3) []float32 {

View File

@ -24,6 +24,7 @@ type entityBehaviour struct {
type EntityIn struct {
Identifier string
Attr []protocol.AttributeValue
Meta map[uint32]any
}
func (bp *BehaviourPack) AddEntity(entity EntityIn) {
@ -64,5 +65,11 @@ func (bp *BehaviourPack) AddEntity(entity EntityIn) {
}
}
if scale, ok := entity.Meta[protocol.EntityDataKeyScale].(float32); ok {
entry.MinecraftEntity.Components["minecraft:scale"] = map[string]any{
"value": scale,
}
}
bp.entities[entity.Identifier] = entry
}