Whenever I use the command " /summon EntityHorse ~-1 ~ ~2 {Tame:1,Saddle:1,Leashed:1,Leash:{X:-530.3,Y:56.0,Z:747.4}} " the horse will spawn with a lead attached to a fence post, however the lead will not render. The only way to get the lead to render is to log out and log back into the world.
Steps to reproduce (command block)
Run this command:
/summon Pig ~ ~ ~ {UUIDLeast:1l,UUIDMost:1l,Health:0.1}
Run this command:
/summon Pig ~ ~ ~ {Health:0.1,Leashed:1,Leash:{UUIDLeast:1l,UUIDMost:1l}}
Reopen the world
Steps to reproduce (structure block)
Save a structure with a mob on a lead, attached to a fence
Remove the mob
Load that structure in the same place (MC-102170)
Reopen the world
Attachments
Comments 9
Confirmed. Command used for screenshot:
summon EntityHorse ~-1 ~ ~2 {Tame:1,Saddle:1,Leashed:1,Leash:{X:2,Y:64,Z:2}}
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. If this has been done, we can reopen the issue.
Keep in mind that the "Resolved"-Status on this ticket just means "Answered", and that we are waiting for further information on whether this issue still exists or not. We will reopen it as soon as the requested information has been delivered.
Confirmed for
15w37a
How to reproduce
Run this command:
/summon Pig ~ ~ ~ {UUIDLeast:1l,UUIDMost:1l,Health:0.1}
Run this command:
/summon Pig ~ ~ ~ {Health:0.1,Leashed:1,Leash:{UUIDLeast:1l,UUIDMost:1l}}
Reopen the world
This occurs with all leashes, not just summoned leashes. I is an issue as of latest snapshot February 11, 2016 snapshots.
It is inconsistent, but leashes don't render sometimes on login.
@unknown what you are describing could be MC-65040 as well
Please link to this comment in the description of the report.
The following is based on decompiled version of Minecraft 1.8 using MCP. All method and class names are the names used in the decompiled version.
There are two problems that cause these bugs:
Leads not rendering when summoning leashed mob
The problem here is that the public void readEntityFromNBT(NBTTagCompound tagCompund)
method of the net.minecraft.entity.EntityLiving
class which reads the NBT data only sets the Leash
compound as value for the leashNBTTag
variable. The entity this mob is leashed to is set once the protected void updateLeashedState()
method is called which happens at some point when the mob is updated. The problem is that the packets send to the client do not contain this values of this tag. That is why the packet net.minecraft.network.play.server.S1BPacketEntityAttach
exists. This packet is only send when the public void setLeashedToEntity(Entity entityIn, boolean sendAttachNotification)
method of the net.minecraft.entity.EntityLiving
class is called, or when the player loads a chunk. As the NBT reading method is also called when an entity is loaded calling the protected void updateLeashedState()
method would send the packet twice (as the player loading the chunk would receive this packet as well).
Leads sometimes not rendering when loading a leashed mob
The problem here is that eventually the player is updated before another entity. This causes the entity to only have the NBT data of the entity it is leashed to set, but not the actual entity as leashedToEntity
. This means no packet net.minecraft.network.play.server.S1BPacketEntityAttach
will be send.
Possible fix
A possible fix would be to not send a net.minecraft.network.play.server.S1BPacketEntityAttach
packet when a player loads a chunk, but instead have the private void recreateLeash()
method call the public void setLeashedToEntity(Entity entityIn, boolean sendAttachNotification)
method:
private void recreateLeash()
{
if (this.isLeashed && this.leashNBTTag != null)
{
if (this.leashNBTTag.hasKey("UUIDMost", 4) && this.leashNBTTag.hasKey("UUIDLeast", 4))
{
UUID var5 = new UUID(this.leashNBTTag.getLong("UUIDMost"), this.leashNBTTag.getLong("UUIDLeast"));
List var6 = this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, this.getEntityBoundingBox().expand(10.0D, 10.0D, 10.0D));
Iterator var3 = var6.iterator();
while (var3.hasNext())
{
EntityLivingBase var4 = (EntityLivingBase)var3.next();
if (var4.getUniqueID().equals(var5))
{
// Replaced this
//this.leashedToEntity = var4;
setLeashedToEntity(var4, true);
break;
}
}
}
else if (this.leashNBTTag.hasKey("X", 99) && this.leashNBTTag.hasKey("Y", 99) && this.leashNBTTag.hasKey("Z", 99))
{
BlockPos var1 = new BlockPos(this.leashNBTTag.getInteger("X"), this.leashNBTTag.getInteger("Y"), this.leashNBTTag.getInteger("Z"));
EntityLeashKnot var2 = EntityLeashKnot.func_174863_b(this.worldObj, var1);
if (var2 == null)
{
var2 = EntityLeashKnot.func_174862_a(this.worldObj, var1);
}
// Replaced this
//this.leashedToEntity = var2;
setLeashedToEntity(var2, true);
}
else
{
this.clearLeashed(false, true);
}
}
this.leashNBTTag = null;
}
Does the lead render if you spawn the horse without the lead and attach it manually ?Yes, it does.