Help requested: how to spawn a human npc via api?

A new update is now available, introducing seasons and more!
Latest hotfix: 0.8.0.2 (2024-12-30)
  • I understand that its world.spawnnpc() but what is the short ID for human? Is there a list? I would have expected it to take the NPCTypes enum, but to no avail.


    Can anyone help me on how to spawn a human npc?


    Thanks!

  • Hi samlander!
    I just ran into the same problem.
    I wrote a quick debug plugin and dumped all of the NPC definitions to a log, and I thought I'd share it with you:


    GameInfo: NPC: 1 : pig
    GameInfo: NPC: 2 : cow
    GameInfo: NPC: 3 : goat
    GameInfo: NPC: 4 : sheep
    GameInfo: NPC: 5 : moose
    GameInfo: NPC: 6 : fox
    GameInfo: NPC: 7 : bear
    GameInfo: NPC: 8 : rabbit
    GameInfo: NPC: 9 : sheepshorn
    GameInfo: NPC: 10 : chicken
    GameInfo: NPC: 11 : elephant
    GameInfo: NPC: 13 : giraffe
    GameInfo: NPC: 14 : jaguar
    GameInfo: NPC: 16 : rhinoceros
    GameInfo: NPC: 17 : tiger
    GameInfo: NPC: 18 : penguin
    GameInfo: NPC: 19 : minipig
    GameInfo: NPC: 20 : polarbear
    GameInfo: NPC: 21 : boar
    GameInfo: NPC: 22 : deer
    GameInfo: NPC: 23 : rat
    GameInfo: NPC: 24 : snake
    GameInfo: NPC: 25 : spider
    GameInfo: NPC: 26 : spiderling
    GameInfo: NPC: 27 : bearblack
    GameInfo: NPC: 28 : goatwhite
    GameInfo: NPC: 29 : cowbrown
    GameInfo: NPC: 30 : earthworm
    GameInfo: NPC: 31 : horse
    GameInfo: NPC: 33 : camel
    GameInfo: NPC: 35 : donkey
    GameInfo: NPC: 100 : dummy
    GameInfo: NPC: 50 : skeleton
    GameInfo: NPC: 60 : bandit


    Hope this helps!

  • Simply open the definitions.db database from the commons.jar archive. It has all the info you might ever need on all assets in the game.

  • Alternatively you can check out this guide on Steam, it's up-to-date and contains all item, object, clothes and npc names (as well as their corresponding id): https://steamcommunity.com/sha…iledetails/?id=1711772125


    Or you could retrieve the NpcDefinition (which contains the npc id) via API, but you have to know the internal name of the npc for that. Just call the static Definitions.getNpcDefinition() function, e.g:

    Java
    Definitions.NpcDefinition def = Definitions.getNpcDefinition("dummy");
    short id = def.getID(); //<- get the npc id

Participate now!

Don’t have an account yet? Create a new account now and be part of our community!