Furnish a tavern with World Builder
Place seats, a bed, a dice table and an alchemy table in World Builder, export them to a server and find them again from a script.
You will furnish a tavern corner in World Builder: a dice table, a bench, a bed and an alchemy table. You export it as a world resource, and the server builds it for every player. Players sit, sleep, play dice and brew there the same way they use the level’s own furniture. A short script then finds the pieces by name.
The game calls these interactive pieces smart objects. World Builder
lists them in the Library’s interactive folder.
What you will learn
Section titled “What you will learn”- Finding seats, beds, the dice table and crafting stations in the Library.
- Placing, turning and naming them, and taking out the level’s own.
- Exporting a world resource and loading it from
server.json. - Finding what the export placed with
WorldResource, and placing the same pieces from a script.
server/ server.json worlds/tavern.world.json exported from World Builder resources/tavern-furniture/ package.json tsconfig.json from Use TypeScript src/server/index.ts lists the furniture by name1. Open World Builder
Section titled “1. Open World Builder”In the main menu, choose World Builder, pick the level your server runs, and click New project. The editor opens once the level has loaded.
Press F7 at any time to walk around as your character, and F7 again to return to the editor. Your work stays in the world while you walk.
2. Find the furniture
Section titled “2. Find the furniture”Open the Library tab. The interactive folder holds every smart object
you can place:
| Folder | What it holds |
|---|---|
interactive/seats |
Benches, chairs and stools. |
interactive/beds |
Beds. |
interactive/games |
The dice table. |
interactive/stations |
Alchemy tables, the smithy, the drying rack and the smokehouse. |
You can also type interactive/ into the search box. Search, favorites and
Recently placed work for these rows as they do for meshes.
3. Place the pieces
Section titled “3. Place the pieces”- Click the dice table’s row. A see-through copy follows the cursor. It is blue over a surface and red in the air.
- Turn it with Shift+mouse wheel or R.
- Left-click to put it down. Another copy stays in your hand, so you can place several in a row.
- Press Escape to put the copy away.
Do the same for a bench, a bed and the alchemy table. Each piece stands assembled, as players will see it.
Smart objects always keep their own size. Ctrl+mouse wheel, random size and the Placement physics setting do nothing for them.
4. Move and name them
Section titled “4. Move and name them”Click a placed piece to select it. Use the gizmo to move or turn it: 1 moves and 2 rotates.
Then open the Object tab and fill in Name: tavern-dice for the dice
table, and tavern-bench, tavern-bed and tavern-alchemy for the others.
Names can be up to 64 bytes long. Scripts use the name to find a piece again,
because its ID changes every time the server starts. The Object tab does not
show Scale or Physics for smart objects, because the server decides both.
Every change is one undo step. Ctrl+Z undoes it and Ctrl+Y redoes it.
5. Take out the level’s own furniture (optional)
Section titled “5. Take out the level’s own furniture (optional)”To remove one of the level’s own dice tables or crafting stations, click it and press Delete. When the server loads your export, it takes that station out for every player too. The station and the furniture around it can be separate objects in the level. If something is left standing, select it and delete it as well.
To bring it back, open Level > Deleted, find it in the list and click Restore.
6. Save and export
Section titled “6. Save and export”Press Ctrl+S, or use Save in the Project tab. This writes a
.project.json file that you open again to keep editing. The server cannot
load this file; the export makes the one it can.
-
In the Project tab, set Resource name to
tavern. -
Click Choose export directory… and pick a folder.
-
Click Export world resource. This writes
tavern.world.json. -
Copy the file to your server, for example to
worlds/tavern.world.json. -
List it in
server.json, merged into your existingmodobject. Paths are relative to the folder the server runs in.server.json {"mod": {"level": "kutnohorsko","world_resources": ["worlds/tavern.world.json"]}} -
Restart the server.
The server checks the file before it finishes starting. A problem stops
startup with an error that names the file and the entry, such as
Invalid door at doors[0]: ....
7. Find the furniture from a script
Section titled “7. Find the furniture from a script”Create resources/tavern-furniture, copy the server tsconfig.json from
Use TypeScript,
and add this manifest:
{ "name": "tavern-furniture", "version": "1.0.0", "scripts": { "build": "tsc -p tsconfig.json" }, "devDependencies": { "@kingdomsconnected/types": "latest", "typescript": "^5.9.2" }, "mafiahub": { "serverScripts": ["dist/server/index.js"] }}A server script reads what the export placed through WorldResource. The
export loads after scripts start, so wait for it:
const EXPORT = "tavern";
function listTavern(): void { const tavern = WorldResource.find(EXPORT); if (!tavern) { console.log(`Add ${EXPORT}.world.json to mod.world_resources and restart the server.`); return; } for (const piece of tavern.smartObjects) { console.log(`${piece.name}: ${piece.kind}, station ${piece.stationId || "none"}`); }
// A placed dice table joins Dice.tables() under its station ID, like one of the level's own. const dice = tavern.smartObjects.find((piece) => piece.name === "tavern-dice"); const table = dice ? Dice.tables().find((candidate) => candidate.id === dice.stationId) : undefined; console.log(table ? `tavern-dice is dice table ${table.id}` : "The export has no tavern-dice.");}
if (WorldResource.ready) listTavern();else Events.once("worldResourcesReady", listTavern);kindisseat,bed,dice,alchemy,smithing,dryingorsmoking.stationIdis the ID thatDice.tables()andSmartObject.stations()list. Seats and beds have none.- The
WorldResource.readycheck works both when the server starts and when you reload the resource withensure.
8. Place a piece from a script (optional)
Section titled “8. Place a piece from a script (optional)”SmartObject.spawn places the same pieces at runtime. It takes a blueprint
name such as Table/table_dice, and SmartObject.blueprints() lists them
all:
const dice = SmartObject.spawn({ blueprint: "Table/table_dice", position: [3102.0, 820.5, 57.3], name: "tavern-dice",});console.log(`${dice.blueprint} placed, station ${dice.stationId}`);A piece a script places belongs to that resource, and disappears when the resource stops. A world resource rebuilds its pieces on every server start.
Try it
Section titled “Try it”- Join the server and walk to the tavern corner.
- Use the game’s own prompt to sit on the bench or sleep in the bed. Other players see you sitting and lying down.
- Look at the dice table. In the default gamemode, the Play dice (join lobby) prompt appears within about two seconds of the server starting. On another gamemode, dice depends on that gamemode’s rules.
- Use the alchemy table as you would one of the level’s own. The server checks every step, as it does at the level’s tables.
- Run
npm installandnpm run buildintavern-furniture, thenensure tavern-furniturein the server console. It lists the four pieces by name, and the dice table’s station ID.
If nothing appears in the game, check that the path in world_resources is
right, that mod.level matches the level you built on, and that you
restarted the server after copying the file. If the server stops at startup,
read the error: it names the file and the entry that is wrong. If there is
no dice prompt, remember that the default gamemode checks for new tables
every two seconds and offers a table only to players in the same world as
the table.
Next steps
Section titled “Next steps”- Lay food and arrows on the ground in the same project with Place items in the world.
- Put a stump where a tree stood with Swap a level object for another mesh.
- Every field, the
SmartObjectandDoorAPIs, stations and virtual worlds are in Smart objects. The World Builder MCP places the same objects from an MCP client. - Keep what players brew and learn at your table with Brew potions at alchemy tables.