Skip to content

[release-v1.2.1]原版红石、放置规则、区块加载、合成、伤害、战利品表与 TNT - #4

Merged
hekuo5310 merged 11 commits into
mainfrom
claude/magical-dijkstra-nro58t
Nov 18, 2026
Merged

hekuo5310 merged 11 commits into
mainfrom
claude/magical-dijkstra-nro58t

Conversation

@hekuo5310

@hekuo5310 hekuo5310 commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

概要

接在 #3 之后的修复与原版机制。仍在推进,所以保持草稿。

发布方式:本 PR 标题含 [release-v1.2.1]。合并后,工作流会自动给合并提交打 v1.2.1 tag,并用 CHANGELOG.md 的 1.2.1 小节发布正式版。

本次变更

  • 删除网页管理台:移除 admin/web.py、其测试以及 web-admin-* 配置项。终端控制台、RCON 和权限系统不受影响。
  • 铁砧先前工作惩罚:合并后结果的惩罚为 max(左, 右) * 2 + 1,合并时两边的惩罚计入费用(与原版一致)。
  • 铁砧费用上限开关:新增配置项 anvil-too-expensive-limit(默认 true,即原版行为)。设为 false 后,费用达到 40 级也能取出,只要等级足够。
  • 药水外观:药水按 1.21.1 原版药水注册表的 id 发给客户端(potion_contents 组件)。id 来自注册表的注册顺序,仓库里 world/data/potions.json 只保存名字和顺序。药效尚未实现。

附魔与附魔书(上一轮)

  • 附魔数据来自 1.21.1 原版注册表(tools/gen_enchantment_data.py 生成 world/data/enchantments.json)。
  • 附魔信息随物品发给客户端,客户端回传的附魔物品能正确解析。
  • 附魔台:三个选项按原版费用计算,书架增加选项,点击后扣青金石和等级。
  • 铁砧:合并附魔书或同类物品,结果在输出格,取走时扣材料和等级。互斥附魔不能合并,同级合并升一级。
  • 关闭附魔台或铁砧时,物品退还背包。

容器与交互(前几轮)

  • 大箱子:按原版规则合并和拆分;54 格界面;漏斗和比较器把两半当作一个容器。
  • 矿车 / 漏斗矿车:沿轨道行驶,充能铁轨加速或刹车;普通矿车可乘坐;玩家推动和互相碰撞;探测铁轨检测矿车。
  • 堆肥桶:漏斗投料,满 7 层后 20 刻可取。
  • 酿造台:5 格容器,烈焰粉燃料,400 刻酿造,常见的基础药水转换,进度随存档保存。

红石与引擎(按原版 1.21.1 重写,world/rs/;C++ 原生引擎在 native/vanilla/)

  • 移植原版的事件驱动模型:带更新标志的 setBlock、原版更新顺序、形状更新、计划刻、方块事件、移动中活塞。
  • 所有红石元件按对应的原版类实现;准连接、BUD、0t、TNT 复制都没有做特判。
  • 原生引擎以共享库形式通过 ctypes 在进程内加载,重负载电路每刻从 117 ms 降到 3.1 ms;爆炸射线约 1 ms。拿不到库时回退到 Python 引擎。

其他

  • 放置规则使用原版 getStateForPlacement;TNT 与爆炸按原版实现,爆炸在独立线程中计算。
  • 区块分批加载;原版合成配方;伤害规则与战利品表按原版实现。
  • CI:合并标题含 [release-vX.Y.Z] 的 PR 时自动打 tag 并发布正式版(tag 已存在时只发预发布);直接推送 v* tag 照旧。

测试

  • pytest:265 个通过,1 个跳过(只检查 Python 引擎内部状态)。
  • tests/test_enchanting.py:附魔和药水的编码往返;附魔台和铁砧的全部交互;先前工作惩罚;费用上限开关(开和关,创造模式);配置文件读取。
  • tests/test_native_engine.py:红石测试在 C++ 引擎上重跑;随机电路逐刻比对;爆炸射线比对;漏斗、堆肥桶、酿造台、矿车、探测铁轨。

已知限制

  • 药效未实现:药水外观已经正确显示,但速度、治疗、再生等效果不会作用于玩家。
  • 附魔还不支持:铁砧改名、修复耐久、附魔的随机掉落(战利品中的附魔书)。
  • 普通矿车不会自动载上生物(这里没有实现)。
  • 刷线机、刷钩机和常见 TNT 复制机还需在真实客户端上实测。

🤖 Generated with Claude Code

https://claude.ai/code/session_01MqNsCYYKLCUPjt3r1MFKgu

Nuitka's --include-data-dir silently skips .exe/.dll/.so/.dylib files,
so the packaged servers never contained terrain_gen/mob_ai and fell
back to the Python generator (~8 s per chunk). List the native files
explicitly with --include-data-files and fail the build if they are
missing or report the wrong worldgen version.

