mojira.dev
MC-103313

Hitbox of slime and magma cube is offset for some seconds

The bug

Mobs with multiple states have their hitboxs shifted when they spawn (except for the first basic state).

How to reproduce

  1. Press F3 + B to make hitboxes visible

  2. Use the following command

    /summon slime ~ ~ ~ {NoAI:1b,NoGravity:1b,Size:3}

    → The hitbox starts at the back of the baby animal, but then jumps into the middle.

Examples

  • Magma Cube:

[media]
  • and

[media]
  • Pufferfish:

[media]
  • Slime:

[media]

Code analysis

Code analysis by @unknown can be found in this comment.

Related issues

Attachments

Comments

migrated
[media][media][media][media][media][media][media]
SunCat

Can reproduce with

/summon Wolf ~ ~3 ~ {Age:-2000}
marcono1234

Please link to this comment in the description

The following is based on a decompiled version of Minecraft 1.10 using MCP 9.30.

The reason for this is that the method net.minecraft.entity.Entity.setSize(float, float) sets the bounding box based on the min values of the current bounding box. This means if the entity becomes smaller, its hitbox is offset in -x and -z direction; if it becomes larger its hitbox is offset in +x and +z direction. The case in which an entity becomes larger is handled by moving the entity in the according direction, however in case it becomes smaller the hitbox remains offset.

I would suggest centering the hitbox on the current position of the entity instead.

Suggested change (MCP 9.30, Minecraft 1.10)

protected void setSize(float width, float height)
{
    if (width != this.width || height != this.height)
    {
        // Replaced this
        //float f = this.width;
        //this.width = width;
        //this.height = height;
        //AxisAlignedBB axisalignedbb = this.getEntityBoundingBox();
        //this.setEntityBoundingBox(new AxisAlignedBB(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.minZ, axisalignedbb.minX + (double)this.width, axisalignedbb.minY + (double)this.height, axisalignedbb.minZ + (double)this.width));
        //
        //if (this.width > f && !this.firstUpdate && !this.worldObj.isRemote)
        //{
        //    this.moveEntity((double)(f - this.width), 0.0D, (double)(f - this.width));
        //}
         this.width = width;
         this.height = height;
         double halfWidth = width / 2d;

         this.setEntityBoundingBox(new AxisAlignedBB(this.posX - halfWidth, this.posY, this.posZ - halfWidth, this.posX + halfWidth, this.posY + height, this.posZ + halfWidth));
    }
}

Note: One problem which existed before and will still exist is that in case the entity becomes larger its hitbox might afterwards intersect with blocks allowing it to clip through them.

migrated

Confirmed for 16w41a: When baby mobs (e.g. Villagers) are in a confined space (e.g. 1x1 tube) they can gllitch out of it as soon as they grow up.

Thanks for the link to the correct bugpost, @unknown }=)

SunCat

Relates to MC-9568

FaRo1

Related. Apparently the same thing happens for one tick after growing up.

SuperGeniusZeb

Reopening, as this bug still affects slimes & magma cubes with a "Size" greater than 0.

JUE13

Confirmed for 17w17b

JUE13

Confirmed for 17w18a

[Mod] Neko

Also occurs with pufferfish, according to MC-148203.

ZeNico13

Confirmed in 1.14 Pre-Release 2.

Also affects Pufferfish!

The bug

Mobs with multiple states have their hitboxs shifted when they spawn (except for the first basic state).
See examples for more infos.

How to reproduce

  1. Activate hitboxes with F3+B

  2. Spawn a mob (like a Magma Cube or a Slime or a Pufferfish) and look at the hixbox of the mob

Examples

Here are examples in videos:

• Magma Cube:

[media]

and

[media]

• Pufferfish:

[media]

• Slime:

[media]

Additional information

This bug occurs both when the mob appears with an spawn egg or a command (/summon).

ZeNico13

Still in 1.14 pre-3, 1.14 pre-4 and 1.14 pre-5

ZeNico13

Still in 1.14 Release

ZeNico13

Still in 1.14.1 Release

ZeNico13

Still in 1.14.2 Pre-Release 1 and 1.14.2 Pre-Release 2

Asteraoth

Fixed according to @unknown.

wobst.michael

No, this is not fixed. The issue can be seen clearly following the reproduction steps. Nothing has changed here.

FaRo1

I found the issue why I couldn't reproduce it before: Apparently their hitbox now corrects itself as soon as they move. And because they normally start jumping pretty quickly after spawning, it can only be seen properly with NoAI.

Also, they can not suffocate because of this, even though it's not just a visual issue (persists after reloading).

FaRo1

Erik Broes

Confirmed

Entities, Hitboxes

baby, hitbox, magma_cube, slime

Minecraft 1.10, Minecraft 1.10.2, Minecraft 16w32a, Minecraft 16w32b, Minecraft 16w33a, ..., Minecraft 1.14.4 Pre-Release 3, Minecraft 1.14.4 Pre-Release 4, Minecraft 1.14.4 Pre-Release 5, Minecraft 1.14.4 Pre-Release 6, 1.14.4

Minecraft 16w43a, 19w34a

Retrieved