A registration point is a place where a plugin attaches a feature to the editor. Call all of them inside Register(host) as host.Add…(data type). The data types are C# records. You can pass fields that have default values as named arguments (Order: 600).
Id gets an ext.<plugin id>. prefix inside the editor. It only needs to be unique within your plugin.
If Id (Name for commands, Kind for actor types) is empty or the run function (Run · Spawn · Build) is null, registration throws. The whole plugin then fails to enable.
If a registered callback throws, the plugin is isolated.
Order is the order within the same location. Smaller comes first. The default is 500.
Do not put emoji or pictographic characters in on-screen text. Pictographic characters are stripped from menu, tab and mode names. Give icons as an icon name (prefab · block · light · trigger · logic …) in the Icon field.
publicsealedrecordNpMenuItem(string Id, string Menu, string Label, Action Run, string Shortcut ="", int Order =500);
Field
Description
Id
Item id
Menu
"파일" · "편집" · "창" · "도구" · "빌드" · "도움말". Any other name creates a new menu before Help.
Label
Text shown in the menu
Run
Runs when clicked
Shortcut
Shortcut string (for example "Ctrl+Alt+H"). If the key can be parsed, it appears next to the menu text, runs the item when pressed, and can be rebound in Tools › Shortcuts….
Order
Order within the menu. A separator appears where the hundreds digit changes (for example between 499 and 500).
host.AddMenuItem(new NpMenuItem("hollow", "도구", "선택 속 비우기", () =>
{
if (host.World.Selectionisnot { } b) { host.Message("먼저 영역을 고르세요"); return; }
int n =host.World.Edit("속 비우기", e =>
{
for (int y =b.Min.Y+1; y <b.Max.Y; y++)
for (int z =b.Min.Z+1; z <b.Max.Z; z++)
for (int x =b.Min.X+1; x <b.Max.X; x++)
e.Clear(x, y, z);
});
host.Message($"{n:N0}칸 비움");
}, Order: 550));
Items in the Window menu are attached below the panel list.
.Number("폭", _width, 1, 9, 1, v => _width = (int)v)
.Check("가로등", _lamps, v => _lamps = v)
.Button("선택 영역에 깔기", () =>host.Message($"폭 {_width}"))));
The panel is created closed in the bottom area. The user opens it from the Window menu. Once open, it can be dragged to another area or popped out as a floating window.
No edit can change a cell for which the guard returns true. This applies to brushes, shapes, fill, console commands and other plugins’ World.Edit. Undo and redo are not checked.
host.AddCellGuard((x, y, z) => y <0); // cells below y 0 cannot be changed
With multiple guards, the cell is blocked if any one returns true.
Called for every cell. Keep it very light (a dictionary lookup or box comparison at most).
Receives the list of cells a user edit (place · break · brush · shape · drag box · paint) will change, and returns an expanded list. It is chained after the built-in symmetry.
host.AddSymmetry(cells =>cells.Concat(cells.Select(b => b with { X =-b.X }))); // mirror across the X=0 plane
Return the list including the original cells. If you leave them out, the original edit disappears.
Cells being set to air (break) have State"minecraft:air".