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

Villager NPCs not working #1987

Open
SkytAsul opened this issue Dec 12, 2019 · 11 comments
Open

Villager NPCs not working #1987

SkytAsul opened this issue Dec 12, 2019 · 11 comments

Comments

@SkytAsul
Copy link
Contributor

@SkytAsul SkytAsul commented Dec 12, 2019

The output of command /version on my server is: git-Spigot-f39a89e-73698cf (MC 1.15)
The output of command /version citizens on my server is: 2.0.26 build 1789

Hello,
After switching to Spigot 1.15, all my existing villagers NPCs have disappeared. I mean, they are still saved etc., but they don't have an entity. Creating a player NPC and doing /npc type villager makes the NPC disappear as well.

@fullwall

This comment has been minimized.

Copy link
Member

@fullwall fullwall commented Dec 13, 2019

Which plugins are you using? Can see villagers here.

@SkytAsul

This comment has been minimized.

Copy link
Contributor Author

@SkytAsul SkytAsul commented Dec 13, 2019

WorldEdit, WorldGuard, Vault, LuckPerms, Citizens and a few of mine that I guarantee don't have anything to do with entity spawning.

EDIT: spawning villagers through spawn eggs is working

@YourCoalAlt

This comment has been minimized.

Copy link

@YourCoalAlt YourCoalAlt commented Dec 15, 2019

I am not sure if this is related, but when I try to grab the villager entity is throws an NPE and the NPCs do not spawn

NPC npc = CitizensAPI.getNPCRegistry().createNPC(EntityType.VILLAGER, displayName);
npc.spawn(location);
Entity ent = npc.getEntity();
ent.setCustomNameVisible(true);
ent.setCustomName(displayName); <-- Error happens here b/c npc.getEntity() is null?

@mcmonkey4eva

This comment has been minimized.

Copy link
Member

@mcmonkey4eva mcmonkey4eva commented Dec 16, 2019

If entity was null, it would happen on the second-to-last line, not the last @YourCoalAlt

@YourCoalAlt

This comment has been minimized.

Copy link

@YourCoalAlt YourCoalAlt commented Dec 16, 2019

Whoops I meant to put it there my bad, must've been tired when I wrote that

@YourCoalAlt

This comment has been minimized.

Copy link

@YourCoalAlt YourCoalAlt commented Dec 18, 2019

yeah something funky is happening and I cannot figure out why.

Codewise, I made a plugin just to do the following:

NPC npc = CitizensAPI.getNPCRegistry().createNPC(EntityType.VILLAGER, displayName);
npc.spawn(location);
Bukkit.getLogger().info("Checking existence for "+npc.getName());
Bukkit.getLogger().info(npc.getEntity() != null ? "Is real" : "Is null");

The NPC exists, however npc.getEntity() is always null and no entity is spawned (god 1.14 all over again). When it comes to just creating one with commands, that also fails for me as well. Hopefully this helps

@mcmonkey4eva

This comment has been minimized.

Copy link
Member

@mcmonkey4eva mcmonkey4eva commented Dec 18, 2019

In my local testing (in 1.15.1 now), /npc create bob --type villager works with no issues, a villager NPC appears.

@YourCoalAlt

This comment has been minimized.

Copy link

@YourCoalAlt YourCoalAlt commented Dec 19, 2019

After updating to 1.15.1, the command now works. However, I am now coming to the conclusion that the .spawn method does not work in the code I provided above. After checking npc.isSpawned, it returns false.

EDIT: Was there a change where NPCs can only spawn if a player is online and at that location? That seems to be what is happening with my issue.

@mcmonkey4eva

This comment has been minimized.

Copy link
Member

@mcmonkey4eva mcmonkey4eva commented Dec 19, 2019

@YourCoalAlt that's not a change, that's always been the case. An NPC cannot spawn into an unloaded area.

@YourCoalAlt

This comment has been minimized.

Copy link

@YourCoalAlt YourCoalAlt commented Dec 19, 2019

I've never experienced this before, it used to work fine whether a player was on or not, and I always force load the chunk. Interesting this didn't effect me until now.

@mcmonkey4eva

This comment has been minimized.

Copy link
Member

@mcmonkey4eva mcmonkey4eva commented Dec 19, 2019

A forceloaded chunk without a player nearby is basically non-guaranteed. There's no definitive guarantee they will spawn and work, but there also isn't a guarantee that they won't. For the most part theoretically NPCs will automatically despawn when players are not nearby, even if the chunk isn't yet unloaded serverside - though exactly how and when varies based on implementation details. Mobs in vanilla minecraft work on a similar principle of despawning based on player distance, not chunk loading.

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