Want a better Minecraft server? Read about SpigotMC here!
Separate names with a comma.
Discussion in 'Spigot Plugin Development' started by PRiiSM, May 4, 2017.
Is there a way to spawn a simple NPC without display them in tab?
Sure there is a way, what have you tried so far? Because spoonfeed is rare
citizens plugin maybe?
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
I would even pay for a simple code where a npc spawns without tablist name
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?
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....
I will send you a working method tonight or tomorrow (depending on how late I get home from the party I currently am at.
That would be great!
Oh dear sorry I forgot about this, I am on holiday this weekend, after that I will
This is the way I did it in 1.11.
You can use the code, however you need to import the 1.10 NMS classes correctly!
Now how much did you want to pay again?