add player package with key client-side player functionality, update protocol codecs, and refactor metadata definitions and slot usage

This commit is contained in:
2025-08-23 16:19:45 +08:00
parent cff9d4a809
commit 4528bdc86a
32 changed files with 2613 additions and 468 deletions

59
pkg/game/world/entity.go Normal file
View File

@ -0,0 +1,59 @@
package world
import (
"git.konjactw.dev/patyhank/minego/pkg/protocol/metadata"
"git.konjactw.dev/patyhank/minego/pkg/protocol/slot"
"github.com/Tnze/go-mc/data/entity"
"github.com/go-gl/mathgl/mgl64"
"github.com/google/uuid"
)
type Entity struct {
id int32
entityUUID uuid.UUID
entityType entity.ID
pos mgl64.Vec3
rot mgl64.Vec2
metadata map[uint8]metadata.Metadata
equipment map[int8]slot.Slot
}
func (e *Entity) ID() int32 {
return e.id
}
func (e *Entity) UUID() uuid.UUID {
return e.entityUUID
}
func (e *Entity) Type() entity.ID {
return e.entityType
}
func (e *Entity) Position() mgl64.Vec3 {
return e.pos
}
func (e *Entity) Rotation() mgl64.Vec2 {
return e.rot
}
func (e *Entity) Metadata() map[uint8]metadata.Metadata {
return e.metadata
}
func (e *Entity) Equipment() map[int8]slot.Slot {
return e.equipment
}
func (e *Entity) SetPosition(pos mgl64.Vec3) {
e.pos = pos
}
func (e *Entity) SetRotation(rot mgl64.Vec2) {
e.rot = rot
}
func (e *Entity) SetID(id int32) {
e.id = id
}