Skip to content
NP Editor Docs
This is not the latest version — view the latest

Registration points

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, and you can pass fields that have default values as named arguments (Order: 600). World logic types (AddSceneEvent) are covered separately in Adding world logic types.

  1. Inside Register, create one data type per registration point and pass it to host.Add….

    // Tools > Hollow selection ("도구" is the editor's key for the Tools menu — keep it in Korean)
    host.AddMenuItem(new NpMenuItem("hollow", "도구", "Hollow selection", () =>
    {
    if (host.World.Selection is not { } b) { host.Message("No selection"); return; }
    int n = host.World.Edit("Hollow", 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} cells cleared");
    }, Order: 550));
  2. Build, then click Reload (selected) in the Plugin Manager.

  3. Check the summary in the Registered column (for example 메뉴 1) to confirm the registration is attached.

    Known issue in 0.10.2: the Registered column shows the summary in Korean (메뉴 1 = “Menu 1”, 빠른 추가 1 = “Quick add 1”).

  • Group menu Order values by hundreds. A separator appears where the hundreds digit changes, so items in the same group, such as 550 and 551, appear as one block.
  • Panels are created closed. Tell users to open the panel from the Window menu, or put a menu item that opens the panel in the Window menu as well (Menu = "창").
  • If you use a built-in mode id (for example np.blockbrush) as is in a shortcut’s Mode, the key works only in that built-in mode.
  • Modes after the first 8 in the mode row go into the list of the More modes button (down arrow) at the end of the mode row. Plugin modes come after built-in modes, so they are usually in this list. Give them a shortcut to make them easier to find.
  • Do not put emoji or pictographic characters in on-screen text. Pictographic characters are stripped from menu, mode, panel and quick add names on screen. Give icons as an icon name (prefab · block · light · trigger · logic …) in the Icon field.
Registration pointData typeSDKIn the editor
AddMenuItemNpMenuItem1.0Menu bar
AddQuickAddItemNpQuickAdd1.0Main toolbar Add
AddCommandNpCommand1.0Console
AddImporter · AddExporterNpFileFormat1.0File menu · Build menu
AddContentTabNpContentTab1.0Bottom area panel (Window menu)
AddModeNpMode1.0Mode row · Tool panel · viewport clicks
AddActorTypeNpActorType1.0Type column of the Outliner
AddCellGuardFunc<int,int,int,bool>1.0Every block edit
AddSymmetryFunc<IReadOnlyList<NpBlock>, IEnumerable<NpBlock>>1.0Block brush edits
AddShotScenarioNpShot1.0--np-shot=<id> (development builds)
AddShortcutNpShortcut1.1Tools > Shortcuts…
AddSceneEventNpSceneEvent1.2World logic — Adding world logic types
AddShowFlag · SetShowFlagNpShowFlag1.5Display menu of the viewport bar
AddStatusItemNpStatusItem1.5Status bar at the bottom of the screen
AddWorldReplaceGuardNpWorldReplaceGuard1.5Before New, Open or loading an autosave
  • 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 · Toggled · Poll · Ask) is null, registration throws. The whole plugin then goes to “Error (isolated)”.
  • If a registered callback throws, the plugin is isolated.
  • Order is the order within the same location. Smaller values come first, and the default is 500. Modes, show flags, status bar items and map replace guards always come after built-in items.
public sealed record NpMenuItem(string Id, string Menu, string Label, Action Run, string Shortcut = "", int Order = 500);
FieldDescription
IdItem id
Menu"파일" (File) · "편집" (Edit) · "창" (Window) · "도구" (Tools) · "빌드" (Build) · "도움말" (Help). These keys are Korean in every editor language. Any other name creates a new menu before Help.
LabelText shown in the menu
RunRuns on click
ShortcutShortcut text (for example "Ctrl+Alt+H"). If the key can be parsed, it appears next to the menu text, runs the item, and can be changed in Tools > Shortcuts….
OrderOrder within the menu. A separator appears where the hundreds digit changes (for example between 499 and 500).
  • Items in the Window menu are attached below the panel list and the area items.
  • Put export-type items in the Build menu.
