Skip to content

fix: restore by MCA or chunk without leaking outside the selection - #67

Open
softmanmaker wants to merge 2 commits into
zly2006:stonecutterfrom
softmanmaker:fix/regional-restore-mca-chunk
Open

fix: restore by MCA or chunk without leaking outside the selection#67
softmanmaker wants to merge 2 commits into
zly2006:stonecutterfrom
softmanmaker:fix/regional-restore-mca-chunk

Conversation

@softmanmaker

Copy link
Copy Markdown

Breaking change

区域回档命令语义变了,旧脚本/指令会按新含义执行,不再兼容。

旧写法 /xb restore <id> --chunk <x1> <z1> <x2> <z2> 把数字当成方块坐标,但会整文件覆盖对应的 .mca(512×512 方块)。

新写法:

/xb restore <id> --mca <x1> <z1> <x2> <z2>
/xb restore <id> --mca --block <x1> <z1> <x2> <z2>
/xb restore <id> --chunk <x1> <z1> <x2> <z2>
/xb restore <id> --chunk --block <x1> <z1> <x2> <z2>
  • --mca--chunk 互斥
  • 默认坐标分别是 MCA 区号 / 区块坐标,不再是方块坐标
  • 只有再加 --block 才会按方块换算(--mcashr 9--chunkshr 4
  • 因此 /xb restore 1 --chunk 0 0 10 10 现在表示区块 (0,0)–(10,10),不是方块 (0,0)–(10,10)

Summary

  • --mca 仍按当前维度整文件恢复 .mca.mcc 按所属区域过滤
  • --chunk 不再整文件覆盖 .mca,只合并选中区块,同文件内其他区块保留
  • 主世界路径不再误匹配 DIM-1 / DIM1 / dimensions
  • 同一 .mca 内的多个区块一次读写;日志按区块/MCA 各一条,不再按 region/entities/poi 拆开
  • 损坏或截断的 MCA 会报错并拒绝写入,避免被当成“备份里没有这些区块”而删档
  • 先写 .xb-new 并校验,再原子 move 替换原文件

Test plan

  • /xb restore N --mca 0 0 0 0 只动当前维度的 r.0.0.mca
  • /xb restore N --chunk 0 0 10 10 只恢复这些区块,同 MCA 其余区块不变
  • /xb restore N --chunk --block 0 0 10 10 换算为区块 (0,0)
  • 确认旧的 --chunk 0 0 10 10 不再按方块坐标理解
  • 主世界区域回档不会写到下界/末地
  • RegionFileMergerTest / RegionalRestoreTest 通过

Made with Cursor

GinoJin and others added 2 commits August 17, 2026 16:15
… the selection

Keep --mca as whole-file restore, make --chunk merge only selected chunks, and treat coordinates as region/chunk indices unless --block is set.

Co-authored-by: Cursor <cursoragent@cursor.com>
Avoid treating truncated backups as missing chunks, write through a temp file then atomic replace, and log one line per chunk or MCA instead of region/entities/poi paths.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant