Minecraft Blogs

[Tutorial] Spawning a Custom Shopkeeper in Vanilla Minecraft

  • 7
  • 4
  • 4
avatar flashteens
Level 58 : Grandmaster Technomancer

Introduction: about this tutorial

If you are either Survival/Adventure map makers or an operator in a multiplayer server, this tutorial totally fit you, since you may want to add different shops in your map!

This tutorial provides you a complete explanation for how to spawn a custom villager as a working shopkeeper, which is one-command and playable in Adventure Mode of Vanilla Minecraft (better 1.9.x, 1.10.x or 1.11 snapshots). Also, this tutorial explains some additional features so as to make the villager even more powerful!

Different from many other one-command tutorials, which only give out a long command for copy-paste without any further explanations, this tutorial explain everything in an easy-to-understand way about the command, making the villager as "customized" as possible!

Why do you need a command to spawn a shopkeeper guy?

A shopkeeper is the person that you may ask to buy the products. In Minecraft, villagers sell items, too, however, which are usually NOT what we may desire. (or more precisely, see on this Minecraft Wiki page for the details) To have a custom shopkeeper in your world, you need a command to spawn the villager with a special NBT tag.

Before typing a command...

It's strongly recommended for you to type the villager command in a command block instead of directly writing them in the chat console. The maximum character limit in a command block is 32,767, while it is only allowed to type at most 100 characters in the chat console.

To get a command block, please type the following command first in your chat console:

/give @p minecraft:command_block
Then, for the rest of this blog post, you are going to do everything in this command block instead of the chat console!

Starting from an example...

To start the tutorial, an example is given here, which spawns a villager that has a SkyDoesMinecraft's face and sells gold ingots and Notch apples.

REALLY REALLY LONG STUFF... - You don't have to click here unless you understand all of this... lol
By pasting this command into a command block, then activate it, and the villager guy may come out onto the command block! How magic it is!!! (So what?)

Many other one-command tutorials end here without explaining anything else, and most players may thus either get confused or just do a copy-paste without any new ideas or modifications. To make this tutorial general, everything in this long command should be explained in the following context.

A step-by-step tutorial for this command

To make such a long command easy to understand, let's get started with a much shorter one.

First, summon an ordinary villager like this:

/summon Villager ~ ~1 ~where the parameters ~ ~1 ~ stand for the location that is one block unit above your command block. For more details about the tilde notation, you are referred to this Minecraft Wiki page.

Giving this guy a new name...

The first step to customize this guy is to give him a new name by add a data tag into the command:

/summon Villager ~ ~1 ~ {CustomName:"BUDDER SHOP"}
(The text "BUDDER SHOP" can be changed to anything you want!)

After giving the custom name tag, you should see the name when you are looking at this guy:
Image: The villager with a custom name

By right-clicking on this guy, the custom name replaces the default profession name, too!
Image: After clicking on the villager

But, as you can see, this guy actually doesn't sell what we desire. We wish him to sell gold ingots and Notch apples instead.

Let him sell the gold ingots!

To determine what to sell, the command is again extended like this, where the red text is newly added here:

/summon Villager ~ ~1 ~ {CustomName:"BUDDER SHOP",Offers:{Recipes:[{buy:{id:emerald,Count:5},sell:{id:gold_ingot,Count:1}]}}

To make this command easier to read, I would have to indent the red text and rewrite as follows:
A slightly LONG stuff... - click to reveal
(All spaces here is just for the readability of this tutorial and should not appear when you type this code into the command block!)

In the code above, the Recipes attribute in the Offers tag has to be rewritten so as to replace this guy's default items with your setting's ones. The Recipes tag is a list representing what to sell, where it currently contains only one item: gold ingot. By this setting, we should be able to buy 1 gold ingot with 5 emeralds!

Add some styles in your budder ingots!

If you know the YouTube star SkyDoesMinecraft, you may know that he always calls gold "butter", which is sometimes intentionally written as "budder". Thus, in this example, we would rename the gold ingot into "Budder", where the Offers tag can be extended in the following way:
It gets longer... - click to reveal
(The red marks indicates the modified content.)

So, now your villager does sell Budder ingots!
Image: The guy now sells budder ingots!

"I can no longer buy the budder ingots! Help me!!!"

What if you buy too much budder ingots from the guy? You may see this scenario...
Image: This guy "got tired"!!!
Then, after he rested for a while, and something happened...

Well... to overcome this problem, the command is to be modified as follows:
The command keeps extending... - click to reveal
(The red marks indicates the modified content.)

There are two modifications (red marks) in the code above, where:
  1. Career is set to an integer equal to or above 1 as CareerLevel is set to a very large number like 1000000. This way prevents the villager from selling unexpected items after some moments.
  2. maxUses is also set to a large number so as not to let the guy "get tired" anymore.

Another issue. In some cases, we don't wish this guy to give out any XP orbs...

By default, whenever we successfully trade anything with a villager, we get some XP orbs. If you don't wish the villager to give out any XP orbs, just do one modification as follows:
Just one modification, though... - click to reveal
(The red marks indicates the modified content.)

The only modification above is "rewardExp:0b", which can also be written as "rewardExp:false", but INSTEAD OF "rewardExp:0", which is a wrong representation since the data type is incorrect!
(See also: Command Data Tag Section in Minecraft Wiki)

Let him sell the second stuff!

How to make this guy sell not only one item? You may just modify the list Offers in the command:
Don't worry, it should still be easy for you... - click to reveal

The blue and red text above is the modified context, where the red marks indicates some crucial differences that you should be noticed.

These red marks include the following key points:

(1) Not only emeralds can be the currency in your Minecraft world!
It's also possible for you to buy something with other currencies instead of emeralds. For the example above, gold ingots are also regarded as another currency for this guy!

(2) It's possible for you to buy an item with two different currencies!
To determine what the second currency you wish to be, the buyB attribute is available in the same syntax as the buy attribute is. The results of these two attributes are illustrated as the following edited screenshot:
Image: What do the tags "buy" and "buyB" do?

(3) The "Damage" tag does not always mean "damage"!
Actually, this is generalized as the data value of any item in the recent versions of Minecraft. Data values may determine some minor differences that have the same ID. For example, both white wool and pink wool have the same ID: minecraft:wool, whereas the data values of each is 0 and 6, respectively. If the argument is omitted, it is set to 0 by default. Likewise, to let the villager sell a Notch apple (data value: 1) instead of an ordinary golden apple (data value: 0), you have to specify the Damage tag value to 1.

(4) The maxUses and rewardExp settings can be different among different items!
In other words, taking the same example as above, it is possible to specify different values of maxUses and rewardExp tags for "gold ingots" and "Notch apples", respectively. Therefore, to make these two settings work in all cases, you may have to repeat these two tags for each item!

Is it possible to change the guy's appearance?

Sure. You may change the face appearance and the color of his clothes. For changing the face, it is required to have a tag called ArmorItems (available since 1.9), of which the syntax is somewhat complicated. Nevertheless, to change his clothes color, what you need is just an integer value of the Profession attribute.

Again, here is the modification for the command:
This time, here are two modifications... - click to reveal
(The blue and red marks indicates the modified content.)

For the detailed syntax of the modified parts, please see on this Minecraft Wiki page. Nevertheless, here we only focus on the red parts of the modifications.

The Profession attribute determines the color of the clothes:
  • 0 - brown
  • 1 - white
  • 2 - purple
  • 3 - brown (w/ black apron)
  • 4 - brown (w/ white apron)
  • 5 - green (for 1.11 only, since snapshot 16w32b)

For the way to change the head, as the same way you specify what the guy sell, now let's specify the SkyDoesMinecraft's head as a "mask" wearing onto the guy's head as if his head become totally the same as SkyDoesMinecraft! In this part, id:skull and Damage:3 refers to a player's head, Count:1 indicates that the number of masks the guy wears is only one (Count:1 here is optional in 1.10.2 or below, but required in 1.11 snapshots), and SkullOwner:SkythekidRS sets the player head to be SkyDoesMinecraft, whose Mojang account is actually SkythekidRS.

"This guy is too noisy!"

It's possible to make him silent! Simply add the attribute Silent:1 to solve it.

"I'm afraid that this guy might be accidentally killed by somebody!"

The solution is to make him invulnerable! Simply add the attribute Invulnerable:1 to solve it.

Note that the invulnerability takes place only if you are in Survival or Adventure modes. You may still kill this villager in Creative mode.

The final command

The FINAL command!!! - click to reveal
(The blue marks indicates the final modification.)

Remove all the leading spaces and new line characters, and check if this command is the same as the beginning!!! :D

Thank you for reading! Welcome to reply here for any of your suggestions or comments!! Also, don't forget to give your DIAMOND and FAVORITE here, and SUBSCRIBE me!! ^_^

See Also

Here are some of my projects so far that contain the custom shopkeepers for different uses! Also check them out!
  • Craftland, my work for the PMC Sustainable City Contest, where there are 19 shops on the ground level of the main building!
  • Republic of FlashTeens, a large map with my original subway and banking systems, as well as many other shops and redstone works inside.
  • Banking system, where the Banker guy is created in this way.
CreditMinecraft Wiki (for the reference only)

3 Update Logs

Update #3: Updates for 1.11 snapshots : 10/07/2016 1:33:42 amOct 7th, 2016

Small modifications for the upcoming version 1.11 and its snapshots:
  • The attribute Count:1 MUST be added in the tag ArmorItems, while it is optional in version 1.10.2 or below.
  • The green-robed villager (Profession:5) is added in the blog description.
  • The mechanism to prevent the villager from being renamed by griefers with a name tag is still UNKNOWN. I will post this issue on PMC forum soon.

05/24/2019 3:54 pm
Level 18 : Journeyman Lemon
Can you update for 1.14?
04/07/2018 2:25 pm
Level 24 : Expert Nerd
Enchanted items???
10/02/2016 11:14 pm
Level 12 : Journeyman Engineer
WOW that is a lot more than what I had xD
10/02/2016 11:31 pm
Level 58 : Grandmaster Technomancer
Thanks so much ^_^
Planet Minecraft Logo


© 2010 - 2020