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

Sample: csv_export

A sample that exports the per-block-type counts of the world (or the selection) to CSV. It has the id csv_export, SDK ^1.0 and version 1.0.0, and appears in the Plugin Manager as 블록 통계 CSV (예제) (block statistics CSV, sample). It uses only SDK 1.0 features. The sample’s UI text is Korean only, so this page quotes it as shown on screen, with an English gloss.

What it showsCode
Export formatAddExporter · NpFileFormat
Console command with argumentsAddCommand
Watching editsCommitted
Clearing state in a new worldWorldChanged
Easy-to-test structureCalculation functions (Stats · ToCsv) moved out as static functions that take only an INpWorld

The source is in samples/plugins/csv_export/ in the NP Editor repository (Plugin.cs · CsvExport.csproj · plugin.json).

  1. From the repository root, run dotnet build samples/plugins/csv_export/CsvExport.csproj -c Release. The output goes to %LOCALAPPDATA%\NPEditorBuild\CsvExport\bin\Release\net8.0\.
  2. Copy CsvExport.dll and plugin.json from the output to %APPDATA%\NPEditor\plugins\csv_export\. Do not include NP.Editor.Sdk.dll.
  3. Click Tools > Plugin Manager…, then check Enable on the 블록 통계 CSV (예제) row shown as “Approval needed”. The first time, click Trusted — load.
  4. Open a map. To count only part of it, select a region.
  5. In the Build menu, click Export: 블록 통계 CSV (block statistics CSV).
  6. In the save dialog, type a file name and save. The default name is <world name>.csv.
  7. The notification “블록 통계 CSV: 종 → ” (block statistics CSV: types → ) appears at the bottom of the screen.
  • To see the result directly without exporting, type blockstats 3 in the Console (the number is an example).

    > blockstats 3
    블록 2,304칸 · 4종 · 편집 2번(2,304칸)
    minecraft:grass_block 2,048
    minecraft:stone_bricks 200
    minecraft:oak_stairs 40
  • The CSV is written as UTF-8 with BOM, so Korean text does not break when you open it in Excel.

  • Stats · ToCsv take only an INpWorld, so you can test them without the editor using the fake world in Testing and debugging.

KindNameDescription
ExportExport: 블록 통계 CSV in the Build menu (.csv)Writes the count and ratio per block state to CSV. If there is a selection, only inside it; otherwise the whole world. Air is not counted.
Commandblockstats [n]Shows the total cell count · type count · edit count and the top n rows by count (default 5). If there is a selection, counts only inside it.
EventCommittedCounts the undo steps and changed cells since the plugin was enabled (or since a new world).
EventWorldChangedResets the edit count to 0.
ColumnContentsExample
blockBlock id without propertiesminecraft:oak_stairs
stateFull block state string"minecraft:oak_stairs[facing=east,half=bottom]"
countNumber of cells40
percent% of the total (up to 3 decimal places, dot decimal)1.736
  • The first line is block,state,count,percent.
  • Rows are sorted by count, largest first; ties are sorted by state name.
  • Values that contain commas or double quotes are wrapped in double quotes. A state with two or more properties is such a case.
  • Counts are per block state. The blockstats rows show ids without properties, so the same id can appear on several rows (stairs facing different directions and so on).
  • The plugin.json description says “파일 › 내보내기” (File > Export), but the export item is in the Build menu.
  • In a large world it scans the whole world, so it takes time, and the editor freezes meanwhile.
  • The edit count is kept in memory only. It is 0 after you restart the editor.
  • If you move the sample out of the source tree to build it, change the csproj’s SDK project reference to a reference to NP.Editor.Sdk.dll in the install folder, as in Quick start.
VersionDateDetails
1.0.0—First version: export 블록 통계 CSV · command blockstats · Committed edit count