NPC in 1.10

Discussion in 'Spigot Plugin Development' started by PRiiSM, May 4, 2017.

  1. Hello,
    Is there a way to spawn a simple NPC without display them in tab?

    Greetings
     
  2. Sure there is a way, what have you tried so far? Because spoonfeed is rare
     
  3. citizens plugin maybe?
     
  4. You could make a NPC like this:
    • Create a private EntityPlayer npc field.
    • Create a private String name field.
    • Create a private UUID uuid field;
    • Now create a constructor with parameters String & Player where name is used to set the NPC's name and Player to get a Location to spawn your NPC.
    • As you look at the EntityPlayer-constructor, you need a WorldServer and a MinecraftServer parameters, so make sure to make them.
    • For the GameProfile parameter, you can fill in UUID.randomUUID() & name
    • For the PlayerInteractManager parameter, you can create a new instance of this class with the 'WorldServer' field as parameter.
    • Then to spawn:
    • - Send a PacketPlayOutNamedEntitySpawn packet
    • - Send a PacketPlayOutPlayerInfo packet
    • Next, make sure to set the EntityPlayer visible by npc.setInvisible(false);
    • Finally, use npc.setLocation(player.getLocation)()); where 'player' is the player from the constructor.
    Hope this helps you out :)
     
    • Informative Informative x 1
    • Useful Useful x 1
  5. Sure.
    I would even pay for a simple code where a npc spawns without tablist name
     
    • Funny Funny x 1
  6. Why not use an API such as Citizens?
     
    • As you look at the EntityPlayer-constructor, you need a WorldServer and a MinecraftServer parameters, so make sure to make them
    Can you tell me how?
     
  7. Code (Text):
    MinecraftServer server = ((CraftServer)Bukkit.getServer()).getHandle();

    WorldServer world = ((CraftWorld)Bukkit.getWorlds().get(0)).getHandle();

    // aint sure about the second one, I sent this from my phone....
    @ItsChristian
     
    #8 _xXProDudeXx_, May 4, 2017
    Last edited: May 4, 2017
  8. I will send you a working method tonight or tomorrow (depending on how late I get home from the party I currently am at.
     
  9. That would be great!
     
  10. Oh dear sorry I forgot about this, I am on holiday this weekend, after that I will