The title is a mouthful, I know, but basically my question is exactly what Wynncraft managed to do. When right-clicking a villager, you would normally open their trading GUI. However, is there a way in Vanilla Minecraft to replace the opening of the GUI with let's say... activating a tellraw command? If you need a visual, I suggest going to the server "play.wynncraft.com" and interacting with the NPCs there.

  • 2
    I dunno... maybe place a custom coded sign behind it? Many servers, Wynncraft most likely included, use customised Villager GUIs applied through plugins. On MCOrigins (mc.mcorigins.com) almost all villagers have a "pre-menu", selecting what kind of trades that come up. This is particularly evident in Eggwars. This server uses very many plugins, and I doubt your problem can be solved without turning to the dark side (mods) Nov 29 '16 at 7:13
  • Yeah, AFAIK this is not possible without server plugins or mods. Nov 29 '16 at 7:58
  • While managing this would be easier with mods, it is definitely very possible in vanilla; villagers don't have a GUI to open if there are no trades, and there are various methods of detecting a right-click action using commands.
    – Skylinerw
    Nov 29 '16 at 13:48

When a villager is summoned without trades, right-clicking it will not open an interface. While detecting who right-clicked it is not particularly accurate, it is possible to do so in vanilla.


Villager to summon, with a label for targeting that specific villager.

1.11+   /summon minecraft:villager ~ ~1 ~ {Offers:{},Tags:["talk"],NoAI:1b}
1.8     /summon Villager ~ ~1 ~ {Offers:{},CustomName:"talk",NoAI:1b}

The stat.talkedToVillager objective-type increments each time a player interacts with a villager, regardless of if it opened an interface or not:

/scoreboard objectives add clickVillager stat.talkedToVillager

Clock commands

The following must be run in numerical order on a clock.

  1. Cause the specific villager to run a /tellraw command targeting the closest player within 5 blocks that has a "clickVillager" score of 1+.

    1.11+   /execute @e[type=minecraft:villager,tag=talk] ~ ~ ~ /tellraw @a[score_clickVillager_min=1,r=5] ["You have right-clicked me."]
    1.8     /execute @e[type=Villager,name=talk] ~ ~ ~ /tellraw @a[score_clickVillager_min=1,r=5] ["You have right-clicked me."]
  2. Reset playerscores to 0 to allow future detection.

    /scoreboard players set @a[score_clickVillager_min=1] clickVillager 0

If multiple villagers are clumped together, then it will not be directly possible to distinguish who clicked which villager (which is where mods would shine with accuracy).

  • Is this all possible to do in 1.8.9 by chance? If not that's 100% fine, I'm just too lazy to download resource packs, Optifine, and WorldEdit for the more recent updates haha.
    – KompriZe
    Nov 29 '16 at 18:21
  • Oh also, where would you add a NoAI for the Villager summon command?
    – KompriZe
    Nov 29 '16 at 18:27
  • Final question, when activating the tellraw commands, I would do the tellraw, then the reset, and then I can have another tellraw command runnng from there, which then activates the next reset, and so on?
    – KompriZe
    Nov 29 '16 at 18:31
  • @KompriZe It'll work in 1.8, yes. I've added commands specific to 1.8, as well as added NoAI. The reset would run a single time and only after all /tellraw commands run. If you reset their score between each /tellraw, the player isn't going to have a score to detect after the first reset.
    – Skylinerw
    Nov 29 '16 at 19:20
  • Oh um, does the /tellraw work in the JSON format when it is part of /execute?
    – KompriZe
    Nov 29 '16 at 19:42

This thing is maintained by customization of server. Most known and used is Spigot and Forge. Spigot focuses on only server-side changes (aka popularly called "plugins"), Forge can manage similar, but also extensively uses client modifications as well (aka "mods").

In the villager case you have two possibilities, one is better to use with Spigot, second with Forge. Wynncraft and a lot other servers use Spigot-like way (even though they have their own version of server for sure!), when keeping the villager and just catching your actions. When such an action is detected (your click), it is cancelled and custom action is fired instead. Then, it can "talk" or do other things.

Therefore there is no Vanilla way, because you cannot catch click events or similar. All you can do is to read stats (like how many times you talked to villager), but it is kinda messy to use in real life. You would make better to let them press some pressure plate, iniciating redstone for /tellraw , it will be less painful to setup.

Forge aproach might do the same, but it can do one more thing - simply remove the villager and replace it with custom one (which can, but does not need to look same), with custom actions, custom trades, custom GUIs etc. Then it depends fully on how the villager is supposed to be by new code.

There is one big difference between those though - On spigot server, anyone can join with vanilla clients, but if you want to join Forge server, you need to have installed same mods as the server, so you have all added/modified thingies.

For your real usage, you should look for Spigot plugins, that come already prepared to do the job and is primarily aimed for begginers. Search https://spigotmc.org for what you need exactly, or write your own plugin/mod if you won't be satisfied by supply.

  • Okay, that explains how servers are able to do that. Thank you, that might come in handy later for my friend, as he was considering such actions for his server.
    – KompriZe
    Nov 29 '16 at 18:19
  • @KompriZe Writing a plugin should be rather easy, working with events is real basic for Spigot/Bukkit and there is extensive API for doing so. However there is probably already something for that released to everybody, so servers use it. Sadly cannot tell you names, as I don't use those, my aim is for Forge mods :) Nov 30 '16 at 0:20
  • I am not using a server, so I can't use plugins. It's a single player world I am making, and I intend to keep it mod-free. Thank you though :)
    – KompriZe
    Nov 30 '16 at 0:30

Not the answer you're looking for? Browse other questions tagged or ask your own question.