-
Notifications
You must be signed in to change notification settings - Fork 3
/
animation_ease.go
58 lines (51 loc) · 1.57 KB
/
animation_ease.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main
import (
"image/color"
"github.com/cooldogedev/spectrum"
"github.com/cooldogedev/spectrum/server"
"github.com/cooldogedev/spectrum/session/animation"
"github.com/go-gl/mathgl/mgl32"
"github.com/sandertv/gophertunnel/minecraft"
"github.com/sandertv/gophertunnel/minecraft/protocol"
"github.com/sandertv/gophertunnel/minecraft/protocol/packet"
"github.com/sirupsen/logrus"
)
type easeProcessor struct {
consumer func(mgl32.Vec3, float32)
}
func (p *easeProcessor) ProcessIncoming(packet.Packet) bool { return true }
func (p *easeProcessor) ProcessOutgoing(pk packet.Packet) bool {
if pk, ok := pk.(*packet.PlayerAuthInput); ok {
p.consumer(pk.Position.Add(mgl32.Vec3{0, 1, 0}), pk.HeadYaw)
}
return true
}
func main() {
logger := logrus.New()
listenConfig := minecraft.ListenConfig{StatusProvider: spectrum.NewStatusProvider("Spectrum Proxy")}
proxy := spectrum.NewSpectrum(server.NewStaticDiscovery(":19133"), logger, nil)
if err := proxy.Listen(listenConfig); err != nil {
logger.Errorf("Failed to listen on proxy: %v", err)
return
}
for {
s, err := proxy.Accept()
if err != nil {
logger.Errorf("Failed to accept session: %v", err)
continue
}
s.SetAnimation(&animation.Ease{
Flicker: true,
Colour: color.RGBA{},
Timing: protocol.CameraFadeTimeData{
FadeInDuration: 0.75,
WaitDuration: 3.25,
FadeOutDuration: 0.75,
},
})
s.SetProcessor(&easeProcessor{consumer: func(position mgl32.Vec3, yaw float32) {
s.Animation().(*animation.Ease).Position = position
s.Animation().(*animation.Ease).Yaw = yaw
}})
}
}