Skip to content
NP Editor Docs

Host API

The host you receive in Register(INpEditorHost host) is the starting point for every plugin feature. This page covers info, notifications, the world, events, settings, 3D drawing and the account. The Add… registration points are in Registration points, and Scene · View are in Scene access and play camera. All types are in the NP.Editor.Sdk namespace.

  1. Store the host you receive in Register in a field. Use the same host inside callbacks.

  2. Read the world through host.World. Even after a new world is opened, host.World always points to the current world.

  3. To change blocks, group the changes in one host.World.Edit(label, e => { … }) call. One call is one undo step.

    int n = host.World.Edit("Stone floor", e =>
    {
    for (int x = 0; x < 8; x++)
    for (int z = 0; z < 8; z++)
    e.Set(x, 0, z, "minecraft:stone");
    });
    host.Message($"{n} cells changed (Ctrl+Z to undo)");
  4. Tell the user the result with host.Message, and keep detailed records in the Output Log with host.Log.

  5. Clear your state in host.WorldChanged so you are ready when a new world or another world is opened.

  • Use the return value of Edit (the number of cells actually changed) to see whether locked cells were skipped. If it is smaller than the number of cells you set, a lock, a protected area or a cell guard blocked them.
  • Do not call Edit while iterating Blocks(). Get the list first with .ToList(), then make changes.
  • Committed fires for user edits, AI work and edits from other plugins alike. Some steps have many cells, so count only Changes.Count instead of reading each change.
  • Separate results for the user (Message) from detailed debug text (Log). Message is also written to the %APPDATA%\NPEditor\logs\godot.log file, but Log appears only in the Output Log panel.
  • Write 3D drawing as “clear everything and redraw”. Keep one function that calls Draw.Clear() and then adds everything again, and call that function whenever the state changes.
MemberTypeSDKDescription
SdkVersionstring1.0The editor’s SDK version (0.11.1 = "1.5.0")
EditorVersionstring1.0The editor version (for example "0.11.1")
PluginIdstring1.0The id from your plugin.json
PluginDirstring1.0The folder containing your plugin.json (full path)
WorldINpWorld1.0The current world
WorldChangedevent Action<NpWorldChange>?1.0When the world changes
Committedevent Action<NpCommit>?1.0Each time an undo step completes
Message(string text)void1.0A short notification (status bar · viewport notification · Output Log)
Log(string text)void1.0One Output Log line [<id>] <text>
SettingsINpSettings1.1This plugin’s settings store
DrawINpDraw1.13D overlay drawing in the viewport
SceneINpScene1.3Read scene actors — Scene access and play camera
ViewINpView1.3Play state · camera — Scene access and play camera
AccountINpAccount1.4Read-only account license — see “Account” below
Add… · SetShowFlagvoid1.0~1.5Registration points — Registration points
MemberTypeDescription
FilePathstring?The current file path. null for a new, unsaved world
SelectionNpBox?The current selection box. null if none
BoundsNpBox?The extent that contains blocks. null for an empty world. It scans the whole world, so do not call it often.
GetBlock(int x, int y, int z)stringThe block state string. Air is "minecraft:air"
IsAir(int x, int y, int z)boolWhether the cell is air
Blocks(NpBox? box = null)IEnumerable<NpBlock>Every non-air cell. If box is given, only cells inside it (chunks that do not touch the box are skipped)
CountBlocks()longThe number of non-air blocks
Edit(string label, Action<INpEdit> build)intChanges blocks. One call = one undo step. Returns the number of cells actually changed

INpEdit is used inside Edit.

MemberDescription
Set(int x, int y, int z, string state)Sets the cell to the block state string. An empty string, "air" or "minecraft:air" is air.
Clear(int x, int y, int z)Sets the cell to air.
  • label is the name shown in the undo history.
  • Locked cells are skipped. Locked cells = cells blocked by a Co-building region lock, a locked actor, a protected area or a cell guard (AddCellGuard).
  • If another large edit (fill, terrain and so on) is running, InvalidOperationException (“Another edit is in progress — try again when it finishes”) is thrown. The same exception (“Syncing with the server (resume) — try again after it finishes”) is thrown while a live server resume is syncing the map with the server (since 0.11.0). If you do not catch it, the plugin is isolated.
  • Block state strings are not validated; they are written exactly as given. Write them precisely in the Minecraft format (namespace:id[property=value,…]) and do not omit the namespace (minecraft:). Custom blocks are np:<id>.
TypeDeclarationDescription
NpCellreadonly record struct NpCell(int X, int Y, int Z)One cell (block coordinates)
NpBlockreadonly record struct NpBlock(int X, int Y, int Z, string State)Cell + block state string
NpBoxreadonly record struct NpBox(NpCell Min, NpCell Max)Box (both ends inclusive). SizeX · SizeY · SizeZ · Contains(x, y, z)
NpVec3readonly record struct NpVec3(float X, float Y, float Z)3D point (one block = 1). NpVec3.Center(NpCell) = center of the cell
NpWorldChangesealed record NpWorldChange(NpWorldChangeReason Reason, string? Path)Why the world changed, and the file path
NpWorldChangeReasonenum { New, Open, Replaced, ShotScenario }New · open · world replaced · screen verification started
NpCommitsealed record NpCommit(string Label, IReadOnlyList<NpBlockChange> Changes)One undo step
NpBlockChangereadonly record struct NpBlockChange(int X, int Y, int Z, string Old, string New)The before and after state of one cell
EventWhenValue passedWhat to do
WorldChangedNew · open · world replaced · screen verification startedNpWorldChangeClear your state (previews · selection · drawings · check results).
CommittedEach time an undo step completesNpCommitLogging and statistics only. Keep it light.
var towers = new List<NpCell>();
int edits = 0;
host.WorldChanged += c =>
{
towers.Clear();
host.Draw.Clear();
};
host.Committed += c => edits += c.Changes.Count; // keep it light
  • Changes in Committed builds block names when it is read. If there are many cells, look only at Count.
  • If a handler throws, the plugin is isolated.
  • Host events are unhooked automatically when the plugin is unloaded, and -= does nothing. To stop handling, filter with a flag inside the handler.