public sealed record NpQuickAdd(string Id, string Label, string Category, Action<NpQuickAddContext> Spawn,
string Keywords = "", int Order = 500, string Icon = "", string IconState = "");
public sealed record NpQuickAddContext(INpWorld World, NpCell Place);
FieldDescription
LabelName shown in the list
CategoryCategory name. A new name creates a new category.
SpawnRuns when the item is chosen. ctx.Place = the cell to place at (the cell the mouse last pointed at in the viewport; if none, the cell in front of the block at the center of the screen)
KeywordsSearch words (separated by spaces). Adding both Korean and English makes the item easier to find. They also appear in the tooltip.
IconIcon name (for example "prefab" · "light")
IconStateBlock state string to draw as the icon. If set, it takes precedence over Icon.
host.AddQuickAddItem(new NpQuickAdd("lamp_post", "Street lamp", "Road", ctx =>
ctx.World.Edit("Street lamp", e =>
{
for (int y = 0; y < 3; y++) e.Set(ctx.Place.X, ctx.Place.Y + y, ctx.Place.Z, "minecraft:dark_oak_fence");
e.Set(ctx.Place.X, ctx.Place.Y + 3, ctx.Place.Z, "minecraft:lantern[hanging=false]");
}),
Keywords: "lamp light 가로등", Icon: "light", IconState: "minecraft:lantern"));
public sealed record NpCommand(string Name, string Usage, string Help, Func<string[], string> Run);
FieldDescription
NameCommand name. No spaces. It gets no prefix, so put your own name in front (for example road_count).
UsageOne line of usage (for example "road_count [block id]")
HelpOne line of description
RunArguments (the words after the name) → result text shown in the console
host.AddCommand(new NpCommand("road_count", "road_count [block id]", "Counts that block in the selection", args =>
{
string id = args.Length > 0 ? args[0] : "minecraft:stone";
long n = host.World.Blocks(host.World.Selection).LongCount(b => b.State.StartsWith(id));
return $"{id}: {n:N0} cells";
}));
  • If the name already exists (built-in or another plugin) or contains a space, that command is not attached.
  • If Run throws, the console shows ”⚠ Plugin error (isolated) — Output Log” as a failure and the plugin is isolated.

AddImporter · AddExporter — file formats

Section titled “AddImporter · AddExporter — file formats”
public sealed record NpFileFormat(string Id, string Label, string[] Extensions, Action<string> Run, int Order = 500);
FieldDescription
LabelMenu text. It appears as Import: <Label> in the File menu and as Export: <Label> in the Build menu.
ExtensionsList of extensions (without the dot, for example new[] { "csv" }). Used for the file dialog filter.
RunReceives the full path of the file the user chose.
OrderOrder within the menu
host.AddExporter(new NpFileFormat("road_stats", "Block stats CSV", new[] { "csv" }, path =>
{
var rows = host.World.Blocks(host.World.Selection)
.GroupBy(b => b.State.Split('[')[0])
.OrderByDescending(g => g.Count())
.Select(g => $"{g.Key},{g.Count()}");
File.WriteAllLines(path, rows.Prepend("block,count"), new System.Text.UTF8Encoding(true));
}));
  • The default file name in the export dialog is <world file name>.<first extension>. For an unsaved world it is world.<first extension>.
  • When an import changes blocks, group the changes in one World.Edit call as well.
public sealed record NpContentTab(string Id, string Label, Func<NpUi> Build, int Order = 500);
FieldDescription
LabelPanel tab title. The panel also appears under this name in the panel list of the Window menu.
BuildPanel content (NpUi). Called once when the plugin is enabled.
OrderOrder in the panel list
int width = 3; bool lamps = true;
host.AddContentTab(new NpContentTab("panel", "Road", () => new NpUi()
.Title("Build road")
.Number("Width", width, 1, 9, 1, v => width = (int)v)
.Check("Street lamps", lamps, v => lamps = v)
.Button("Lay in selection", () => host.Message($"Width {width}"))));
  • The panel is created closed in the bottom area. The user opens it by checking the panel in the Window menu. Right-click the tab to move it to another area or a floating window.
  • The icon is always the plugin image.
  • How to use NpUi is in Panel UI (NpUi).