While the spawn area is prepared, /stop (console), Ctrl+C and SIGTERM
now take effect after the current chunk instead of after startup; a
world stopped before its spawn was chosen is saved with
initialized=0 so the next start searches again. Without the native
generator only 3x3 spawn chunks are prepared, with per-chunk progress.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MqNsCYYKLCUPjt3r1MFKgu
Chunks: section/heightmap/NBT encoding now works on whole lists
(world/fastpack.py, output byte-identical to before) and the native
generator output is read without quadratic concatenation, ~150 ms ->
~35 ms per new chunk. Chunks beyond the join radius are generated and
sent nearest first in pipelined batches of 32, so the view fills in
within seconds instead of everything arriving after ~1 minute.

Crafting: the 2x2 inventory grid and the crafting table now work, with
all vanilla 1.21.1 shaped/shapeless recipes (tags resolved, mirrored
shapes, crafting remainders; tools/gen_recipe_data.py builds
world/data/recipes.json). Result slot clicks, shift-crafting, number
keys and dropping behave like vanilla; grids empty back into the
inventory on close or logout. Clicks are answered like vanilla with
only the slots the client predicted wrong (one state id per answer)
instead of a full window each time, which raced with fast clicking.

Leaves drop by the vanilla loot table (saplings 1/20, jungle 1/40,
sticks 1/50, apples 1/200, Fortune-scaled; shears/Silk Touch keep the
leaves) instead of always dropping a sapling or the leaves themselves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MqNsCYYKLCUPjt3r1MFKgu
Mobs treated grass, flowers, torches and every other block without a
collision box as walls, so on vanilla terrain they got stuck within a
block and hostile mobs never got close enough to hurt anyone. Mob
physics now uses the collision data from blocks.json.

Damage follows vanilla: weapon damage/attack speed tables, attack
strength scaling instead of dropping clicks within 0.4 s, critical
hits, armor + toughness, protection enchantments, difficulty scaling of
mob damage, the 10-tick invulnerability window (for players and mobs)
and 3 s spawn invulnerability on join/respawn.

Region files were written concurrently by the event loop and chunk
worker threads, racing on the same .tmp file ("Failed to save region");
all region access is now serialized.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MqNsCYYKLCUPjt3r1MFKgu
Block and entity drops now come from the vanilla 1.21.1 loot tables
(tools/gen_loot_data.py -> world/data/loot_tables.json): Fortune and
Looting formulas, Silk Touch, shears, random chances, crop ages,
killed-by-player drops, explosion decay, sheep wool by colour.
Blocks drop with bare hands unless vanilla requires the correct tool
(blocks.json harvestTools); before, dirt, logs, sand etc. dropped
nothing without a tool.

TNT is primed into a TNT entity with an 80-tick fuse (flint and steel,
redstone) instead of exploding instantly. Explosions use the vanilla
ray algorithm with block blast resistance, chain-prime TNT, drop blocks
through their loot tables, damage and push entities by exposure, and
send the 1.21.1 Explosion packet (the old packet layout would make
clients disconnect).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MqNsCYYKLCUPjt3r1MFKgu
Replace the approximate redstone engine (full recompute of a component
registry every other tick) with a port of the vanilla 1.21.1 update model
in world/rs: setBlock with update flags, onPlace/onRemove, block updates
in W,E,D,U,N,S order, shape updates, scheduled ticks ordered by
(tick, priority, sub-tick), block events and moving-piston block entities,
run every game tick in vanilla phase order.

Components follow the vanilla classes: redstone wire (connection shapes,
weak/strong power via shouldSignal, update order from Java HashSet
iteration), torches with burnout, repeaters (delay, locking, priorities),
comparators (compare/subtract, container/cauldron/composter/cake
readings), observers, levers, buttons, pressure plates, redstone lamps,
TNT, note blocks, doors/trapdoors/fence gates, dispensers/droppers,
hoppers, powered/activator rails and pistons (structure resolver with
slime/honey, push limit 12, push reactions, moving pistons, finalTick,
fast retraction). Quasi-connectivity, BUD pistons and 0-tick behaviour
emerge from this instead of being special-cased; scheduled ticks survive
restarts. Clients get Block Action packets for piston animations.

