juliarn / npc-lib

Asynchronous, high-performance Minecraft NPC library for 1.8-1.21 servers.
MIT License
296 stars 50 forks source link

NPC won't look at player until player moves #109

Closed DasBabyPixel closed 1 year ago

DasBabyPixel commented 1 year ago

When you join any NPC next to you won't look at you until you move, which looks jerky if you stand still for a few seconds waiting for the world to load. I'd offer to make a PR but the easiest fix would involve listening to the ShowNpcEvent.Post, and that's bad practice(, right?). Another easy way to fix I didn't find

Anyways, looking at the CommonNpc file.

image image

derklaro commented 1 year ago

Yea that's quite unfortunate - I noticed that a few times before. I would not listen to the event in the lib directly, maybe we can offer a method in CommonNpc to simply a position sync for the user?

DasBabyPixel commented 1 year ago

Already thought of that but it's not that easy because there is no way to get the distance to the player for the imitateDistance check (in CommonNpc). There is simply no (abstract) method to get the position of the player from the npc-lib-common module

derklaro commented 1 year ago

I just took a closer look into the code: there is already an event listener that observes the exact event you wanted to intercept on 1.19.2 and lower to remove the npc from the tablist. So adding an option to make the behaviour opt-out (I guess that a better default than opt-in) to add a listener that rotates the npc into the player direction seems good to me.

Let me know if you want to make a PR for that, otherwise I will take a look to implement that later 😄

DasBabyPixel commented 1 year ago

110