public sealed record NpMode(string Id, string Label, Func<NpUi>? Panel = null, Func<NpClick, bool>? OnClick = null,
Action? Enter = null, Action? Exit = null, string Shortcut = "", int Order = 500);
public sealed record NpClick(NpCell Hit, NpCell Place, bool Shift, bool Ctrl);
FieldDescription
LabelMode name (mode row tooltip · Tool panel header)
PanelContent shown in the Tool panel. Built once when first shown and reused. If none, only the title appears.
OnClickLeft-click in the viewport. Hit = the block cell that was hit, Place = the cell outside that face (where to place), Shift · Ctrl = keys held at the same time
Enter · ExitWhen entering and leaving the mode
ShortcutShortcut text that switches to the mode
OrderOrder among plugin modes. Plugin modes always come after built-in modes.
host.AddMode(new NpMode("flag", "Plant flag",
Panel: () => new NpUi().Title("Flag").Label("Left-click = flag · Shift+click = erase"),
OnClick: c =>
{
var p = c.Shift ? c.Hit : c.Place;
host.World.Edit(c.Shift ? "Erase flag" : "Flag", e =>
{
if (c.Shift) { for (int i = 0; i < 3; i++) e.Clear(p.X, p.Y + i, p.Z); return; }
e.Set(p.X, p.Y, p.Z, "minecraft:oak_fence");
e.Set(p.X, p.Y + 1, p.Z, "minecraft:oak_fence");
e.Set(p.X, p.Y + 2, p.Z, "minecraft:red_wool");
});
return true;
},
Exit: () => host.Draw.Clear()));
  • If OnClick is set, every left-click in the viewport in that mode goes to OnClick, and the default block placement does not happen. 0.10.2 does not use the return value of OnClick (true and false behave the same).
  • A click that hits no block (the sky) does not call OnClick.
  • Drags cannot be received. Only clicks are received.
  • If the plugin is disabled while its mode is in use, the editor returns to Block brush mode.
public sealed record NpActorType(string Kind, string Label, string Color = "#9a9a9a");
FieldDescription
KindActor kind text. Put your own name in front (for example "myroad.zone").
LabelText in the Type column of the Outliner
ColorColor of the Type column, "#rrggbb". Gray if it cannot be parsed.
host.AddActorType(new NpActorType("myroad.zone", "Road zone", "#44aaff"));
  • Sets the text and color shown when an actor of that kind appears in the Outliner. If the kind already exists (including built-in), only that type is not attached.
  • The SDK has no API for creating actors.
void AddCellGuard(Func<int, int, int, bool> guard);

No edit can change a cell for which the guard returns true. This applies to brushes, shapes, fills, console commands, AI work and World.Edit from other plugins. Undo and redo are not checked.

host.AddCellGuard((x, y, z) => y < 0); // cells below y 0 cannot be changed
  • If there are several guards, any one returning true blocks the cell.
  • It is called for every cell. Keep it very light (a dictionary lookup or a box comparison).
void AddSymmetry(Func<IReadOnlyList<NpBlock>, IEnumerable<NpBlock>> expand);

Receives the list of cells a Block brush edit (place · break · brush · shape · drag box fill) will change and returns an extended list. It runs 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 original cells first. If you leave them out, the original edit disappears. A single-cell place or break treats the first cell of the returned list as the original cell and skips it, so if you change the order, one symmetric cell is lost.
  • If the same cell appears more than once, only the first is used.
  • A cell changed to air (break) has State = "minecraft:air".
public sealed record NpShot(string Id, Func<INpShotApi, Task> Run);
INpShotApi memberDescription
WorldThe world (INpWorld)
LookAt(float ex, float ey, float ez, float tx, float ty, float tz)Points the camera from the eye position to the target point
Frames(int n)Waits n frames (await)
Check(bool ok, string what)Records one verdict (pass · fail)
Shot(string name)Saves the screen as a PNG (await)

The screen verification runner (--np-shot) exists only in editor development builds. In the installed editor, scenarios are registered but do not run. Examples and limits are in Testing and debugging.

