Since I was given the ticket to this issue, I decided to make some changes to make this report a bit more informative. For full information, see MC-96024. I'm just going to sum it up shortly in this report.
The bug
If you connect any animals to a lead, then place the lead on a fence, then go far away from them (Until they become unloaded), then go back, there is going to be most of the times one of these issues occurring:
The lead will simply break and drop as an item on the ground.
The lead will become invisible, sometimes unloading and reloading will fix this issue, sometimes not. If this occurrence happens, the client will think the animal isn't actually leashed, and you can right click it to leash it, however due to this being only client side, you cannot place the lead on a fence.
The leads will glitch out and connect to an invisible target far away (See pictures). Following the lead for a bit of time will fix this, or, in some cases, make occurrence #1 happen.
I have yet to find a way to, using command blocks, leash the animals back. I'm not exactly sure how the leashing part works technically. It seems like there are two tags for every mob that are related to leads, but all they do is place a lead on the specified location, not connect the animal to it.
Code analysis
Code analysis by @unknown can be found in this comment.
Related issues
is duplicated by
relates to
Attachments
Comments


Cannot reproduce.
Unable to reproduce.
I saw this in one of VintageBeef's recent episodes as well.
It still happens. just look at bdoubleOs latest episode in 13w19a http://www.youtube.com/watch?v=h-0J61KbLns
This is happening on my server when it is rebooted, running 13w19a.

Reopened.

Confirmed.
Also affects 13w23a.

In the screenshot all horses are attached but only the two saddled ones show the lead
still in 25c!
I hope they fix this before the official release next week
Still in 1.6 pre-release
Confirmed in multi-player. Pre-release 1.6 (downloaded yesterday). When the server restarted ALL leads were broken and laying on the floor.

Is this still a concern in the current Minecraft version? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases.
it seems that if a baby horse is on a lead for to long they start taking damage and die?
You might be seeing MC-13632.
this bug is extremely annoying. have the same problem. sometimes the lead is just invisible, sometimes it lays on the ground and the animals walk freely around. sometimes this happens when i go far away and leave the chunk and come back. sometimes it happens when i rejoin the smp. you have to play a little longer, because sometimes it just works as it should. i dont know what exactly trigger this bug, but it happens on my smp way too often. and this is on release 1.6.1
bug is still present in 1.6.2
got the bug in 1.6.2 too. However I didn't recognize it in 1.6.1, but that might be by luck.
I saw this on the SMP server I administrate after restarting the server app in both 1.6.1 and 1.6.2. (Win7 based server)
A gamer on the server has also seen this happen in 1.6.2
It is certainly in 1.6.2. We have a scheduled reboot daily, and are now considering not doing the reboot. 25% of everyone's horses go missing each time.
This is currently happening to me also. The leads in my instance are not invisible but can be found lying on the ground around the posts after traveling away from the chunk in question and then returning to it. Oddly, it does not happen in ALL instances, only sometimes.
This happens to me, except they don't act like they are on a lead. I will tie up my horse, donkey, and mule, leave for a while, return and the leads are gone and the 3 mobs are freely walking around.
I did some testing today. My Horse was standing in chunk A while the fence was in chunk B. Because chunk A was loaded before chunk B, the lead drops itself on the floor.
Current fix -> Try to leave horse and fence in the same chunk.... I hope, that it will work for a while.
Edit: Nope, my fix doesn't work

