Quick start
Build your first plugin in 10 minutes. This plugin adds two things.
| Kind | Name | What it does |
|---|---|---|
| Menu item | Tools › 선택 블록 세기 (count selected blocks) | Shows the number of blocks inside the selection box as a notification. |
| Quick add | Add › Preset › 3×3 기둥 (3×3 pillar) | Places a stone brick pillar (3×3, 6 high) at the cell under the mouse. |
You need the .NET 8 SDK and an installed NP Editor. Check the prerequisites table in the Overview first.
1. Create the project
Section titled “1. Create the project”Create three files in one folder.
my_first_plugin/├─ MyFirstPlugin.csproj├─ Plugin.cs└─ plugin.jsonMyFirstPlugin.csproj
Section titled “MyFirstPlugin.csproj”<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>net8.0</TargetFramework> <EnableDynamicLoading>true</EnableDynamicLoading> <Nullable>enable</Nullable> <ImplicitUsings>enable</ImplicitUsings> </PropertyGroup> <ItemGroup> <!-- References the 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>| Setting | Why |
|---|---|
EnableDynamicLoading | Lets the plugin be unloaded from memory when it is disabled. |
Private=false | Does not copy the SDK dll to the output folder. The plugin uses the editor’s SDK. |
ImplicitUsings | Adds default usings such as System.Linq and System.IO automatically. |
Copy plugin.json | plugin.json is placed in the build output folder too. |
Plugin.cs
Section titled “Plugin.cs”using NP.Editor.Sdk;
namespace MyFirstPlugin;
public sealed class Plugin : INpEditorPlugin{ public void Register(INpEditorHost host) { // Tools › Count selected blocks host.AddMenuItem(new NpMenuItem("count", "도구", "선택 블록 세기", () => { if (host.World.Selection is not { } box) { host.Message("먼저 영역을 고르세요"); return; } int n = host.World.Blocks(box).Count(); host.Message($"선택 안 블록 {n:N0}개"); }));
// Add › Preset › 3×3 pillar (placed at the cell under the mouse) host.AddQuickAddItem(new NpQuickAdd("pillar", "3×3 기둥", "프리셋", ctx => ctx.World.Edit("3×3 기둥", 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("준비됨"); }}- The entry class implements
INpEditorPlugin. It must have apublicparameterless constructor. - Attach features inside
Registerwithhost.Add…. - If
Registerthrows, nothing is registered and the plugin is disabled.
plugin.json
Section titled “plugin.json”{ "id": "my_first_plugin", "name": "내 첫 플러그인", "version": "0.1.0", "sdk": "^1.0", "dll": "MyFirstPlugin.dll", "entry": "MyFirstPlugin.Plugin", "description": "선택 블록 세기 + 3×3 기둥", "author": "내 이름"}This plugin uses only SDK 1.0 features, so it uses "sdk": "^1.0". The fields are described in plugin.json.
2. Build
Section titled “2. Build”dotnet build -c ReleaseMyFirstPlugin.dll and plugin.json appear in the output folder (bin\Release\net8.0\).
3. Put it in the plugin folder
Section titled “3. Put it in the plugin folder”- In the editor, select Tools › Open plugin folder.
%APPDATA%\NPEditor\plugins\opens. - Create a
my_first_pluginfolder inside it. - Copy
MyFirstPlugin.dllandplugin.jsoninto it. Do not includeNP.Editor.Sdk.dll. - To debug, also include
MyFirstPlugin.pdb.
4. Enable it
Section titled “4. Enable it”- Open Tools › Plugin Manager….
- Click Rescan.
- The first time, a security warning appears. Click Trusted — load.
- You are done when the list shows 내 첫 플러그인 as On.
5. Verify
Section titled “5. Verify”| Where | What you should see |
|---|---|
| Output Log | [my_first_plugin] 준비됨 |
| Plugin Manager Registered column | Menu 1 · Quick add 1 |
| Menu bar | Tools › 선택 블록 세기 |
| Main toolbar Add | 3×3 기둥 in the Preset category (search for 기둥) |
- Place a few blocks, select a region, then select Tools › 선택 블록 세기. A notification with the block count appears.
- Select Add › 3×3 기둥. A pillar appears.
- A single Ctrl+Z removes the whole pillar.
6. Edit and reload
Section titled “6. Edit and reload”The editor does not lock the dll file. You can rebuild while the editor is running.
- Edit the code and rebuild.
- Overwrite the dll in the plugin folder with the new one.
- In the Plugin Manager, select that row and click Reload (selected).
Enter
pluginsin the console to list plugins and their status.plugins reloadrescans the folders.
Next steps
Section titled “Next steps”- More registration points: Registration points
- A sample with a settings tab, shortcuts and 3D drawing: Sample: hello_tool
- When the plugin does not enable: Troubleshooting