Open andrei923 opened 4 years ago
The exact same thing happens to me in version 1.16 I hope they fix it soon, it becomes impossible to use having this problem.
same here tested with 2.9 and 2.10
Are you setting a skin when creating the npc? Or just a blank npc?
Yes, I'm setting skin for it.
npc.setLocation(loc)
npc.setSkin(skin)
npc.create()
Same for me, the name appears but the skin doesn't. It's invisible.
I'll look into it when I get the chance.
I can’t seem to replicate it, are you spawning in a bunch of npcs at a time? I.e. looping through a set of locations and creating an npc for each?
@andrei923 @iNezuko would you mind sharing your code?
looping through a set of locations and creating an NPC for each?
yes, also make sure you(the player) are not online when creating them.
I can’t seem to replicate it, are you spawning in a bunch of npcs at a time? I.e. looping through a set of locations and creating an npc for each?
@andrei923 @iNezuko would you mind sharing your code?
I'm using 1.16.4 (from the updated version someone shared on the issues). I'm using single NPC. Edit: oh it was you
My gamemode relies on NPCs made from packets. This lib seems to have saved my time, but yeah. If it's an issue of the version then I can downgrade to 1.16.2
I also tried changing the skin int and replacing it with Skin skin
looping through a set of locations and creating an NPC for each?
yes, also make sure you(the player) are not online when creating them.
I had this issue in the past, I believe it was a limitation of the mineskin api. I fixed the issue by serializing and saving the skin object in a config and retrieving it later so I only have to make the api call once.
Here’s my serializable skin class https://github.com/Mooselk/All-In-One-Lobby/blob/master/src/main/java/me/kate/lobby/npcs/api/skin/Skin.java
I can’t seem to replicate it, are you spawning in a bunch of npcs at a time? I.e. looping through a set of locations and creating an npc for each? @andrei923 @iNezuko would you mind sharing your code?
I'm using 1.16.4 (from the updated version someone shared on the issues). I'm using single NPC. Edit: oh it was you
My gamemode relies on NPCs made from packets. This lib seems to have saved my time, but yeah. If it's an issue of the version then I can downgrade to 1.16.2
I also tried changing the skin int and replacing it with Skin skin
That’s very strange, do you have the same issue if you create the skin object manually? You can do this by copy pasting the signature and value from mineskin and creating the skin object Skin(value, signature)
That’s very strange, do you have the same issue if you create the skin object manually? You can do this by copy pasting the signature and value from mineskin and creating the skin object Skin(value, signature)
Yes I did it with Skin skin = I'll try the one from your code in a second.
That’s very strange, do you have the same issue if you create the skin object manually? You can do this by copy pasting the signature and value from mineskin and creating the skin object Skin(value, signature)
Loaded class net.jitse.npclib.api.skin.Skin from NPCLibPlugin v2.9.1-SNAPSHOT which is not a depend, softdepend or loadbefore of this plugin.
I have added Depend on npclib and put it inside plugins folder (also before shaded it in maven but I undid it)
My code looks like this: https://pastebin.com/mtvZes5q
Still invisible.
Edit: I have changed from Depend to depend. The error vanished, but the skin still doesnt show up
Edit: It seems to not even create the NPC as it's not showing a Hitbox, or maybe because it's packets. I don't know how it works yet. https://gyazo.com/3a1a37619fcd8fa3a3963ec1cdfad0cc
Edit: I removed the setskin code and the NPC still wont show.
Edit: I downgraded the versions to 1.16.2 and used supporting version. Still throws error. Has to be something wtih code.
Edit!: I tried checking if npc is created and shown. It returns true for "created" and false for shown. Then I tried showing it against and got Task #2571 for SWSettlements v1.0-SNAPSHOT generated an exception java.lang.IllegalArgumentException: NPC is already shown to player
That’s very strange, do you have the same issue if you create the skin object manually? You can do this by copy pasting the signature and value from mineskin and creating the skin object Skin(value, signature)
My code now I took from "examples" the author of this lib did. It works and spawned the NPC.
My code now I took from "examples" the author of this lib did. It works and spawned the NPC.
Good to here that it’s working now, still confused as to why it wasn’t before.
@andrei923 looks like it was an issue with rate limiting, especially if your loading the npcs again and again. Each request for a given skin has a 60 second cool down.
I’d recommend serializing and saving your skins so you only need to make the api call once.
Good to here that it’s working now, still confused as to why it wasn’t before.
I'm p sure the NPC has to be created when the player is on the server. Or like couple minutes after start.
is not related to the skin, tried without setting the skin, the same result, the bug was added in 2.8
Good to here that it’s working now, still confused as to why it wasn’t before.
I'm p sure the NPC has to be created when the player is on the server.
that's the bug, meaning that you have to create an NPC every time a player joins.
that's the bug, meaning that you have to create an NPC every time a player joins.
Works for me as I'd make them spawn like this anyways. Hope you can figure it out soon
I’d recommend serializing and saving your skins so you only need to make the api call once.
Would it work with saving the data of the skin. Value and signature? How it would look like in the code?
Would it work with saving the data of the skin. Value and signature? How it would look like in the code?
You’d just need to save the value and signature under the id so you can grab it later.
Here’s my skin class https://github.com/Mooselk/All-In-One-Lobby/blob/master/src/main/java/me/kate/lobby/npcs/api/skin/Skin.java
And fetching methods https://github.com/Mooselk/All-In-One-Lobby/blob/master/src/main/java/me/kate/lobby/cache/SkinCache.java
is not related to the skin, tried without setting the skin, the same result, the bug was added in 2.8
I need to see how you’re showing the npc, I’m still unable to replicate your issue.
Have you tried hiding and unhiding the npc? I’m trying to narrow this down as much as possible before I go digging.
is not related to the skin, tried without setting the skin, the same result, the bug was added in 2.8
I need to see how you’re showing the npc, I’m still unable to replicate your issue.
Have you tried hiding and unhiding the npc? I’m trying to narrow this down as much as possible before I go digging.
yes, the NPC is still hidden, it throws the "NPC is already shown to player" error, the hologram works.
Creating a new NPC Object for every player and using the code from #130 worked for me. It seems, like it's a issue with the NPCs getting created before the skin finished downloading... 🤔
Creating a new NPC Object for every player and using the code from #130 worked for me. It seems like it's an issue with the NPCs getting created before the skin finished downloading... 🤔
it's not related to the skin, you don't need to set the skin to reproduce it.
Well without skins it kinda worked for me.
Am Mi., 16. Dez. 2020 um 13:53 Uhr schrieb andrei923 < notifications@github.com>:
Creating a new NPC Object for every player and using the code from #130 https://github.com/MinecraftLibraries/NPCLib/pull/130 worked for me. It seems like it's an issue with the NPCs getting created before the skin finished downloading... 🤔
it's not related to the skin, you don't need to set the skin to reproduce it. [image: 2020-12-16_14 52 47] https://user-images.githubusercontent.com/29291628/102350990-679af500-3fae-11eb-90c9-a0ab84274a35.png
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/MinecraftLibraries/NPCLib/issues/124#issuecomment-746244716, or unsubscribe https://github.com/notifications/unsubscribe-auth/AL3U2R5HPKGGR5CJN5NS7MDSVCUURANCNFSM4SF7AG5A .
Creating a new NPC Object for every player and using the code from #130 worked for me.
this.
Creating a new NPC Object for every player and using the code from #130 worked for me.
this.
what do you mean?
Please note that showing the NPCs to the players async results in strange behavior like this. Always make sure that player related mechanics act on the main server thread!
Version 2.7.2 works as it should, In 2.8 it doesn't.
Still an issue in the latest version.
Can confirm, brand new user here running Paper Version 495 1.16.5-R0.1-Snapshot and NPCLibPlugin 2.11.1-Snapshot when I spawn a npc on server start it will appear invisible even if spawned with no skin. Weird thing is if I reload the plugin (Using PlugMan) the npc will become visible so I thought maybe spawning the npc right as the server started was causing this somehow and tried using a delayed task but no luck there, I ended up trying what someone recommended here which is to spawn an npc for each individual player when they join and that works fine, its messy and I assume not very efficient but for now it is a temporary fix I hope.
for (NPC npc : NPCManager.getAllNPCs())
{
if (!npc.isCreated())
npc.create();
npc.show(event.getPlayer());
}
I solved this issue in 1.16.5 by running the following code on player join.
for (NPC npc : NPCManager.getAllNPCs()) { if (!npc.isCreated()) npc.create(); npc.show(event.getPlayer()); }
I solved this issue in 1.16.5 by running the following code on player join.
the player must be offline to reproduce it.
I'm giving people a solution. I created the NPC object while the server is starting, and ran npc#create and npc#show on join. I can't find a way to fix it properly, I don't know if there is.
I think the issue lies somewhere between sending the packets and there being no players to receive them.
I'm giving people a solution. I created the NPC object while the server is starting, and ran npc#create and npc#show on join. I can't find a way to fix it properly, I don't know if there is.
Yeah your fix is much better than creating individual npcs for every player which was the solution I went with before, I will note that I ran into an null error with isCreated()
but it has to do with how I define the npc variable, I define the npc in the class with like:
public NPC examplenpc;
so instead of doing
if(!examplenpc.isCreated())
I switched it to
if(examplenpc != null)
I'm assuming the difference is how we are initially defining our npc variable, here is my final improvised example from your solution which works great in case anyone finds it useful:
public NPC woodcuttingnpc;
@EventHandler public void OnJoin(PlayerJoinEvent event){ if(woodcuttingnpc != null){ woodcuttingnpc.show(event.getPlayer()); }else{ Skin skin = new Skin("ewogICJ0aW1lc3RhbXAiIDogMTYxNjExNTcwNjE5OSwKICAicHJvZmlsZUlkIiA6ICJjNjc3MGJjZWMzZjE0ODA3ODc4MTU0NWRhMGFmMDI1NCIsCiAgInByb2ZpbGVOYW1lIiA6ICJDVUNGTDE2IiwKICAic2lnbmF0dXJlUmVxdWlyZWQiIDogdHJ1ZSwKICAidGV4dHVyZXMiIDogewogICAgIlNLSU4iIDogewogICAgICAidXJsIiA6ICJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2Q1ZWQ4MDk3ZTM0YThmMGJkNDZlNzY2MTkwYzNhOWY2ODNiYThkODBjM2FiM2RiZTYwMWI1ZDU4ZWQ3MjEwMGUiLAogICAgICAibWV0YWRhdGEiIDogewogICAgICAgICJtb2RlbCIgOiAic2xpbSIKICAgICAgfQogICAgfQogIH0KfQ==", "HCPbYqjTkLRgm2VpvkCj9OMIibZCZIpJ7qd/yb5TtZdriX4T5YFYB1pUwnP/wSPHXU9eDwqYHP32G5kiXLV7W4GrTqRT55t1dtDE0l4nHzLNMFVZZDuZ9/DGCTPGdWZ2ACfijiQ+KRE3n5mrWNIG88m0GAQuwIp5WmoIPRcdEyBZieruU8Mqb6Rnk/xusJwHdj4YLZFT0HMpm2dJGnUhVNA5ZD59MMFb4bByMeQX7NHChqYxGkPyg5WIrTRDE4lfRleOOm7ZYKDsDiNGof9xytmQhGVk+BeOTqnSq2Yo2NDc/2Ag6QVYrdpFmSnSjvb2hpxAF2H0SMb0rGZDNqD8ASY0MI2LgZo95acTO9yWV5ep32ykbmUCEDuJmPbbbKiJqifiZzkPbZOihifwoVhEvFrFLBYcWdJmsCmaBeNQHbnGR5flbhR+8mY7+L7EHQndUEAc7juAGVFjWSc8DG4Wsy16eozuDSrc3YcY7ymszN2ol/VqdAt1hdhwOzcaGFBkrXJQ/t+1Dlpb4+n6Wk3Fezi+Hq7Ln74x/PahyV2SoQriEERYlikV6xj1V+4W4wTwFihqs+uH8UxAkJYq6W5wjBlF6zDwK3+bip52a+RuCYTENdrfOPIZC9lyFivoMZ+SFxpD9xD3+gVRnzjjxQm0VLnDm2GEt6fj7MOLCmY6dvY="); int skinID = 962200259; Location loc = new Location(Bukkit.getWorld("world"), -500.443, 65, -149.591, -179, 4); //NPC dmv = null; woodcuttingnpc = plugin.getNPCLib().createNPC(Arrays.asList("§e§lRobin", "§7Right Click to Interact")); woodcuttingnpc.setSkin(skin); woodcuttingnpc.setLocation(loc); woodcuttingnpc.create(); woodcuttingnpc.show(event.getPlayer()); } }
I'm giving people a solution. I created the NPC object while the server is starting, and ran npc#create and npc#show on join. I can't find a way to fix it properly, I don't know if there is.
Yeah your fix is much better than creating individual npcs for every player which was the solution I went with before, I will note that I ran into an null error with
isCreated()
but it has to do with how I define the npc variable, I define the npc in the class with like:public NPC examplenpc;
so instead of doingif(!examplenpc.isCreated())
I switched it to
if(examplenpc != null)
I'm assuming the difference is how we are initially defining our npc variable, here is my final improvised example from your solution which works great in case anyone finds it useful:
public NPC woodcuttingnpc;
@EventHandler public void OnJoin(PlayerJoinEvent event){ if(woodcuttingnpc != null){ woodcuttingnpc.show(event.getPlayer()); }else{ Skin skin = new Skin("ewogICJ0aW1lc3RhbXAiIDogMTYxNjExNTcwNjE5OSwKICAicHJvZmlsZUlkIiA6ICJjNjc3MGJjZWMzZjE0ODA3ODc4MTU0NWRhMGFmMDI1NCIsCiAgInByb2ZpbGVOYW1lIiA6ICJDVUNGTDE2IiwKICAic2lnbmF0dXJlUmVxdWlyZWQiIDogdHJ1ZSwKICAidGV4dHVyZXMiIDogewogICAgIlNLSU4iIDogewogICAgICAidXJsIiA6ICJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2Q1ZWQ4MDk3ZTM0YThmMGJkNDZlNzY2MTkwYzNhOWY2ODNiYThkODBjM2FiM2RiZTYwMWI1ZDU4ZWQ3MjEwMGUiLAogICAgICAibWV0YWRhdGEiIDogewogICAgICAgICJtb2RlbCIgOiAic2xpbSIKICAgICAgfQogICAgfQogIH0KfQ==", "HCPbYqjTkLRgm2VpvkCj9OMIibZCZIpJ7qd/yb5TtZdriX4T5YFYB1pUwnP/wSPHXU9eDwqYHP32G5kiXLV7W4GrTqRT55t1dtDE0l4nHzLNMFVZZDuZ9/DGCTPGdWZ2ACfijiQ+KRE3n5mrWNIG88m0GAQuwIp5WmoIPRcdEyBZieruU8Mqb6Rnk/xusJwHdj4YLZFT0HMpm2dJGnUhVNA5ZD59MMFb4bByMeQX7NHChqYxGkPyg5WIrTRDE4lfRleOOm7ZYKDsDiNGof9xytmQhGVk+BeOTqnSq2Yo2NDc/2Ag6QVYrdpFmSnSjvb2hpxAF2H0SMb0rGZDNqD8ASY0MI2LgZo95acTO9yWV5ep32ykbmUCEDuJmPbbbKiJqifiZzkPbZOihifwoVhEvFrFLBYcWdJmsCmaBeNQHbnGR5flbhR+8mY7+L7EHQndUEAc7juAGVFjWSc8DG4Wsy16eozuDSrc3YcY7ymszN2ol/VqdAt1hdhwOzcaGFBkrXJQ/t+1Dlpb4+n6Wk3Fezi+Hq7Ln74x/PahyV2SoQriEERYlikV6xj1V+4W4wTwFihqs+uH8UxAkJYq6W5wjBlF6zDwK3+bip52a+RuCYTENdrfOPIZC9lyFivoMZ+SFxpD9xD3+gVRnzjjxQm0VLnDm2GEt6fj7MOLCmY6dvY="); int skinID = 962200259; Location loc = new Location(Bukkit.getWorld("world"), -500.443, 65, -149.591, -179, 4); //NPC dmv = null; woodcuttingnpc = plugin.getNPCLib().createNPC(Arrays.asList("§e§lRobin", "§7Right Click to Interact")); woodcuttingnpc.setSkin(skin); woodcuttingnpc.setLocation(loc); woodcuttingnpc.create(); woodcuttingnpc.show(event.getPlayer()); } }
I'm not creating an npc per person, just running the method npc#create on join. npc#create is the method that sends the packets to spawn the npc, but I guess your solution works too.
I'm giving people a solution. I created the NPC object while the server is starting, and ran npc#create and npc#show on join. I can't find a way to fix it properly, I don't know if there is.
Yeah your fix is much better than creating individual npcs for every player which was the solution I went with before, I will note that I ran into an null error with
isCreated()
but it has to do with how I define the npc variable, I define the npc in the class with like:public NPC examplenpc;
so instead of doingif(!examplenpc.isCreated())
I switched it to
if(examplenpc != null)
I'm assuming the difference is how we are initially defining our npc variable, here is my final improvised example from your solution which works great in case anyone finds it useful:
public NPC woodcuttingnpc;
@EventHandler public void OnJoin(PlayerJoinEvent event){ if(woodcuttingnpc != null){ woodcuttingnpc.show(event.getPlayer()); }else{ Skin skin = new Skin("ewogICJ0aW1lc3RhbXAiIDogMTYxNjExNTcwNjE5OSwKICAicHJvZmlsZUlkIiA6ICJjNjc3MGJjZWMzZjE0ODA3ODc4MTU0NWRhMGFmMDI1NCIsCiAgInByb2ZpbGVOYW1lIiA6ICJDVUNGTDE2IiwKICAic2lnbmF0dXJlUmVxdWlyZWQiIDogdHJ1ZSwKICAidGV4dHVyZXMiIDogewogICAgIlNLSU4iIDogewogICAgICAidXJsIiA6ICJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2Q1ZWQ4MDk3ZTM0YThmMGJkNDZlNzY2MTkwYzNhOWY2ODNiYThkODBjM2FiM2RiZTYwMWI1ZDU4ZWQ3MjEwMGUiLAogICAgICAibWV0YWRhdGEiIDogewogICAgICAgICJtb2RlbCIgOiAic2xpbSIKICAgICAgfQogICAgfQogIH0KfQ==", "HCPbYqjTkLRgm2VpvkCj9OMIibZCZIpJ7qd/yb5TtZdriX4T5YFYB1pUwnP/wSPHXU9eDwqYHP32G5kiXLV7W4GrTqRT55t1dtDE0l4nHzLNMFVZZDuZ9/DGCTPGdWZ2ACfijiQ+KRE3n5mrWNIG88m0GAQuwIp5WmoIPRcdEyBZieruU8Mqb6Rnk/xusJwHdj4YLZFT0HMpm2dJGnUhVNA5ZD59MMFb4bByMeQX7NHChqYxGkPyg5WIrTRDE4lfRleOOm7ZYKDsDiNGof9xytmQhGVk+BeOTqnSq2Yo2NDc/2Ag6QVYrdpFmSnSjvb2hpxAF2H0SMb0rGZDNqD8ASY0MI2LgZo95acTO9yWV5ep32ykbmUCEDuJmPbbbKiJqifiZzkPbZOihifwoVhEvFrFLBYcWdJmsCmaBeNQHbnGR5flbhR+8mY7+L7EHQndUEAc7juAGVFjWSc8DG4Wsy16eozuDSrc3YcY7ymszN2ol/VqdAt1hdhwOzcaGFBkrXJQ/t+1Dlpb4+n6Wk3Fezi+Hq7Ln74x/PahyV2SoQriEERYlikV6xj1V+4W4wTwFihqs+uH8UxAkJYq6W5wjBlF6zDwK3+bip52a+RuCYTENdrfOPIZC9lyFivoMZ+SFxpD9xD3+gVRnzjjxQm0VLnDm2GEt6fj7MOLCmY6dvY="); int skinID = 962200259; Location loc = new Location(Bukkit.getWorld("world"), -500.443, 65, -149.591, -179, 4); //NPC dmv = null; woodcuttingnpc = plugin.getNPCLib().createNPC(Arrays.asList("§e§lRobin", "§7Right Click to Interact")); woodcuttingnpc.setSkin(skin); woodcuttingnpc.setLocation(loc); woodcuttingnpc.create(); woodcuttingnpc.show(event.getPlayer()); } }
Your solution works, yes. But it might be better to let @JitseB fix this issue, one attempt to fix this could also be to delay the show method on the player by 1 tick on joining. That's to make sure the player has joined and loaded the world since that might be the root cause. Because, yes.. the server can throw packets at the client whenever it wants to. But the client also has to accept the packets and actually do something with them! So if the client receives an entity packet while it hasn't even loaded the world yet, it might just drop that packet and thus the NPC won't exist for the client because this library is packet-based, and thus the NPC only exists on the client; NOT the server!
Describe the bug The NPCs are invisible, only the hologram is shown.
Server version Spigot-21fe707-e1ebe52 (MC: 1.8.8) (Implementing API version 1.8.8-R0.1-SNAPSHOT) & spigot 1.16.3
To Reproduce
tested with npclib-plugin-2.10-SNAPSHOT.