Placing blocks now uses vanilla getStateForPlacement rules (piston,
observer, repeater, comparator, hopper facing; lever/button faces; wall
torches; slab/stair halves; log axes; trapdoors; doors and beds with both
halves; signs; waterlogging) and items whose block has another name
(redstone -> redstone_wire, string, seeds, ...) can be placed at all.
Every edit through world.editing (placing, breaking, /setblock, /fill,
/clone, explosions) notifies the engine; /setblock accepts name[prop=val].

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MqNsCYYKLCUPjt3r1MFKgu
TripWireHookBlock.calculateState (cached line states written back,
10-tick recheck when the line changes), tripwire connections, update
sources and entity detection, as in vanilla, so string/hook behaviour
under pistons follows the same code path as the vanilla server.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MqNsCYYKLCUPjt3r1MFKgu
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MqNsCYYKLCUPjt3r1MFKgu
@hekuo5310 hekuo5310 changed the title 区块加载、合成、伤害、原版战利品表与 TNT(草稿,进行中) 原版红石、放置规则、区块加载、合成、伤害、战利品表与 TNT(草稿) Nov 18, 2026
TNT dupers work again: pistons capture the pushed states before moving
them, so a budded TNT primed by an update inside that window is still
placed by the moving piston. The missing pieces were vanilla details:
coral fans are pushable (MC-133541) and pop without support, rails are
pushable, and powered/detector/activator rails update their
surroundings when removed (BaseRailBlock). A layout search found
duplicating layouts; one is kept as a regression test.

Explosions are computed (rays, exposure, loot rolls) on a dedicated
explosion thread pool regardless of the multithreading setting, and
applied back on the server thread (damage, knockback, block changes,
redstone updates, drops, packets), skipping blocks that changed in the
meantime. Queued explosions run as background tasks in order, so the
game tick no longer waits for them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MqNsCYYKLCUPjt3r1MFKgu
native/vanilla is a line-by-line port of world/rs (setBlock, block and shape
updates, scheduled ticks, block events, moving pistons; BUD, quasi-connectivity,
0-tick and TNT duplication emerge the same way), loaded in-process through
ctypes. Adds the vanilla hopper block entity (cooldowns, push then pull,
locking, sided furnace slots, item pickup) and computes explosion rays and
exposure in C++ on the explosion thread.

The Python engine stays as fallback and reference: every redstone test is
rerun on the native engine and 300 random circuits are compared tick by tick.
CMake, build scripts and CI build and package the library.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MqNsCYYKLCUPjt3r1MFKgu
@hekuo5310 hekuo5310 changed the title 原版红石、放置规则、区块加载、合成、伤害、战利品表与 TNT(草稿) [release-v1.2.1]原版红石、放置规则、区块加载、合成、伤害、战利品表与 TNT(草稿) Nov 18, 2026
Double chests: vanilla placement joins a single chest beside the new one,
ChestBlock shape updates join and split the halves (both engines), a 54-slot
window opens, and hoppers and comparators see one compound container with
the right half first.

Hopper minecarts: minecart entities follow straight, curved and sloped rails
with powered-rail boost and braking; a hopper minecart sucks one item per
tick from the container above (or picks up items) unless it stands on a
powered activator rail; hoppers push into and pull from minecarts next to
them; players open and break them; they are saved with the world.

Composters: hoppers fill them with the vanilla compost chances, level 7
becomes ready after 20 ticks, hoppers below take the bone meal; players
compost and empty them by hand.

The native hopper code now tags every slot with the inventory that owns it
(block container, entity, composter), so all views stay consistent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MqNsCYYKLCUPjt3r1MFKgu
… release from PR title

Minecarts: players ride plain minecarts (interact to get in, W pushes the cart,
sneak gets out; Set Passengers and Player Input), walking into a minecart
pushes it, minecarts push each other apart (AbstractMinecart.push), moving
minecarts are synced every tick. Detector rails power while a minecart is on
them and comparators read a container minecart (both engines).

Brewing stands get their 5-slot container and window, and hoppers follow the
vanilla faces: ingredients from above, bottles and blaze powder from the side,
potions out of the bottom.

CI: merging a pull request whose title contains [release-vX.Y.Z] tags the
merge commit vX.Y.Z and publishes the stable release in the same workflow.
CHANGELOG gets a 1.2.1 section for everything after v1.2.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MqNsCYYKLCUPjt3r1MFKgu
@hekuo5310 hekuo5310 changed the title [release-v1.2.1]原版红石、放置规则、区块加载、合成、伤害、战利品表与 TNT(草稿) [release-v1.2.1]原版红石、放置规则、区块加载、合成、伤害、战利品表与 TNT Nov 18, 2026
@hekuo5310
hekuo5310 marked this pull request as ready for review November 18, 2026 07:58
@hekuo5310
hekuo5310 merged commit f2dd427 into main Nov 18, 2026
6 checks passed
@hekuo5310
hekuo5310 deleted the claude/magical-dijkstra-nro58t branch November 18, 2026 07:58
hekuo5310 added a commit that referenced this pull request Nov 18, 2026
[release-v1.2.1]原版红石、放置规则、区块加载、合成、伤害、战利品表与 TNT
hekuo5310 pushed a commit that referenced this pull request Nov 20, 2026
main and this branch share the same history from PR #4 onward only through
the squashed merge; the conflicts were the same files written in both
histories. Resolved in favour of this branch. main still referred to
pumpkin-ref/, which is gone; those references are removed here.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MqNsCYYKLCUPjt3r1MFKgu
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.

2 participants