feat(installer): 便携中文安装包「年糕历险记-Setup-v0.1.0.zip」——安装.bat 中文交互+桌面快捷方式;修复 ps1 BOM 编码
This commit is contained in:
@@ -26,6 +26,8 @@ import (
|
||||
"mc/internal/item"
|
||||
"mc/internal/logx"
|
||||
"mc/internal/mesh"
|
||||
"mc/internal/netclient"
|
||||
"mc/internal/netproto"
|
||||
"mc/internal/physics"
|
||||
"mc/internal/recipe"
|
||||
"mc/internal/render"
|
||||
@@ -51,6 +53,10 @@ type clientApp struct {
|
||||
titleScreen *ui.TitleScreen
|
||||
pauseScreen *ui.PauseScreen
|
||||
|
||||
// 联机(多人同步.md §2:无连接时为单机)
|
||||
net *netclient.Client
|
||||
log *logx.Logger
|
||||
|
||||
meshBuilder *mesh.Builder
|
||||
|
||||
mu sync.Mutex
|
||||
@@ -77,6 +83,15 @@ func (a *clientApp) Tick(dt float64) {
|
||||
case "play":
|
||||
a.screen = 1
|
||||
a.rend.SetCursorMode(true)
|
||||
case "multi":
|
||||
// 联机:连接本机服务器(多人同步.md §2)
|
||||
if err := dialServer(a, "127.0.0.1:25565", "玩家"); err != nil {
|
||||
a.logf("连接服务器失败: %v", err)
|
||||
} else {
|
||||
a.screen = 1
|
||||
a.rend.SetCursorMode(true)
|
||||
a.logf("已连接服务器")
|
||||
}
|
||||
case "quit":
|
||||
a.rend.Window().SetShouldClose(true)
|
||||
}
|
||||
@@ -112,9 +127,19 @@ func (a *clientApp) Tick(dt float64) {
|
||||
a.in.apply(a.sess)
|
||||
a.sess.Tick(dt)
|
||||
|
||||
// 联机:上报移动(20Hz,多人同步.md §3)
|
||||
if a.net != nil {
|
||||
p := a.sess.Player
|
||||
a.net.SendMove(netproto.PlayerMove{
|
||||
X: float32(p.Pos[0]), Y: float32(p.Pos[1]), Z: float32(p.Pos[2]),
|
||||
Yaw: float32(a.sess.Cam.Yaw), Pitch: float32(a.sess.Cam.Pitch),
|
||||
OnGround: p.OnGround,
|
||||
})
|
||||
}
|
||||
|
||||
// 定时存档:30s(存档与持久化.md §2)
|
||||
a.tickCnt++
|
||||
if a.tickCnt%(20*30) == 0 {
|
||||
if a.tickCnt%(20*30) == 0 && a.net == nil {
|
||||
if err := save.SaveWorld(a.sess.World, "worlds", "NewWorld", 123456789, int64(a.tickCnt)); err != nil {
|
||||
// 日志由调用方输出(避免每次 tick 刷屏)
|
||||
_ = err
|
||||
@@ -178,6 +203,13 @@ func (a *clientApp) Render() {
|
||||
// ShouldClose 窗口关闭判定。
|
||||
func (a *clientApp) ShouldClose() bool { return a.rend.ShouldClose() }
|
||||
|
||||
// logf 客户端日志(联机回调使用)。
|
||||
func (a *clientApp) logf(format string, args ...any) {
|
||||
if a.log != nil {
|
||||
a.log.Infof(format, args...)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
@@ -341,6 +373,7 @@ func main() {
|
||||
hud: hud,
|
||||
titleScreen: titleScreen,
|
||||
pauseScreen: pauseScreen,
|
||||
log: log,
|
||||
meshBuilder: mesh.NewBuilder(reg, uvFn),
|
||||
winW: cfg.Client.WindowWidth,
|
||||
winH: cfg.Client.WindowHeight,
|
||||
|
||||
Reference in New Issue
Block a user