public sealed record NpShortcut(string Id, string Label, string Key, Action Run, string Mode = "");
FieldDescription
IdShortcut id. Keys the user rebinds are saved under this id.
LabelName shown in the Shortcuts window. Putting the plugin name in front makes it easier to find (for example "Road: Hollow").
KeyDefault key text. Follows the table below.
RunRuns on that key
Mode"" = everywhere. A mode id = only in that mode. For your own mode, use the id you passed to AddMode as is.
host.AddShortcut(new NpShortcut("hollow_key", "Road: Hollow selection", "Ctrl+Alt+H", () => host.Message("Hollow")));
host.AddShortcut(new NpShortcut("flag_undo", "Flag: Erase last", "Shift+J", () => host.Message("Last flag"), Mode: "flag"));
Key textParsed
Ctrl+Alt+H · ctrl + alt + h · Cmd+K (= Ctrl)Yes
Shift+F5 · Ctrl+Enter · Alt+Space · Ctrl+[Yes
J (one key without modifiers)Yes. It easily collides with built-in keys, so it is not recommended.
1~8 · W/E/R · Ctrl++No → registration throws (“Can’t parse shortcut key”) → the plugin does not enable
  • A key = Ctrl · Alt · Shift plus one key. Key names are a single letter or digit, F1–F24, or names such as Enter · Space · Delete · Esc.
  • Users change keys in Tools > Shortcuts… (Ctrl+Alt+K). Changed keys persist when the plugin is enabled again.
  • A key that collides with another key is still registered. It appears in red in the Shortcuts window.
  • If several bindings use the same key, a key for the current mode takes precedence over an everywhere key. Within the same scope, the key registered first (built-in) wins.

AddShowFlag · SetShowFlag — “Display” menu items

Section titled “AddShowFlag · SetShowFlag — “Display” menu items”
public sealed record NpShowFlag(string Id, string Label, Action<bool> Toggled, string Tooltip = "", bool On = false, int Order = 500);
void SetShowFlag(string id, bool on);
FieldDescription
Id · LabelItem id · menu text. If either is empty, registration throws.
ToggledWhen the user clicks the item. Argument = on (true) · off (false)
TooltipTooltip
OnInitial check state
OrderOrder. Plugin items always come after built-in items.

SetShowFlag(id, on) only sets the check state of an item your plugin registered. It does not call Toggled, and an unknown id does nothing. Use it when you turn the flag on or off from somewhere else, such as a panel or a shortcut.

public sealed record NpStatusItem(string Id, Func<NpStatus?> Poll, Action? Click = null, string Tooltip = "", int Order = 500);
public readonly record struct NpStatus(string Text, int Level = 0, string? Tooltip = null);
FieldDescription
PollThe value to show now. Called every 0.25 seconds on the main thread. null hides the item. Keep it very light.
NpStatus.Level0 = normal · 1 = warning (yellow) · 2 = error (red)
NpStatus.TooltipTooltip for this value. If null, the Tooltip given at registration
ClickRuns on click. If none, the item cannot be clicked.
OrderOrder. Plugin items come after the notification text and the built-in items.

AddWorldReplaceGuard — confirm before replacing the map

Section titled “AddWorldReplaceGuard — confirm before replacing the map”
public sealed record NpWorldReplaceGuard(string Id, Func<NpWorldChangeReason, Action, bool> Ask, int Order = 500);

Before the map is replaced by New, Open or loading an autosave (from menus, shortcuts and other plugins’ menus alike), the editor calls Ask(reason, proceed). The reason is New (New) · Open (Open · loading an autosave) · Replaced (any other world replacement).

ReturnMeaning
trueThe map may be replaced. The editor moves on to the next guard.
falseThis plugin takes over. The replacement stops; when the plugin later calls proceed(), the editor goes through every guard again from the start and then replaces the map.
  • The built-in guards (unsaved changes · live server connection) ask first, and plugin guards ask after them.
  • If the plugin is disabled or Ask throws, the guard does not block (the replacement goes ahead). This keeps a broken plugin from blocking file opening. A plugin that throws is isolated.
  • The SDK has no confirmation dialog API. Ask the user with a notification and a panel button, and when they agree, call the proceed you stored.
  • Do the cleanup after the replacement in WorldChanged.
bool guides = true, dirty = false;
int built = 0, errors = 0;
Action? pending = null;
host.AddShowFlag(new NpShowFlag("guides", "Tower guides", on => guides = on, Tooltip: "Guide lines around towers", On: true));
host.SetShowFlag("guides", false); // when changing it from elsewhere, such as a panel — sets the check only (does not call Toggled)
host.AddStatusItem(new NpStatusItem("count",
() => built == 0 ? null : new NpStatus($"Towers {built}", errors > 0 ? 1 : 0),
Click: () => host.Message("Tower list"), Tooltip: "Number of towers built"));
host.AddWorldReplaceGuard(new NpWorldReplaceGuard("unsaved", (why, proceed) =>
{
if (!dirty) return true; // may replace
pending = proceed; // call this once the user agrees
host.Message("Tower settings are not saved — 'Save and continue' in the 'Towers' panel");
return false; // stop this replacement
}));
host.AddContentTab(new NpContentTab("towers", "Towers", () => new NpUi()
.Button("Save and continue", () =>
{
dirty = false; // … save …
var go = pending; pending = null;
go?.Invoke(); // goes through the guards again from the start, then replaces the map
})));

Write "sdk": "^1.5" in plugin.json.