Skip to content

Commit

Permalink
world/viewer: Add ViewEntityAnimation for resource-pack based animati…
Browse files Browse the repository at this point in the history
…ons (#773)
  • Loading branch information
unickorn committed Jul 4, 2023
1 parent 6e19bc6 commit 35c9801
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions server/session/world.go
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,16 @@ func (s *Session) ViewEntityState(e world.Entity) {
})
}

// ViewEntityAnimation ...
func (s *Session) ViewEntityAnimation(e world.Entity, animationName string) {
s.writePacket(&packet.AnimateEntity{
Animation: animationName,
EntityRuntimeIDs: []uint64{
s.entityRuntimeID(e),
},
})
}

// OpenBlockContainer ...
func (s *Session) OpenBlockContainer(pos cube.Pos) {
if s.containerOpened.Load() && s.openedPos.Load() == pos {
Expand Down
3 changes: 3 additions & 0 deletions server/world/viewer.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ type Viewer interface {
// ViewEntityState views the current state of an entity. It is called whenever an entity changes its
// physical appearance, for example when sprinting.
ViewEntityState(e Entity)
// ViewEntityAnimation starts viewing an animation performed by an entity. The animation has to be from a resource pack.
ViewEntityAnimation(e Entity, animationName string)
// ViewParticle views a particle spawned at a given position in the world. It is called when a particle,
// for example a block breaking particle, is spawned near the player.
ViewParticle(pos mgl64.Vec3, p Particle)
Expand Down Expand Up @@ -87,6 +89,7 @@ func (NopViewer) ViewEntityItems(Entity) {}
func (NopViewer) ViewEntityArmour(Entity) {}
func (NopViewer) ViewEntityAction(Entity, EntityAction) {}
func (NopViewer) ViewEntityState(Entity) {}
func (NopViewer) ViewEntityAnimation(Entity, string) {}
func (NopViewer) ViewParticle(mgl64.Vec3, Particle) {}
func (NopViewer) ViewSound(mgl64.Vec3, Sound) {}
func (NopViewer) ViewBlockUpdate(cube.Pos, Block, int) {}
Expand Down

0 comments on commit 35c9801

Please sign in to comment.