Autonomous Market Shoppers

Custom villager AI brings a miniature store to life as mobs independently browse shelves, pick up items, and head to the checkout counter.

Java EditionMobs & PetsHard24 commandsTested on a real 26.2 & 26.3 server
Minecraft villagers with floating apples walk through market aisles toward a cashier counter with green particles. Download the GIF Video & GIF © www.9minecraft.net

Custom MobsMedievalCuteGreenGoldWhiteDecorationMap MakingServer LobbyParticlesItem displaysScoreboard timersExecute chainsSummoned mobsBlock building (fill/setblock/clone)Rotation math21+ commands

Watch a bustling miniature store come to life with autonomous villagers! In this command creation, shoppers walk through the market entrance, browse stocked wooden shelves, pick up floating apples, bread, and books above their heads, and queue at the checkout counter.

The cashier rings up each customer with glowing emerald particles, floating receipts, and bell chimes before they head out the exit. All of the pathfinding and shopping phases are driven purely by scoreboard state machines and display entities.

1. Setup - type these once 10 commands

  1. /scoreboard objectives add c9_tick dummy
  2. /scoreboard objectives add c9_state dummy
  3. /fill ~-7 ~-1 ~-5 ~7 ~-1 ~5 minecraft:smooth_stone
  4. /fill ~-4 ~ ~-2 ~-4 ~1 ~2 minecraft:bookshelf
  5. /fill ~ ~ ~-2 ~ ~1 ~2 minecraft:barrel[facing=up]
  6. /fill ~3 ~ ~-4 ~5 ~ ~-2 minecraft:quartz_bricks
  7. /summon minecraft:villager ~4 ~ ~-3.5 {NoAI:1b,Silent:1b,Invulnerable:1b,Rotation:[0f,0f],VillagerData:{profession:"minecraft:librarian",level:5,type:"minecraft:plains"},CustomName:{"text":"Cashier","color":"gold"},CustomNameVisible:1b,Tags:["c9_ent","c9_cashier"]}
  8. /summon minecraft:marker ~-4 ~1.2 ~ {Tags:["c9_ent","c9_shelf","c9_s1"]}
  9. /summon minecraft:marker ~ ~1.2 ~ {Tags:["c9_ent","c9_shelf","c9_s2"]}
  10. /summon minecraft:marker ~4 ~1.2 ~-3 {Tags:["c9_ent","c9_shelf","c9_reg"]}

2. Loop - one repeating command block each (Always Active) 14 commands

  1. /scoreboard players add #sys c9_tick 1
  2. /execute if score #sys c9_tick matches 55.. run scoreboard players set #sys c9_tick 0
  3. /execute if score #sys c9_tick matches 1 run summon minecraft:villager ~-6 ~ ~4 {NoAI:1b,Silent:1b,Invulnerable:1b,Tags:["c9_ent","c9_shopper","c9_new"],VillagerData:{profession:"minecraft:nitwit",level:1,type:"minecraft:plains"}}
  4. /execute as @e[tag=c9_new] at @s run summon minecraft:item_display ~ ~2.2 ~ {Tags:["c9_ent","c9_cart"],billboard:"center",item:{id:"minecraft:air",count:1},transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[0f,0f,0f],scale:[0.6f,0.6f,0.6f]}}
  5. /execute as @e[tag=c9_new] run scoreboard players set @s c9_state 1
  6. /tag @e[tag=c9_new] remove c9_new
  7. /scoreboard players add @e[tag=c9_shopper] c9_tick 1
  8. /execute as @e[tag=c9_shopper,scores={c9_state=1}] at @s facing ~-4 ~ ~ run tp @s ^ ^ ^0.12 ~ 0
  9. /execute as @e[tag=c9_shopper,scores={c9_state=1,c9_tick=45..}] at @s run data modify entity @n[tag=c9_cart] item set value {id:"minecraft:golden_apple",count:1}
  10. /execute as @e[tag=c9_shopper,scores={c9_state=1,c9_tick=45..}] at @s run particle minecraft:happy_villager ~ ~1.5 ~ 0.3 0.3 0.3 0 6
  11. /execute as @e[tag=c9_shopper,scores={c9_state=1,c9_tick=45..}] run scoreboard players set @s c9_state 2
  12. /execute as @e[tag=c9_shopper,scores={c9_state=2}] at @s facing ~4 ~ ~-2 run tp @s ^ ^ ^0.14 ~ 0
  13. /execute as @e[tag=c9_shopper,scores={c9_state=2,c9_tick=110..}] at @s run particle minecraft:totem_of_undying ~ ~1.5 ~ 0.3 0.4 0.3 0.1 12
  14. /execute as @e[tag=c9_shopper] at @s run tp @n[tag=c9_cart] ~ ~2.2 ~

How it works

Frames from the test run

Autonomous Market Shoppers - frame 1Autonomous Market Shoppers - frame 2Autonomous Market Shoppers - frame 3

Recorded on our own test server: 59 frames at about 9.7 fps. Our image check saw: Villagers with floating golden apples above their heads walk along a path between bookshelves and barrels, leaving green particles as they pass a cashier villager at a white counter.

Commands, video and screenshots: tested and recorded by www.9minecraft.net © 9Minecraft. Sharing a video or screenshot? Please credit www.9minecraft.net.

Build it in your world

  1. Stand in the center of a flat open area where you want your miniature store to appear.
  2. Run each command from the Setup list one by one in chat to build the floor, shelves, counter, and cashier.
  3. Place 14 Repeating Command Blocks in a line or column nearby, set them all to Always Active.
  4. Paste one command from the Loop list into each repeating command block in order.
  5. Watch as villagers automatically spawn, walk to the shelves, grab items, and check out at the register.

Use it with real players

To let real players browse the shelves too, run /execute as @a at @s if entity @e[tag=c9_shelf,distance=..2] run give @s minecraft:golden_apple 1 in a repeating command block on a cooldown so walking near a shelf stocks your inventory.

Remove it again 5 commands

  1. /kill @e[tag=c9_ent]
  2. /scoreboard objectives remove c9_tick
  3. /scoreboard objectives remove c9_state
  4. /fill ~-7 ~ ~-5 ~7 ~2 ~5 minecraft:air
  5. /fill ~-7 ~-1 ~-5 ~7 ~-1 ~5 minecraft:grass_block

FAQ

Why do the villagers walk in straight lines instead of wandering randomly?

They are summoned with the NoAI:1b tag and moved using facing and local caret coordinates (^ ^ ^0.12), which lets commands guide them smoothly from shelf to counter.

Can I change what items the villagers buy?

Yes! Edit loop command 9 and replace minecraft:golden_apple with any item ID like minecraft:bread, minecraft:book, or minecraft:diamond.

Commands used

/data/execute/fill/particle/scoreboard/summon/tag/tp

Similar creations

Join 9Minecraft News & Guides