• check_circle Advancements
  • check_circle Functions
  • check_circle Predicates
  • 1,836 views, 56 today
  • 732 downloads, 16 today
  • 16
  • 11
  • 8
the der discohund avatar the der discohund
Level 11 : Journeyman Crafter
1

Villager Leads Minecraft Data Pack
Description

This is a very small data pack, with its only feature being that you can now also use leads on villagers.

Other implementations

I noticed that AustenFrisch made a data pack with the same features, but a few days earlier than I. To help you choose between which one to install, here is a table of differences in the implementation:

Feature
My pack
Austen's pack
Consequences
Activation
Advancement
Constant NBT and scoreboard tests
Performance-wise, NBT tests are rather expensive and especially so when they are called 80 times per player per second without anything being done. On the other hand, advancements only run commands when the corresponding event triggers, which means that my pack causes no server cost for the time that the player doesn't do anything.
This uses the advancement format introduced in 1.16, causing my pack to be incompatible with earlier versions.
Detection of the villager
Ray casting
Radius searchRay casting only searches in the player's line of sight, while searching in a radius may select any villager that is close enough, resulting in a far less accurate search.
Removing a lead item
Shulker box + loot table
/clear command
The /clear command removes the item from anywhere in the inventory, while my method only targets the slot that was actually used.

TL;DR:
My pack is far more efficient and accurate, but incompatible with 1.15 or earlier.

Also, all the features implemented from 12.02.2021 onwards only exist in my version.

In case you still want to check out Austen's pack, here's the link:
https://www.planetminecraft.com/data-pack/leashable-villagers/

How to uninstall

Removing the data pack from the 'datapacks' folder of your world directly doesn't have any noticeable side-effects, however, not uninstalling it properly first can leave a few bytes of extra storage on your world as well as impact the performance of other commands you may want to act on your world.
This can be avoided by running the command '/function tddh_villager_leads:uninstall' without reloading your world before removing the data pack.

Changelog

  • 18.02.2021: Minor tweaks to comply with official conventions, including adding the uninstall function and changing the trading GUI to not close anymore when villagers have the 'global.ignore.pos' tag
  • 18.02.2021: Fixed bug with multiple villagers being connected at once when in the same position
  • 14.02.2021: Fixed bug with trades being regenerated under some circumstances
  • 12.02.2021: Fixed bug with gamemode check being inverted
  • 12.02.2021: Increased interaction range in creative to 5 blocks
  • 12.02.2021: Made the trading GUI close when leashing a villager by resummoning it
  • 12.02.2021: Removed activation on interactions where the the lead is intended to be disconnected instead of connected
  • 11.02.2021: Made lead items not be consumed when used in creative
  • 10.02.2021: Fixed issue with shulker box being attempted to be found in different dimensions, causing leads to sometimes not be consumed
  • 10.02.2021: Fixed critical issue in relation to the /loot command
CompatibilityMinecraft 1.16
toMinecraft 1.17 Snapshot
Tags

1
02/22/2021 5:09 am
Level 22 : Expert Procrastinator
HauntedSniper
HauntedSniper avatar
Hey, dude, love the pack, super useful, but I was thinking, could I suggest you make a pack with a similar idea, but instead of leashing villagers, you could make them follow you (like animals to food) when holding an Emerald Block, just like Quark.

This way it feels less weird than leashing a human. I am aware it wouldn't be the same code as leashing, so it is just a suggestion you don't really have to do, it's just in case you'd like to make that option. If not, I'm happy just using this data pack either way.
2
02/12/2021 8:04 pm
Level 1 : New Miner
The_Mad_Alien
The_Mad_Alien avatar
when i leashed one of my Master villagers they lost most of their trades.
1
02/13/2021 9:05 pm
Level 11 : Journeyman Crafter
the der discohund
the der discohund avatar
Thank you for the feedback, it turned out two commands were executed in the wrong order. In the new version, I can't reproduce the issue anymore.
1
02/12/2021 1:42 pm
Level 1 : New Miner
VioletZCato
VioletZCato avatar
when I right click the villager to disconnect, I don't get my lead back
1
02/12/2021 3:33 pm
Level 11 : Journeyman Crafter
the der discohund
the der discohund avatar
Disconnecting wasn't actually implemented by my pack, it's vanilla behavior and according to any tests I've done, works as you would expect, including the lead being returned. The only way I can reproduce your claim is by going into creative mode, where you also don't get your lead back even with normal mobs like cows, which I didn't change in any way.
2
02/11/2021 7:36 am
Level 18 : Journeyman Architect
NorbertXD
NorbertXD avatar
Finally I can bound up my slaves.
1
02/10/2021 8:48 pm
Level 1 : New Collective
mrcreeper___
mrcreeper___ avatar
GUY how did you do this???
1
02/11/2021 11:58 am
Level 11 : Journeyman Crafter
the der discohund
the der discohund avatar
Should I give a full explanation on how it works or was that meant rhetorically?
Planet Minecraft Logo

Website

© 2010 - 2021
www.planetminecraft.com

Welcome