Preset - MarkusBordihn/BOs-Easy-NPC GitHub Wiki
Presets let you save, share, import, and export NPC data. The current code supports both binary NBT presets and text-based SNBT presets.
Supported file formats:
.npc.nbt.npc.snbt
Preset files can also contain compatible third-party entity data that belongs to the NPC.
A preset can carry metadata that the preset browser shows instead of a bare file name:
PresetMetadata:{
name:"Welcome Coin Trader",
category:"Villager",
author:"Kaworru",
version:"1.0.0",
description:"A daily welcome trader who gives one custom named NPC coin per player per day.",
entityTypeId:"easy_npc:villager",
variantType:"PLAINS_LIBRARIAN"
}
created and modified are timestamps and are written automatically. Adding metadata is
recommended for any preset library shipped in a modpack or data pack.
The built-in presets all carry metadata โ see Default Presets.
Easy NPC currently distinguishes between these preset sources:
-
defaultfor presets shipped with the mod -
datafor presets loaded from data packs or other resources -
customfor presets stored inconfig/easy_npc/preset -
worldfor presets stored in the current world -
localfor client-local presets used by the UI
local presets are not available through the server import command.
Import an existing preset:
/easy_npc preset import custom <preset> [position] [uuid]
/easy_npc preset import data <preset> [position] [uuid]
/easy_npc preset import default <preset> [position] [uuid]
/easy_npc preset import world <preset> [position] [uuid]Import a preset as a new NPC with a new UUID:
/easy_npc preset import_new custom <preset> [position]
/easy_npc preset import_new data <preset> [position]
/easy_npc preset import_new default <preset> [position]
/easy_npc preset import_new world <preset> [position]Import a preset as a new NPC and assign an owner immediately:
/easy_npc preset import_with_owner custom <preset> <player> <position>
/easy_npc preset import_with_owner data <preset> <player> <position>
/easy_npc preset import_with_owner default <preset> <player> <position>
/easy_npc preset import_with_owner world <preset> <player> <position>If you provide a UUID to preset import, Easy NPC first tries to update an existing NPC with that
UUID. If that is not possible, it spawns a new NPC with the imported data.

Both import commands accept a pattern instead of a single preset:
/easy_npc preset import <type> matching <pattern> [confirm]
/easy_npc preset import_new <type> matching <pattern> [position] [confirm]The pattern is matched against the preset name without its file extension. * stands for any number
of characters and is the only wildcard; at least three fixed characters have to come before it, so
test_case_* works while * and a* are rejected. A pattern containing / is matched against the
full preset path instead of the name.
Four guards run before the first NPC is created:
-
npcPresetBatchLimit(default 10) aborts the command if the pattern matches more presets, instead of silently importing only part of them. - Without the trailing
confirmthe command only reports what it would do as soon as an existing NPC would be overwritten or more presets match thannpcPresetBatchConfirmThreshold(default 5). -
npcPresetBatchCooldown(default 30 seconds) limits how often a player may start a batch import. - The regular spawn rate limit applies as well and may grant only part of a batch.
import matching restores every match under its stored ID at its stored position and can therefore
overwrite existing NPCs. import_new matching always creates copies with fresh IDs and spreads them
around the given position. Commands run from the console or a command block skip the cooldown and
the
rate limit.
Local import is available through the Config UI. These presets are read from the local client config directory and are not shared automatically with the server or other players.
Server command note:
/easy_npc preset import localThis command is currently rejected by the server and only exists to tell you that local preset import is handled client-side.

Export the selected NPC:
/easy_npc preset export local <NPC> [name]
/easy_npc preset export custom <NPC> [name]
/easy_npc preset export world <NPC> [name]Export targets:
-
localwrites to the player-local config preset directory -
customwrites toconfig/easy_npc/preset -
worldwrites to the world preset storage

Preset import is sanitized on the server before the NPC is created or updated.
Depending on the importing player and the current security config, the server may:
- rewrite the owner
- remove owner data
- remove trading
- remove objectives
- remove movement and attribute data
- remove blocked action entries
- clamp command permission levels
If sanitizing changes the imported preset, the importing player receives a short warning in chat.
The preset browser uses the same security rules to show a preview before import:
- allowed features
- blocked features
- reduced command authority
Preset export removes runtime state before saving, so an exported preset describes the NPC itself and not the moment it was exported. This includes:
- momentary physics state such as motion, fall distance, air, fire and ground contact
- momentary damage state such as health absorption, hurt timers and death time
- the last update, last save and spawn action timestamps
- the stored action authority
The entity UUID, the position and the rotation are kept. They are what allows an export to be imported back as the same NPC later on.
Whether an import restores the original NPC or creates a copy depends on the way you import it.
The stored identity is kept by:
-
/easy_npc preset importandimport matching - the preset browser button "Restore"
A new identity is assigned by:
-
/easy_npc preset import_newandimport_new matching /easy_npc preset import_with_owner- the preset browser button "Spawn New"
- the preset item
- the spawner block
Restoring requires the feature.POSITION permission, because it places the NPC at its stored
position. Without that permission the browser refuses the action instead of spawning a copy
somewhere else.
Common preset locations used by the code:
config/easy_npc/preset- world preset storage managed by Easy NPC
- built-in resource locations for
defaultanddata
The exact resource path depends on the preset type and the selected skin model.
The Config UI still provides dedicated screens for:
- local import
- default import
- custom import
- world import
- custom export
- world export
Those screens use the same handler and sanitizing rules as the command-based import and export paths.
