Minecraft
  1. Minecraft
  2. MC-55851

Leads not rendering when spawned (attached to mob/fencepost) via command block/structure block

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Resolution: Fixed
    • Affects Version/s: Minecraft 14w21b, Minecraft 1.8.3, Minecraft 1.8.8, Minecraft 15w37a, Minecraft 1.8.9, Minecraft 16w06a, Minecraft 1.10.2, Minecraft 16w32a, Minecraft 16w32b, Minecraft 16w33a, Minecraft 16w36a, Minecraft 16w38a, Minecraft 16w39a, Minecraft 16w39b, Minecraft 16w39c, Minecraft 16w40a, Minecraft 16w41a, Minecraft 16w42a
    • Fix Version/s: Minecraft 16w43a
    • Security Level: Minecraft - Public (Viewable by everyone)
    • Labels:
      None
    • Confirmation Status:
      Confirmed

      Description

      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)

      1. Run this command:
        /summon Pig ~ ~ ~ {UUIDLeast:1l,UUIDMost:1l,Health:0.1}
      2. Run this command:
        /summon Pig ~ ~ ~ {Health:0.1,Leashed:1,Leash:{UUIDLeast:1l,UUIDMost:1l}}
      3. Reopen the world

      Steps to reproduce (structure block)

      1. Save a structure with a mob on a lead, attached to a fence
      2. Remove the mob
      3. Load that structure in the same place (MC-102170)
      4. Reopen the world

      Code analysis: https://bugs.mojang.com/browse/MC-55851?focusedCommentId=284856&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-284856

        Activity

        Hide
        [Mod] Kumasasa added a comment - - edited

        Does the lead render if you spawn the horse without the lead and attach it manually ? Yes, it does.

        Show
        [Mod] Kumasasa added a comment - - edited Does the lead render if you spawn the horse without the lead and attach it manually ? Yes, it does.
        Hide
        [Mod] Kumasasa added a comment - - edited

        Confirmed. Command used for screenshot:

        summon EntityHorse ~-1 ~ ~2 {Tame:1,Saddle:1,Leashed:1,Leash:{X:2,Y:64,Z:2}}
        
        Show
        [Mod] Kumasasa added a comment - - edited Confirmed. Command used for screenshot: summon EntityHorse ~-1 ~ ~2 {Tame:1,Saddle:1,Leashed:1,Leash:{X:2,Y:64,Z:2}}
        Hide
        roman seiler added a comment -

        It is also possible to get the leash to render by going far enough from the leashed mob.

        Show
        roman seiler added a comment - It is also possible to get the leash to render by going far enough from the leashed mob.
        Hide
        [Mod] Galaxy_2Alex added a comment -

        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.

        Show
        [Mod] Galaxy_2Alex added a comment - 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.
        Hide
        [Helper] Marcono1234 added a comment -

        Confirmed for

        • 1.8.3
        Show
        [Helper] Marcono1234 added a comment - Confirmed for 1.8.3
        Hide
        [Helper] Marcono1234 added a comment - - edited

        Confirmed for

        • 15w37a

        How to reproduce

        1. Run this command:
          /summon Pig ~ ~ ~ {UUIDLeast:1l,UUIDMost:1l,Health:0.1}
          
        2. Run this command:
          /summon Pig ~ ~ ~ {Health:0.1,Leashed:1,Leash:{UUIDLeast:1l,UUIDMost:1l}}
          
        3. Reopen the world
        Show
        [Helper] Marcono1234 added a comment - - edited 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
        Hide
        Ron Smalec added a comment -

        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.

        Show
        Ron Smalec added a comment - 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.
        Hide
        [Helper] Marcono1234 added a comment - - edited

        Ron Smalec what you are describing could be MC-65040 as well

        Show
        [Helper] Marcono1234 added a comment - - edited Ron Smalec what you are describing could be MC-65040 as well
        Hide
        [Helper] Marcono1234 added a comment - - edited

        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;
        }
        
        Show
        [Helper] Marcono1234 added a comment - - edited 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 ; }

          People

          • Assignee:
            [Mojang] Agnes Larsson
            Reporter:
            Griffin Heart
          • Votes:
            7 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              CHK: