NPCLib icon indicating copy to clipboard operation
NPCLib copied to clipboard

The NPCs are invisible

Open andrei923 opened this issue 4 years ago • 38 comments

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

  • Create an NPC (The player must be offline when you create it! otherwise will work as expected.)
  • Join the server
  • Show the NPC to the player.

tested with npclib-plugin-2.10-SNAPSHOT.

andrei923 avatar Oct 06 '20 12:10 andrei923

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.

iSatnin9 avatar Oct 27 '20 00:10 iSatnin9

same here tested with 2.9 and 2.10

ogfabio avatar Oct 27 '20 21:10 ogfabio

Are you setting a skin when creating the npc? Or just a blank npc?

Mooselk avatar Nov 17 '20 19:11 Mooselk

Yes, I'm setting skin for it.

npc.setLocation(loc)
npc.setSkin(skin)				
npc.create()

andrei923 avatar Nov 18 '20 17:11 andrei923

Same for me, the name appears but the skin doesn't. It's invisible.

iNezuko avatar Nov 19 '20 21:11 iNezuko

I'll look into it when I get the chance.

Mooselk avatar Nov 19 '20 21:11 Mooselk

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?

Mooselk avatar Nov 20 '20 16:11 Mooselk

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.

andrei923 avatar Nov 20 '20 16:11 andrei923

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

https://pastebin.com/dYuXMJti

https://pastebin.com/nFSTyz70

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

iNezuko avatar Nov 20 '20 16:11 iNezuko

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

Mooselk avatar Nov 20 '20 22:11 Mooselk

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

https://pastebin.com/dYuXMJti

https://pastebin.com/nFSTyz70

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)

Mooselk avatar Nov 20 '20 22:11 Mooselk

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.

iNezuko avatar Nov 21 '20 15:11 iNezuko

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

iNezuko avatar Nov 21 '20 16:11 iNezuko

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.

https://pastebin.com/pS1s26Ks

iNezuko avatar Nov 21 '20 21:11 iNezuko

My code now I took from "examples" the author of this lib did. It works and spawned the NPC.

https://pastebin.com/pS1s26Ks

Good to here that it’s working now, still confused as to why it wasn’t before.

Mooselk avatar Nov 22 '20 16:11 Mooselk

@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.

Mooselk avatar Nov 22 '20 16:11 Mooselk

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.

iNezuko avatar Nov 22 '20 16:11 iNezuko

is not related to the skin, tried without setting the skin, the same result, the bug was added in 2.8

andrei923 avatar Nov 22 '20 16:11 andrei923

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.

andrei923 avatar Nov 22 '20 16:11 andrei923

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?

iNezuko avatar Nov 22 '20 17:11 iNezuko

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

Mooselk avatar Nov 22 '20 18:11 Mooselk

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.

Mooselk avatar Nov 22 '20 18:11 Mooselk

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.

andrei923 avatar Nov 22 '20 19:11 andrei923

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... 🤔

sam302rk avatar Dec 16 '20 11:12 sam302rk

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. 2020-12-16_14 52 47

andrei923 avatar Dec 16 '20 12:12 andrei923

Well without skins it kinda worked for me.

Am Mi., 16. Dez. 2020 um 13:53 Uhr schrieb andrei923 < [email protected]>:

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 .

sam302rk avatar Dec 16 '20 14:12 sam302rk

Creating a new NPC Object for every player and using the code from #130 worked for me.

this.

andrei923 avatar Dec 22 '20 22:12 andrei923

Creating a new NPC Object for every player and using the code from #130 worked for me.

this.

what do you mean?

sam302rk avatar Dec 22 '20 22:12 sam302rk

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!

JitseB avatar Dec 27 '20 20:12 JitseB

Version 2.7.2 works as it should, In 2.8 it doesn't.

andrei923 avatar Feb 08 '21 17:02 andrei923