How to create custom NPC's in vanilla minecraft? (1.10.2)

Solution 1:

You need to get a Command Block

/give @p minecraft:command_block 

You've to run the following command in a Impulse Command Block (normal command block).

Change the word "NAME" to what you want the name of the NPC to be (example Jay). Then activate it.

/summon ArmorStand ~ ~1 ~ {ShowArms:1,CustomNameVisible:1,CustomName:NAME} 

You should now have an armor stand named what you changed "NAME" to. Put armor on it and a head (optional give it a block or tool).

Now place another Impulse Command Block (normal command block). Place the following command below in it. Change the word "NAME_" to what you want with _ at the end (example Jay_). Then change where it says "MOB" to the minecraft mob you want you NPC to have (example villager, zombie, creeper)

/summon MOB ~0 ~1 ~0 {CustomName:NAME_,CustomNameVisible:1,Silent:1} 

Now place a Repeater Command Block (purple command block) Set it from "Needs Redstone" to "Always Active". Then Place the following command below. Change "NAME" to what the armor stands name is (example Jay) and also change "NAME_" to what the MOB name is (example Jay_)

/tp @e[name=NAME] @e[name=NAME_] 

Place a Chain Command Block (green command block) in front of the Repeater Command Block (purple command block) having the arrow on the Repeater Command Block pointing into the Chain Command Block. Set the Chain Command Block from "Needs Redstone" to "Always Active". Finally now place the final command below in the Chain Command Block. Then change "NAME_" to what you named the minecraft mob (exmple Jay_).

/effect @e[name=NAME_] minecraft:invisibility 1 1 

Now you should have your very own NPC in your world.

Solution 2:

/execute as @e[name=<name of armor stand>] at <player name> facing entity @p[distance=2..] eyes run tp @s ^ ^ ^0.5

instead of 0.5 you can do 1 block away or 2 3 ect its how many blocks away from the player you want the armor stand to move to Example: i set it to 2 blocks the armor stand everytime i move will move with me but always 2 blocks behind you sorta like a pet (which i have done :D) to make a pet do this:

/summon ArmorStand ~ ~ ~ {Invulnerable:1b,NoGravity:1b,Invisible:1b,CustomNameVisible:1b,CustomName:<your name here>}

so the armorstand will follow the player but it wont go werever it wants