Based on the above comments, there seems to be at least two different (but closely related) bugs that are being confused. One with leashes breaking inexplicably (mob drops a lead item and is able to wander; leash no longer appears to be on the mob; seems to happen whenever the server (minecraft's internal server or the smp server, whatever is doing the non-graphics processing.) is restarted), and one with leashes and their knots disappearing (selection box included) but the mobs still acting like they are leashed, which seems to happen when the client is restarted (again, it can be SSP or SMP).
The bug's are probably the same oversight (occurring when the leash is unloaded on either the server or client), but appearing to be different do to the differences in what the two do.
Okay now they are disappearing when I am right next to them. I tied up my horse, donkey, and mule, did some smelting/crafting/buildings, and despite being less than 35 blocks away from them the entire time, the leads broke. However, this time they dropped as items, although they still broke for an unknown reason.
My god this is so annoying. A few days ago I had 12 leads, now I am down to 3, because they keep breaking and then the items despawn. Can they fix this in 1.7, or maybe like 1.6.3???
I have the same problem when I go to the nether and back. nothing else, just the nether. In survival.
It seems as if the lead is only visually gone; the mob acts as if it is still attached (tested with a tamed horse).
However, if you punch the fence, it destroys the fence instead. The lead drops, but after a small delay.
This is an annoying problem. I can't ride my horse anymore because, even though I removed the fence, it stands still.
The problem is not just a visual one. There may be two bugs here:
1. The leads disappear from the fence post to the mob when I log out and then back in to my server, but
2. The leads actually break and appear on the ground as an item when I leave the area and come back (perhaps on chunk reload?).
This is extremely annoying as it has cost me several mobs. Furthermore, I can't rely on just bringing fence and leads when I go exploring. I have to encase my horse in walls because I just can't rely on the to leads keep my horse there.
I can verify this - just encountered it the other day. Had a horse leashed to a post in a desert village. Did some errands, came back to hear my horse running into a cactus (that was out of reach of his leashed limit). I went to the spot where it was and the lead was nowhere to be seen and my horse completely un-tethered. (Not a case of an invisible lead!)
I've seen issue two myself once. I'm not sure whether I had gone to the nether, a long way away, or just logged in/out.
Could this be a similar issue to mobs escaping from fences MC-2025? Say the horse and fence are in two different chunks and the horse is at the maximum range of the leash when the chunk unloads.
The chunk with the horse loads.
The horse starts moving.
The chunk with the fence loads, leash is connected up to the horse. (The horse moves again and code detects the) leash is too long, leash breaks. Sometimes this will not drop a leash at all (a chance based thing?).
This could also happen with the horse and fence in the same chunk, if the leash is loaded later.
Confirming it is easily able to be reproduced most of the time by going far enough away for the chunk to unload. Note that this for the lead actually breaking, not the invisible lead problem. I am unsure as to why the breaking problem is being closed as duplicates.
Been getting this since 1.6.1. I thought it was a SMP issue but it have been happening extremely often in my current SSP world as well (1.6.2).
Confirmed, still a problem on my server running 1.6.2. Everyone has to build stables for their horses, or the leads break and they wander away.
@Joey F - They are being closed as duplicates because they are duplicates of this ticket. 1000 "Hey the leads don't work" doesn't help us, only one ticket with appropriate information is necessary.
@ArmEagle - I doubt this is anything related to mobs escaping fences. If anything it would be closer related to an old bug (pre-JIRA) where minecarts would derail if they moved into an unloaded chunk. I SUSPECT that when the leashed mob's chunk is loaded but the fencepost is not, that the leash determines it's not connected to anything instead of waiting for the chunk to load before checking.
Confirmed for 13w37a in SMP. Three horses next to each other all dropped their leashes when restarting the server.
Confirmed in 13w37a. When leaving the chunk, leads either are invisible until the fence is broken or leads are not there at all and the horses are walking around.
I will confirm if this behavior is still present in 13w38c later today.
Still present in 1.7.2.
This is happening to me a lot in 1.7.2. The leads DO NOT become invisible, they BREAK. Most of the time I find the items lying on the ground. However looks like the cause is the same, since it doesn't happen in loaded chunks.
I agree with Talven81 assumption.
Experiencing this issue as well with 1.7.2. Oddly enough, the lead that did break somehow not only broke, it simply vanished. It cannot have despawned, breaking should have caused it to fall into a system of water that I have leading into a hopper > chest and the lead simply did not end up in the chest. ie, somehow it simply vanished. Regardless, given the circumstances, I am inclined as well to suspect it being related to the (slow) loading of the chunk and the fence post(s) this lead was connected to.
This is happening to me and my friend as well.
For me, the lead broke and was completely gone. It did not even spawn as items. For my friend, the leash only became invisible. However, we were both in the same server (I was running the server) and our house were only a few blocks away from each other.
This is becoming annoying since the horse ran to our wheat farms, chicken farms, cow farms and so forth farms and then I have to hunt for the horse and make a new lead again.
It is not just leads that show this kind of behaviour; if I use a water / hopper containment for an egg farm instead of using leads, similar phenomena occur when reloading the chunk. Specifically, chickens will start falling through the hopper top and end up inside of it. Any eggs they lay subsequently are no longer caught by the hopper and simply fall to the side (if there is room).
A reasonably straightforward I can think of would be to simply ensure that the loading of (passive) animals/mobs occurs after everything else has been loaded. To ensure that any leads they are attached to, any trap they are contained in and so forth actually is present whenever they are in fact loaded.
I'm pretty sure that I found the source of the problem (and a solution) of vanishing leads.
It is related to the reading and writing of the NBT tag of the (leashed) entities.
When the entity is read from the NBT tag, the leash is not read directly, but the corresponding tag compound is first stored in a temporary variable (in MCP it's called field_110170_bx). Once the entity has its first update, this temporary variable is then used to attach the entity to another entity or to a leash knot, and the temporary variable is set to null.
The problem occurs when the entity is again written to an NBT tag before it had its first update, because it is not yet attached to something. But the writing method assumes that the lead has already been initialized, and therefore, no further information about the lead is stored. The next time, the entity is read from the tag, we have the information that it is leashed, but the information of where it is attached to has gone.
So, the problem can be solved by additionally checking on writing to the NBT tag, if the temporary tag compound variable for the leash (field_110170_bx) is not null. If this is the case, then the lead was not yet initialized, and it is necessary to store again the tag compound. I tried this and it worked.
I have to add, as already pointed out in earlier comments, there are actually two different bugs - one, where the leashes disappear completely, and one, where they disappear only visually. Both bugs have the same reason, but the solution that I suggested in my previous post only helps with the first one.
The second bug, where the leash is invisible, but the entities behave leashed, happens when the client does not know about the leash because it did not receive a corresponding packet from the server. This is because the server does not send a packet, if the tag for the leash was not yet read (i.e. the information is still only in the temporary variable field_110170_bx in the class EntityLiving).
This problem can be solved by sending a package at the end of the method that reads the leash tag, which is called func_110165_bF in class EntityLiving in MCP, analogously to the package that is sent when a leash is created in func_110162_b.
With this modification and the suggested modification in my previous comment, I could not observe any disappearing leashes.
2 months and no word. Is this going to be fixed? It happens all the time to me and makes leads pretty much useless as they can't be relied upon.
Still broken as of 14w05a.
Word of advice, never leave your animals on a lead, only use it to "lead" your animals to their pens/stables/enclosed areas. Won't be fixed anytime soon(over a year now). Deal with it in the meantime with my advice.
Confirmed for 14w11b
I regularly encounter both issues: invisible lead and breaking lead (breaking much more often). Both problems occur when the chunk is unloaded and reloaded again. Still a problem as of 1.7.9.
Confirmed for 14w21b.
I just discovered this in 1.7.9
Leads are nice for traveling, but if they keep breaking on fence posts then 50% of its functionality is wasted. Seems pretty high priority to me.
Confirmed for 14w25b.

perhaps the current implementation should just be scrapped and redone. Or maybe they're waiting until the rest of Minecraft works better for this sort of thing? Still, if this is not working, what is the point of having this part of the lead's functionality? It's a bunch of false security for your animal farm. Take it out until it works and leave people to use fenceposts like we did before this item came out.
What is so hard about fixing this? My horse keeps wandering off when I go caving and I have to craft new leads all the time.
Normally before, like I said, the leads would randomly break and be on the ground. I would tie up my animals, walk off, return, and the animals would be roaming freely and the leads would be items on the ground.
Around 10 minutes ago, I went to ride my horse and, just like this problem states, the horse acted like it was on a lead although the lead didn't seem to be present. I found out it was invisible, and in order to get the lead back I had to destroy the fence post it was on. So I've experienced both variants of this lead disappearance glitch, and both are annoying.
Hawk: Until the issue is fixed, you can simply keep your horses in a fenced-in pen. You can jump a horse over a fencepost when you're riding, but a riderless horse can't jump a fencepost. This isn't a fix, of course, but at least you can stop losing leads.
confirmed for 14w28b, affects all animals not only horses
I attached a 30s video showing an instance where a lead is invisible upon game start and doesn't even pop off when the fence it is tied to is destroyed.
After exiting and starting the game again, the lead appeared again (in mid-air where the fence once stood) and popped off into item form after a few seconds.
They did remove the rabbit teleporting in MC-64395.
I'm playing 1.8 pre-release 1 and the leads break on my horses when I travel far away. I have to fence them in. All the leads drop to the ground and no animals are missing.
I used to be able to rely on leads keeping animals in place when I was far away but now I need to obtain much more wood to create large enough pen for all the animals.
I like to keep horses and donkeys outside pens for easy access since I use them for traveling.
Not sure if it's related but animals that usually teleport to you, such as wolves and cats, are unable to keep up because the chunks behind you are unloaded and the animals aren't teleported out as a clean-up measure. Any animals following a player that are supposed to teleport to the player should be teleported before the chunk is unloaded. The animals also tend to get stuck in water very easily and won't teleport while in the water if you walk too far away. Animals that are stuck at path finding get the same issue. It probably has something to do with the threaded AI not restoring to teleportation fast enough.
Chunks scheduled for unloading should be checked for animals in follow-mode and make sure that the AI thread teleports them as a cleanup measure. The AI isn't very good at water and dense forests, which is something that I can live with as long as the intended teleportation works the way it should. I often have to run back to make sure that the animal is able to catch up. Walking slow doesn't help, since they easily get stuck in leaves or ponds.
@Tobias, the mobs swimming slow is covered by MC-48616 and seems to predate the threaded AI. There might be other tickets open regarding your teleportation concerns. Remember to vote on issues.
> Not sure if it's related but animals that usually teleport to you, such as wolves and cats,
> are unable to keep up
Teleporting being broken in 1.8-pre1 is MC-55661.

Same here. I leave for maybe a day (a forest or two away) and I come back and my leaded Horse is walking around and the lead (in item form) is floating on the ground, waiting for pickup.
EDIT: Forgot to mention; I am currently using 1.8 -Pre1.
I'm getting this every 3 minutes. Why? Because I have a command block teleporter to get between my two bases (about half a km apart). Every time I return to my village the lead has broken.
Using 1.8 pre-3 This seems to be related to chunks unloading and reloading. Simply walking away or flying away and returning will cause the lead to disconnect and eventually de-spawn.

@@unknown
This seems to be related to chunks unloading and reloading.
Therefore the summary of this ticket is
Lead break / disappear on game restart or chunk reload
affects the final 1.8 too
I get this same issue. Tying leads to posts for more then a minute is useless. I suspect the chunk loading causes the mob to temporarily "fall" more than 10 blocks from the lead triggering it to break. If you remember back when there were missing chunk bugs you'd often catch mobs "bouncing" up and down in the missing space. They keep falling and resetting their position until the blocks load. My guess is that's what happens and snaps the lead.
That's a very good theory. I tested in a creative world, by tying a horse to a fence at 0,0 and then teleporting it various distances away from the fence
/tp @e[type=EntityHorse,r=15] 0 ~ 9
/tp @e[type=EntityHorse,r=15] 0 ~ 10
With the prior command, the horse bounces back towards the fence, and then walks towards the fence.
With the latter command, the horse breaks free and walks towards the fence. A lead item appears 10 block away from the fence. The fence still has a knot until I reload the chunk (e.g. exit and rejoin the game).
Perhaps the falling entities don't bounce back towards the fence (like a mob hanging from a fence, which just bounces and accumulates fall damage)
It could be the leads themselves. They're loaded before the blocks are, like all other entities. In the split second before the blocks are loaded, the game thinks that the lead knot isn't attached to a fence, so it breaks the lead.
What could determine which explanation, this or the mobs falling, is correct, would be to see how long it takes the chunk containing the leashed mob to load. If the time is not enough for a mob to fall 10 blocks, then the lead itself is the problem.
If the mob falling is the cause, then this could be fixed by slowing the falling speed of all mobs when the chunks aren't fully loaded yet, like players (if that's possible to do with mobs).
If the lead is the cause, then something similar can be done: have the check for if the lead is attached to a fence wait until the chunk has finished loading (again, if that's possible).

Also in 1.8.3.
Fencing-in my horses now. 😞
Still present 1.8.8.
It appears it is fixed in the latest snapshot, 15w31b.
Can't seem to break the lead without hands and arrows, so it must have been fixed.

Resolved as fixed. If someone can reproduce it in the snapshots, please say so
Supposedly this still exists in 15w33c, according to MC-86535.
I said that THIS bug HAS been fixed in the snapshot. The bug I requested a fix for has gone unnoticed by the Mods since 1.6 and is STILL not fixed in the snapshot because they have been getting confused between the bug that I and countless other people have reported and this one so the posts related to mine have been incorrectly marked as duplicates of this bug. Please confirm my report.
kieran heilner is right. this bug here is about a lead which disappears visibly, but is still "there". his bugreport is about a lead which disconnects from horse and fence after reload chunk or restart. if last one can be reproduced in a new snapshot i guess it has another cause than the bug here and therefore is NOT A DUPLICATE of this.

@@unknown and @unknown: Please confirm what I've understood from you:
In this ticket are two different issues mixed up:
that leads are still connected to fence post and horse but visually invisible (fixed)
that leads break, the item form is floating on the ground and the horse is running around (not fixed)
I'm trying to reproduce this bug (either one) and couldn't do it at first (after 10 or so tries with different things). After giving up and going about my game I just respawned near one and the first version of the bug (visual-only) is happening. The lead is visible, but trying to point to some point in the ground and wavering back and forth rapidly in a glitchy way. The horse IS still prevented from leaving the area by the lead. It looks like the lead is changing angles 20 times a second, maybe a max difference in angles of about 15 degrees.
i cannot confirm for the snapshots for version 1.9 (though i didn't played them yet), but the latest 1.8-version. leads clearly aren't connected to the horses and lying on the ground when i "get home". and this is clearly another bug than the one fixed. maybe it has the same cause and therefore could be fixed now, but, as i said, i cannot confirm for the snapshots as i haven't played them. maybe i can in a few days, but maybe someone else is quicker than me 🙂
to be clear, @unknown : yes, you understood right. though the fixed/not fixed cannot be said (by me).
Apparently this ticket is actually two bugs. If you're still experiencing any of them, please create a new ticket and leave a comment with the ticket number here.
Still experiencing it. MC-96024
I seriously hope this will get more attention. It says it's fixed, but it's actually not and no one bothers to do something about it.
What's not covered in MC-96024 that is here?
Fine, reopening this ticket, resolving MC-96024 to this ticket and making you the reporter of this ticket.
Thanks.
This happens to me constantly on my 1.8.9 server. Anything I tie up (horses, cows, sheep) breaks the lead and just gets away before I even notice most of the time. I remember this vaguely being an issue on 1.7, but it's gotten a lot worse now. Back then I generally only had the issue with the lead turning invisible, now they always break. Leads are pretty much useless for me.
This, combined with MC-2025, means that I cannot store animals or mobs in any fashion. They die or escape within a few hours of gameplay.
Hey, just asking @Grum; Does "Far Future Version - 1.10" mean it's going to be fixed but probably not in the very soon snapshots or does it literally mean it's going to be fixed in 1.10?
If they're doing it the same as with "Far Future version - 1.9?" during the 1.8 snapshots, it just means "not now".
Not now, as in not in the current version of the snapshots, or just not the soon snapshots?
"Most likely not in any snapshot before the next major release."
Well that's just great. I'm gonna have to wait another year until this high priority bug is fixed.

Not quite the same bug, but it appears that at least on 1.9-pre4 if you travel far away from the entity then come back, the leash will be invisible and require a relog to be seen.
It is the same bug. See occurrence #2.
Still problematic in 1.9 single player, nothing will stay tied up. The lead always breaks.
1.9 is already listed, and outdates
Occurring 3 is still present in 1.9.4 (Leads connect to an invisible target far away after reentering chunks)
Two more accurate facts to occurring 3:
The lead will always visually connect to x=0,z=0 but it has no physical effect.
And the Entity only needs to be unloaded for the client while it can still be loaded through the spawn chunks.
Still present in 1.10. Is this ever going to get resolved? It's over 3 years old now...
Confirming - still a problem in 1.10.2 .
can confirm 1.10.2
Was already marked as affected...
Confirmed in 16w32a
Confirmed in 16w32b
Confirmed in 16w33a
Confirmed in 16w35a
Confirmed in 16w36a
Confirmed in 16w38a
Confirmed in 16w39a
Confirmed in 16w39b
Confirmed in 16w39c
Confirmed in 16w40a
Confirmed in 16w41a
Confirmed in 16w42a
Confirmed in 16w43a
Confirmed in major release 1.11
Can vouch for it still occurring in 1.11.2; I have had this happen to me twice when trying to lead a llama caravan home and have had to tie one to a fence and make bridges/paths for everyone to follow on.
Happens to me too (1.11.2)
It's been 4-5 years, any chance this bug can get addressed? Leads have always had a lot of problem, and if we are going to keep them in the game we might as well fix them.
Lead lines from a mob to a fence post will vanish, leaving only the wrapped lead around the post, and occasionally both will vanish. Eventually the lead will not just be invisible, but gone all together resulting in the mob wandering off. In that case the lead will pop off and remain on the ground as an item until it de-spawns. This is easily produced by tethering a horse to a fence post, flying a few chunks away and back.
Issue is still present in 17w06a.
Definitely still occuring in 1.11.2. They might as well remove the ability to tie a lead to to a fence, as it will anger a lot of players that they break or disappear. Honestly one of the most critical bugs in this version. along with duplication bugs.

just noticed this bug in pre-7. though the leashed entities are in the spawnchunks, after I died it looked like this
> Didn't play Minecraft for 2 years.
> Come back and see this bug still isn't fixed.
> "Status: Postponed"
> "Fix version: 15w31b"
:|
I can confirm the in 1.12, sometimes the lead becomes invisible
I just tested the leads in the Windows 10 version. While rendering of the leads is not perfect. They did not disconnect from the post and animal, disappear, or despawn. After an hour of playing, the leads remained. Respectfully, perhaps the code from that version could be compared to the Java version.

Confirmed for Minecraft Java 1.12.2- all three possible variants (invisible, breaking, and stretching afar)

Confirmed for 1.13-pre2

Confirmed for 1.13-pre3
Found out how to fix this in vanilla code I think. Encountered the bug reliably with my own entity using forge, upon debugging I tracked it down and tested a fix, works consistently for me. Heres my notes based on MCP mappings:
Â
So vanilla behavior works like this:
Actively leashed entity EntityLiving.leashedToEntity is written to nbt with tag "Leash" when chunk unloads.
On chunk reload, the nbt data is loaded into a temporary variable called EntityLiving.leashNBTTag
The next time the entity ticks, it detects EntityLiving.leashNBTTag has data and attempts to re-establish the leash link and set EntityLiving.leashedToEntity
An important note here is that EntityLiving.leashNBTTag is not written to disk, it only writes to the "Leash" nbt tag if EntityLiving.leashedToEntity is not null.
So heres the real bug: There is an edge case where the entity can load and then instantly unload before it has a chance to tick, causing the data loaded into EntityLiving.leashNBTTag, but then never properly used to set EntityLiving.leashedToEntity, since EntityLiving.leashNBTTag is not serialized, the leashed data is now lost forever, breaking the leash link.
Heres the fix: In EntityLiving.writeEntityToNBT, at the end of the "if (this.leashedToEntity != null) {" if statement, add an else clause:
} else if (leashNBTTag != null) {
compound.setTag("Leash", leashNBTTag);
}
Â
Â
This makes sure the leashNBTTag data is preseved if it wasnt able to get made use of.
Â
Note I only confirmed this fix with my own entity that reproduces it a lot, did this test fix in vanilla code and confirmed it fixes it, tested with my entity leashed to a fence post only, not to another entity eg the player, which probably doesn't have the bug since theyre always chunkloaded.
Also note, you will still get visibly broken leash links on the client side, but server side the link is still there.
The glitch still works in 1.13 proper. I've only gotten result #2 in my expirience so far.
Confirmed for 1.13.1.
There are two bugs related to leashes. One is regarding invisible leads and one have to do with the leashes breaking. Kevin Gagnon suggestion for the fix certainly does the job but I would suggest to not fix the bug in the simpler way as suggested by Kevin and go for a more interesting approach that will have deeper mechanics for those that seek it out.
Â
Invisible leashes bug.
When walking further then 80 blocks from mobs that are attached with leashes and walking back the leashes become invisible. This is because leashes are part of EntityTracker and have a hardcoded range of 80 blocks as all animals have a range of 80.
else if (entityIn instanceof IAnimals)
{
this.addEntityToTracker(entityIn, 80, 3, true);
}else if (entityIn instanceof EntityHanging)
{
this.addEntityToTracker(entityIn, 160, Integer.MAX_VALUE, false);
}
The issue comes from the fact that leashes are sent to the client after the entity first become entity processing. The packets that link entities with there respective leashes are sent to players in EntityLiving.java by the following code.
Â
Â
public void setLeashedToEntity(Entity entityIn, boolean sendAttachNotification)
{
this.isLeashed = true;
this.leashedToEntity = entityIn;
if (!this.world.isRemote && sendAttachNotification && this.world instanceof WorldServer)
{
((WorldServer)this.world).getEntityTracker().sendToAllTrackingEntity(this, new SPacketEntityAttach(this, this.leashedToEntity));
}
if (this.isRiding())
{
this.dismountRidingEntity();
}
}
Â
Its clear that the leash packets are sent to only players within range. This means that any player that is further then 80 blocks from the entity never receive the packets and assume the mobs don't have a leash. This makes all mobs lose there leashes unless players can somehow teleporting to the mobs directly via commands or logging in next to them. The same issue is that the leashes are removed on the client if the player have a higher render distance and simply walk further then 80 blocks to stop seeing the mob and walks back.
Â
The fix was done with aid from Pokechu22. There is a code in EntityTrackerEntry.java that re-updates players in case a player gets in range in public void updatePlayerEntity(EntityPlayerMP playerMP).
By placing the following line of code in the updatePlayerEntity somewhere in the large if statement the bug of invisible leashes fixes itself. The leashes simply re-update as the player gets close enough again to the animals.
Â
if(this.trackedEntity instanceof EntityLiving){
playerMP.connection.sendPacket(new SPacketEntityAttach(this.trackedEntity, ((EntityLiving)this.trackedEntity).getLeashedToEntity() ) );
}
Â
Breaking leashes
Â
The second bug regarding the breaking leashes comes from what Kevin Gagnon explains. The NBT of entities never save to disk as the entity needs to become entity processing at least for 1 gametick to reload the leash in the following code found in EntityLiving.java recreateLeash(). The leash is simply recreated and the leash can be saved to disk again. If the leash never becomes updated the leash isn't saved breaking it the next time the chunk is reloaded. This happens if the mob is loaded into lazy chunks and never update.
As an alternative fix I suggest that the recreateLeash() code is run directly after the entity is placed into the world after loading the chunk. This can be done by having the recreateLeash() run in the spawn entity into world. This will ensure that entities that are loaded get there leashes reattached instantly without problems as there leashes otherwise wont be attached until they update at least ones. This solves the breaking of leash bug and ensure the mob doesn't need to become loaded to become attached with its leash. It is a safer way to fix the bug as it guaranties that the mob never is detached from its leash at any given time that can cause issues in rare instances.
Â
Just as a suggestion. Add the one "entityIn.postLoad();" line in onEntityAdded in WorldServer.java
Â
protected void onEntityAdded(Entity entityIn)
{
super.onEntityAdded(entityIn);
this.entitiesById.addKey(entityIn.getEntityId(), entityIn);
this.entitiesByUuid.put(entityIn.getUniqueID(), entityIn);
Entity[] aentity = entityIn.getParts();
entityIn.postLoad(); // <-- Add this line
if (aentity != null)
{
for (Entity entity : aentity)
{
this.entitiesById.addKey(entity.getEntityId(), entity);
}
}
}
This line could then be used to post load the leashes to animals right after the animal is loaded into the world.
Â
affects 18w44a
This bug affects Wandering Traders now. The leads break and the trader llamas just walk away.
-I was just trying to get a trader llama into my pen and the lead randomly broke, but the visual stayed on the screen and started jittering chaotically. I quit & reloaded the world and the lead was still jittering, stretched toward -∞ on the x axis. I followed it out some distance until it disappeared and came back. The glitch is gone now, but I never got my lead item back.

That's a different bug, see MC-143351
I also have this happening on game load in 1.13. There are some leashed horses in the pasture of my base. Sometimes when I load the game their leads have broken and they are wandering loose. When this happens on game load, the leads do not drop, I have to reattach them using new leads. When lead breaking happens on chunk reload after going away and coming back, the leads are dropped and can be reused.
I get this is postponed but still happening in 19w13b
Also why postponed ;(
still happens all the time in 1.14
Confirmed in 1.14.1. This is a really old bug, it would be the time to be fixed,Â

Also in 1.14.2, and 1.14.3 Pre-release 2.
I believe I experienced this issue in 1.14.4. I have a llama connected to a fence by lead. I noticed that the lead had turned invisible so I replaced it. Right-clicking the lead knot on the fence post did not remove the lead but left-clicking the knot removed the lead and dropped as the lead item as normal. While the lead was invisible, it seemed that the llama was still connected to the fence post. However, I was able to connect another lead to the llama. Despite this, the llama would not move when I moved farther away and the lead stretched as I moved. This weirdness NEEDS to be fixed.

Confirmed in 19w45b.
still happening in 1.14 xD
@[Zrov] This is fixed in 1.15. Fixes are never back-ported to previous versions.