Let a tool world refuse to close and hear that it is closing, and tell middle clicks apart

ToolWorldListener gets closeRefusal() and closing(by) so a tool world that holds the
studio slot can keep its owner's work safe. MenuClick tells a middle click from a
left or right one.
This commit is contained in:
piexel committed 2026-11-08 16:52:09 +01:00
1 parent 3691611c6c
commit 18c6b189d1
8 files changed
+43 -412

No files matched your search

+4
View File
@@ -611,6 +611,10 @@ worlds.open(new ToolWorldSpec("scratch", painter, new ToolWorldListener() { }))
`Cause`). Each method returns `true` to allow or `false` to cancel where it decides, and `blockChanging` freezes the
world unless the tool overrides it. Calls come on the thread that owns the player or the position, and must return
quickly.
- A tool world takes the pack's studio slot: opening another studio, the studio close command and a server stop go
through the world. `closeRefusal()` lets the tool veto such a close with a message (an unsaved edit, a running
save), and `closing(by)` lets it finish its work before another studio replaces it; the host closes the world when
that future completes.
- On a platform that splits a world across threads (Folia), `ToolWorld.owns(at)` says whether the calling thread may
touch the block, `run`/`call` get a task there, and `block`, `blockEntity` and `setBlock` fail with
`IllegalStateException` elsewhere. `ToolPlayer` readers are valid on the player's own thread (`ToolPlayer.run`); its