CitizensDev / Citizens2

Citizens - the premier plugin and API for creating server-side NPCs in Minecraft.
https://citizensnpcs.co
Open Software License 3.0
590 stars 313 forks source link

NPCs spawning far away are invisible client-side #2132

Closed Ferocimo closed 4 years ago

Ferocimo commented 4 years ago

Hello,

We have an important issue with our Citizens and Sentinels. They become invisible when they spawn far away from a player, and then come to the player.

For instance, let's say we have a Sentinel that is guarding a wall, going from point A to point B. Points A and B are separated by a distance of 70 blocks. Point A is the respawn point of the NPC. Player is at point B, the NPC spots him and attack him. Player kills the NPC. NPC respawn at point A, and proceed to resume its walk toward point B. If player is still at point B, he won't see the NPC because it has respawned while he was far away from that NPC. As a result, the NPC will attack him but the player won't be able to fight back, being attacked by an invisible NPC.

I think this occurs because of the render distance of players. In this example we have a render distance of 60 blocks for players and entities, meaning that if an entity is further than 60 blocks from the player, the player won't see the entity even if it's there. If he reduces that distance then he will see the entity appears. This functionnality seems in conflict with Citizens.

An easy way to test and reproduce this issue is to do the following : Spawn an NPC. Go a hundred blocks further away. Type /npc move. The NPC will be teleported to you but since it has come directly from a place where you couldn't see it, you won't see that NPC. Interesting note : if you "/npc move" that NPC back to where it originally was, it will appear again.

The only ways for a player to see an invisible Sentinel again are :

The output of command /version on my server is: Paper version git-Paper-229 (MC: 1.15.2) The output of command /version citizens on my server is: Citizens version 2.0.26-SNAPSHOT (build 1921)

Config.yml : https://haste.mineera.fr/ubudusuwub.coffeescript

mcmonkey4eva commented 4 years ago

Sounds likely to be related to https://github.com/CitizensDev/Citizens2/issues/2074

Ferocimo commented 4 years ago

Indeed it seems like it's the same issue. Please note however that this issue has a disastrous consequence on Sentinels since they very often spawn further away from the player, something that wasn't reported in this other issue.

J-SHarper commented 4 years ago

We are having the same issue, and it has a big impact on our use of Sentinel.

TJPlaysNow commented 4 years ago

I fixed this by setting the view distance for players in the spigot.yml I believe

Ferocimo commented 4 years ago

This most certainly could fix the problem, but there is a reason we set a maximum view distance for players : performance. We can't really remove the view distance without having a significant impact on performances.

mcmonkey4eva commented 4 years ago

@HungryHobos never give an NPC the same name or UUID as a real player.


The original issue here was considered probably related to 2074, which was fixed, meaning this issue problem is too.

If this original issue isn't fixed on latest builds from https://ci.citizensnpcs.co/job/Citizens2/ , please reply below