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

Quick start

Create a first plugin that adds one menu item and one quick add item, build it and enable it in the editor. You need a .NET SDK (8 or later) and an installed NP Editor 0.10.2. Check the prerequisites table in the Overview first.

KindName on screenWhat it does
Menu itemCount selected blocks in the Tools menuShows the number of blocks inside the selection box as a notification.
Quick add3×3 pillar in the Preset category of the main toolbar Add listPlaces a stone brick pillar (3×3, 6 blocks high) at the cell the mouse points at.
  1. Create an empty folder my_first_plugin and create MyFirstPlugin.csproj in it.

    <Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <EnableDynamicLoading>true</EnableDynamicLoading>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    </PropertyGroup>
    <ItemGroup>
    <!-- SDK dll in the editor install folder. If you changed the install folder, change this path too. -->
    <Reference Include="NP.Editor.Sdk">
    <HintPath>$(LOCALAPPDATA)\Programs\NP Editor\data_NPEditor_windows_x86_64\NP.Editor.Sdk.dll</HintPath>
    <Private>false</Private>
    </Reference>
    </ItemGroup>
    <ItemGroup>
    <None Include="plugin.json" CopyToOutputDirectory="PreserveNewest" />
    </ItemGroup>
    </Project>
  2. Create Plugin.cs in the same folder.

    using NP.Editor.Sdk;
    namespace MyFirstPlugin;
    public sealed class Plugin : INpEditorPlugin
    {
    public void Register(INpEditorHost host)
    {
    // Tools > Count selected blocks ("도구" is the editor's key for the Tools menu — keep it in Korean)
    host.AddMenuItem(new NpMenuItem("count", "도구", "Count selected blocks", () =>
    {
    if (host.World.Selection is not { } box) { host.Message("No selection"); return; }
    int n = host.World.Blocks(box).Count();
    host.Message($"{n:N0} blocks in the selection");
    }));
    // Add > Preset > 3×3 pillar, placed at the cell under the mouse ("프리셋" is the key of the built-in Preset category — keep it in Korean)
    host.AddQuickAddItem(new NpQuickAdd("pillar", "3×3 pillar", "프리셋", ctx =>
    ctx.World.Edit("3×3 pillar", e => // one Edit = one undo step
    {
    for (int y = 0; y < 6; y++)
    for (int x = 0; x < 3; x++)
    for (int z = 0; z < 3; z++)
    e.Set(ctx.Place.X + x, ctx.Place.Y + y, ctx.Place.Z + z, "minecraft:stone_bricks");
    }),
    Keywords: "pillar column 기둥", Icon: "prefab", IconState: "minecraft:stone_bricks"));
    host.Log("Ready");
    }
    }
  3. Create plugin.json in the same folder. This plugin uses only SDK 1.0 features, so sdk is ^1.0.

    {
    "id": "my_first_plugin",
    "name": "My first plugin",
    "version": "0.1.0",
    "sdk": "^1.0",
    "dll": "MyFirstPlugin.dll",
    "entry": "MyFirstPlugin.Plugin",
    "description": "Count selected blocks + 3×3 pillar",
    "author": "Your name"
    }
  4. Run dotnet build -c Release in that folder. MyFirstPlugin.dll and plugin.json appear in bin\Release\net8.0\.

  5. In the editor, click Tools > Open plugin folder. The %APPDATA%\NPEditor\plugins\ folder opens.

  6. Create a my_first_plugin folder inside it and copy MyFirstPlugin.dll and plugin.json into it. Do not copy NP.Editor.Sdk.dll.

  7. Click Tools > Plugin Manager…. My first plugin appears in the list with the status “Approval needed”.

  8. Check Enable on that row.

  9. The first time, the External plugins confirmation window appears. Click Trusted — load.

    The External plugins confirmation window with the Trusted — load button outlined in red

  10. Check that the row’s status is “On” and that the Registered column shows 메뉴 1 · 빠른 추가 1.

    The Plugin Manager window with the My first plugin row enabled, status On and Registered 메뉴 1 · 빠른 추가 1

    Known issue in 0.10.2: the Registered column shows the registration summary in Korean. 메뉴 1 · 빠른 추가 1 means “Menu 1 · Quick add 1”.

  11. Place a few blocks, select a region, then click Count selected blocks in the Tools menu. A notification with the block count appears at the bottom of the screen.

  12. In the viewport, move the mouse over a floor block, click Add on the main toolbar, type pillar in the search field and click 3×3 pillar. The pillar appears at the cell the mouse last pointed at in the viewport.

  13. Press Ctrl+Z to undo. The whole pillar disappears at once.

  • Edit and reload: the editor does not lock the dll. Edit the code and rebuild, overwrite the dll in the same plugin folder with the new one, then select that row in the Plugin Manager and click Reload (selected). You do not need to restart the editor.
  • Overwrite in the same folder: the approval is remembered by plugin id and full folder path. If you overwrite the files in the same folder, you do not need to allow the plugin again. If you move the folder or change the id, it goes back to “Approval needed”.
  • Copy on every build: add a post-build copy step to the csproj and you no longer need step 6. See “Copy after build” in Testing and debugging.
  • Check from the console: type plugins in the Console to see the list and states, or plugins reload to see the result of rescanning the folders.
  • Output log: text from host.Log appears in the Output Log panel as [my_first_plugin] Ready.
SettingWhy
TargetFramework = net8.0The .NET runtime inside the editor is 8. A dll built for a newer target (net9.0 and so on) does not load.
EnableDynamicLoadingLets the plugin be unloaded from memory when it is disabled, and copies NuGet dependency dlls to the output folder too.
Private=falseDoes not copy the SDK dll to the output folder. The plugin uses the editor’s SDK.
ImplicitUsingsAdds default usings such as System.Linq and System.IO automatically.
Copy plugin.jsonplugin.json appears in the build output folder too.
  • The entry class implements INpEditorPlugin and must have a public parameterless constructor.
  • Attach features inside Register with host.Add….
  • If Register throws, nothing is registered and the plugin goes to the “Error (isolated)” state.