Custom villager AI brings a miniature store to life as mobs independently browse shelves, pick up items, and head to the checkout counter.
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.
/scoreboard objectives add c9_tick dummy/scoreboard objectives add c9_state dummy/fill ~-7 ~-1 ~-5 ~7 ~-1 ~5 minecraft:smooth_stone/fill ~-4 ~ ~-2 ~-4 ~1 ~2 minecraft:bookshelf/fill ~ ~ ~-2 ~ ~1 ~2 minecraft:barrel[facing=up]/fill ~3 ~ ~-4 ~5 ~ ~-2 minecraft:quartz_bricks/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"]}/summon minecraft:marker ~-4 ~1.2 ~ {Tags:["c9_ent","c9_shelf","c9_s1"]}/summon minecraft:marker ~ ~1.2 ~ {Tags:["c9_ent","c9_shelf","c9_s2"]}/summon minecraft:marker ~4 ~1.2 ~-3 {Tags:["c9_ent","c9_shelf","c9_reg"]}/scoreboard players add #sys c9_tick 1/execute if score #sys c9_tick matches 55.. run scoreboard players set #sys c9_tick 0/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"}}/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]}}/execute as @e[tag=c9_new] run scoreboard players set @s c9_state 1/tag @e[tag=c9_new] remove c9_new/scoreboard players add @e[tag=c9_shopper] c9_tick 1/execute as @e[tag=c9_shopper,scores={c9_state=1}] at @s facing ~-4 ~ ~ run tp @s ^ ^ ^0.12 ~ 0/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}/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/execute as @e[tag=c9_shopper,scores={c9_state=1,c9_tick=45..}] run scoreboard players set @s c9_state 2/execute as @e[tag=c9_shopper,scores={c9_state=2}] at @s facing ~4 ~ ~-2 run tp @s ^ ^ ^0.14 ~ 0/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/execute as @e[tag=c9_shopper] at @s run tp @n[tag=c9_cart] ~ ~2.2 ~loop #3 Every 55 ticks, a new villager shopper is summoned at the store entrance with NoAI enabled so our custom pathfinding can control their movement.loop #4 Each new shopper gets a personal item_display entity floating above their head to show what item they have picked up from the shelves.loop #8 Shoppers in state 1 turn toward the bookshelf aisle and walk forward smoothly using local coordinates (^ ^ ^0.12).loop #9 Once the shopper reaches the shelf at 45 ticks, their floating display updates to show a golden apple and happy villager sparkles appear.loop #12 In state 2, the shopper turns toward the quartz checkout counter and walks over to pay the cashier.


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.
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.
/kill @e[tag=c9_ent]/scoreboard objectives remove c9_tick/scoreboard objectives remove c9_state/fill ~-7 ~ ~-5 ~7 ~2 ~5 minecraft:air/fill ~-7 ~-1 ~-5 ~7 ~-1 ~5 minecraft:grass_blockThey 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.
Yes! Edit loop command 9 and replace minecraft:golden_apple with any item ID like minecraft:bread, minecraft:book, or minecraft:diamond.
▶Living Citizen CottageCustom MobsEasy24 cmds
▶Miniature Toy Army SkirmishCustom MobsMedium24 cmds
▶Da Vinci Ornithopter Griffin AutomatonCustom MobsExpert24 cmds
▶Kintsugi Cracked Teapot Tanuki SpiritCustom MobsMedium24 cmds
▶Lumbering Walking Castle BossCustom MobsExpert20 cmds
▶Molten Waffle-Iron Lava GolemCustom MobsMedium23 cmds