Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigation/Pathing seems to bypass MemoryNPCDataStore #1789

FerusGrim opened this issue May 19, 2019 · 3 comments


None yet
3 participants
Copy link

commented May 19, 2019

The output of command /version on my server is:

This server is running Paper version git-Paper-"b72508c2" (MC: 1.12.2) (Implementing API version 1.12.2-R0.1-SNAPSHOT)
Previous version: git-Paper-"28f5c6a7" (MC: 1.12.2)

The output of command /version citizens on my server is:

Citizens version 2.0.24-SNAPSHOT (build Unknown)
Authors: aPunch and fullwall

Logs not included; don't contain any pertinent information.

Excerpt from saves.yml:

    name: Guard
    uuid: 5f93bffe-05f9-4b8b-9584-827a3a0047b3
      type: PLAYER
        x: '0.0'
        y: '0.0'
        z: '0.0'
        yaw: '0.0'
        pitch: '0.0'
      spawned: true
        owner: server
        uuid: ''
    traitnames: type,spawned,mounttrait,location,owner
      pathfindingrange: '50.0'
      distancemargin: '0.0'
      speedmodifier: '1.0'
      avoidwater: false
      usedefaultstuckaction: true

The Issue

I'm programmatically creating NPCs do perform specific functions. This creation is not meant to be saved to configuration, so I've used a MemoryNPCDataStore which is supposed to not save anything:

    private static NPCRegistry getRegistry() {
        final NPCRegistry registry = CitizensAPI.getNamedNPCRegistry(REGISTRY_NAME);
        if (registry == null) {
            return CitizensAPI.createNamedNPCRegistry(REGISTRY_NAME, new MemoryNPCDataStore());
        return registry;

Simple enough.

Unfortunately, for whatever reason, some of the entities are being saved, regardless. And it seems as if it's only the NPCs which make use of pathing/navigation. None of my other NPCs are being stored to saves.yml.

From what I can gather, the XYZ values are blank, and the information being saved doesn't seem to actually reflect what they're being used for (except the accurate navigational values, such as range and margin), but they're being saved, taking up space, and incrementing the last-created-npc-id value.


This comment has been minimized.

Copy link

commented May 23, 2019

How are the navigation NPCs being spawned/created? I don't see how this is possible unless you are using the global registry somehow. You can also use NPC.SHOULD_SAVE_METADATA if you want a different solution.


This comment has been minimized.

Copy link

commented May 24, 2019

Running a quick test, not only can I confirm that I'm not calling the global registry to create an NPC, I'm not calling the global registry in my entire project.

The NPC is created within an NpcController abstract class which is shared amongst all my NPCs. The only difference between the type of NPC which is being saved to saves.yml and the others is that I'm using pathing for this kind.

Creation in NpcController:

    public NPC getNpc() {
        if (this.npc == null) {
            this.npc = getRegistry().createNPC(EntityType.PLAYER, this.getSkin());
  , false);
        return this.npc;

    protected abstract String getSkin();

    protected void onNpcCreate(NPC npc) {


onNpcCreate from Guard:

    public void onNpcCreate(NPC npc) {

updateNavigation from Guard:

    public void updateNavigation(boolean onSpawn) {
        final GuardConfig config = this.getCachedConfig();
        if (config.getPath().size() < 2) {

        if (config.getPath().size() <= this.goal + 1) {
            this.goal = -1;

        if (!onSpawn) {

        final NPC npc = this.getNpc();
        if (npc.isSpawned()) {

Note that GuardConfig is entirely separate from NPCs. All I'm pulling from it is the predefined path for the NPCs to follow. Perhaps not the most elegant solution, but certainly nothing (that I can think of) which should be making any saves to the global configuration.

EDIT: To clarify again, GuardConfig is something stored elsewhere in the project. It's not something to do with NPCs that I've merely renamed.


This comment has been minimized.

Copy link

commented May 24, 2019

I'm really confused because the only way to be saved in the saves.yml is for the NPC to be registered to the global registry somehow and the only way for that is for createNPC to be called.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.