MemberWhere it appearsWhen to use
Message(text)Left side of the status bar (shortened, full text in the tooltip) · viewport notification · Output Log · logs\godot.logTo tell the user a result
Log(text)Output Log panel ([<id>] …)Debug records · detailed results

Each plugin has one key–value (string) store. Every Set is written to the file immediately, and values persist across editor restarts and plugin reloads.

MemberTypeDescription
KeysIReadOnlyCollection<string>List of stored keys
Get(string key)string?The value. null if missing
Get(string key, string fallback)stringThe value. fallback if missing
GetInt(string key, int fallback = 0)intRead as an integer. fallback if it cannot be read
GetDouble(string key, double fallback = 0)doubleRead as a floating-point number (dot decimal)
GetBool(string key, bool fallback = false)boolRead as "true" / "false"
Set(string key, string? value)voidStore. null deletes the key. An empty key throws.
SetInt · SetDouble · SetBoolvoidTyped store
Changedevent Action<string>?When a value changes or is deleted (key name)
int height = host.Settings.GetInt("height", 12);
var ui = new NpUi()
.Number("Height", height, 4, 64, 1, v => { height = (int)v; host.Settings.SetInt("height", height); }); // save as soon as it changes
ItemValue
File%APPDATA%\NPEditor\plugin_settings\<id>.json
Format{"format":"np-plugin-settings","version":1,"values":{…}}
Same valueSetting the same value again does not write the file.
Corrupt fileStarts with empty settings and keeps the old file next to it as <id>.json.bad. The Output Log records a “Couldn’t read settings file, starting with empty settings” line.
Large dataDo not store it here. Every Set rewrites the whole file. Keep data of several MB in your own files under PluginDir.

Draws lines, boxes and text over the viewport. It does not affect blocks, selection or clicks. Coordinates are world coordinates (one block = 1), and colors are "#rrggbb".

MemberDescription
CountNumber of items currently drawn
Line(NpVec3 a, NpVec3 b, string color = "#ffcc33")Line
Box(NpVec3 min, NpVec3 max, string color = "#ffcc33", bool filled = false, float alpha = 0.25f)Box edge lines. If filled, translucent faces are drawn too.
Cell(NpCell c, string color = "#ffcc33", bool filled = false)Box around one block cell (slightly larger)
Text(NpVec3 at, string text, string color = "#ffffff", float size = 1f)Text that always faces the camera. size = scale relative to block height
Clear()Clears everything
void Redraw()
{
host.Draw.Clear(); // when redrawing, clear and draw everything
if (host.World.Selection is not { } b) return;
host.Draw.Box(new NpVec3(b.Min.X, b.Min.Y, b.Min.Z),
new NpVec3(b.Max.X + 1, b.Max.Y + 1, b.Max.Z + 1), "#ffcc33", filled: true, alpha: 0.1f);
host.Draw.Text(new NpVec3(b.Min.X, b.Max.Y + 2, b.Min.Z), $"{b.SizeX}×{b.SizeY}×{b.SizeZ}");
}
LimitValue
Maximum count20,000 per plugin. Anything beyond is ignored.
Text lengthUp to 200 characters
size0.1 – 20
alpha0 – 1
min · max of BoxDrawn correctly even if swapped.
When the plugin is disabledCleared automatically.

Read-only access to the license of the account signed in to the editor. The tier is decided only by a license the server has signed, and the raw license (signed text) is never given to plugins.

MemberTypeDescription
TierstringTier text: free · supporter · builder · studio · partner · beta · dev. Other values may come in the future, so decide only with Has when the text is unknown.
Has(string feature)boolWhether the license has that feature code (for example editor_pro · beta_builds · ai_mapgen · mcp_web · collab_plus)
Changedevent Action?When the license changes (sign-in · daily refresh · expiry). Called on the main thread.
public sealed class Plugin : INpEditorPlugin, IDisposable
{
private INpEditorHost _h = null!;
private bool _pro;
private Action? _onAccount;
public void Register(INpEditorHost host)
{
_h = host;
_pro = host.Account.Has("editor_pro");
_onAccount = () => _pro = _h.Account.Has("editor_pro");
host.Account.Changed += _onAccount;
}
public void Dispose()
{
if (_onAccount != null) _h.Account.Changed -= _onAccount; // only this event must be unhooked by hand
}
}
  • Server features are checked again by the server when they run. Use the Has result only to decide whether to show a button.
  • In development builds with the license check turned off, Tier is dev and Has always returns true.
  • Unlike other host events, Account.Changed is not unhooked automatically when the plugin unloads. Unhook it with -= in Dispose. Exceptions thrown by the handler are not isolated; they are ignored.