mojira.dev
MC-79925

null hitResult when no entity or block is in focus while looking through blocks without the ray trace intersecting the blocks themselves

Game Output

[16:57:52] [Client thread/ERROR]: Null returned as 'hitResult', this shouldn't happen!
[16:57:52] [Client thread/WARN]: Null returned as 'hitResult', this shouldn't happen!

How to reproduce

  • Go to a wall which has at least 6 (+1 where you should stand) ladders below or above you

  • Click the mouse

  • Observe that the item in your hand is not swung, and that a warning is printed in the log

Affects all blocks that allow you to stand in them and punch without hitting them, including:

  • Ladders

  • Vines

  • Iron bars

  • Glass panes

  • Portal blocks

  • ...

Not restricted to only the vertical axis - can also happen when looking sideways.

Code analysis

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

Related issues

Attachments

Comments

migrated
[media][media]
marcono1234

Confirmed for

  • 1.8.4

  • 1.8.6

How to reproduce:

  • Gamemode Creative or Survival (at least I can confirm it for these both)

  • Go to a wall which has at least 6 (+1 where you should stand) ladders below or above you and punch down respectively up

migrated

Can confirm in 15w36d. Near/on ladders when messages displayed.

marcono1234

Relates to:

Confirmed for

  • 15w50a

Affects all blocks that allow you to stand in them and punch without hitting them, like:

  • Ladders

  • Vines

  • Iron bars

  • Glas panes

  • Portal blocks
    ...

The main bug might be in the collisionRayTrace(World worldIn, BlockPos pos, Vec3 start, Vec3 end) method of the /Client/src/net/minecraft/block/Block.java class. If all collision checks fail null is returned, however it should maybe rather be returned that the player missed. I added that however the EnumFacing needs to be adjusted and the other arguments might be wrong as well.

/**
 * Ray traces through the blocks collision from start vector to end vector returning a ray trace hit.
 *  
 * @param start The start vector
 * @param end The end vector
 */
public MovingObjectPosition collisionRayTrace(World worldIn, BlockPos pos, Vec3 start, Vec3 end)
{
	this.setBlockBoundsBasedOnState(worldIn, pos);
	start = start.addVector((double)(-pos.getX()), (double)(-pos.getY()), (double)(-pos.getZ()));
	end = end.addVector((double)(-pos.getX()), (double)(-pos.getY()), (double)(-pos.getZ()));
	Vec3 var5 = start.getIntermediateWithXValue(end, this.minX);
	Vec3 var6 = start.getIntermediateWithXValue(end, this.maxX);
	Vec3 var7 = start.getIntermediateWithYValue(end, this.minY);
	Vec3 var8 = start.getIntermediateWithYValue(end, this.maxY);
	Vec3 var9 = start.getIntermediateWithZValue(end, this.minZ);
	Vec3 var10 = start.getIntermediateWithZValue(end, this.maxZ);

	//... Collision tests, var11 is null if none succeeded

	if (var11 == null)
	{
		//return null;
		// EnumFacing.DOWN is probably wrong
		return new MovingObjectPosition(MovingObjectPosition.MovingObjectType.MISS, start, EnumFacing.DOWN, pos);
	}
	else
	{
		//...
	}
}

Please keep in mind that this is only based on partwise obfuscated code so this might not be the actual fix needed.

marcono1234

I updated the comment. The floor implementation was correct, I got there something wrong, sorry 😞

SunCat

Still in 1.9.4
I think this and MC-89132 should be combined, because they occur in the same circumstances (so, your hand doesn't swing AND game output says hitResult is null)

migrated

They're already marked as related, so it's not really necessary.

bemoty

Can confirm for MC 1.12.1.

migrated

Can confirm for 1.13.2.

pokechu22

Can anyone reproduce this in 19w03a? It seems to be fixed there for me.

pokechu22

Resolving as fixed for 19w03a, since a lot of the related code was changed so I assume this bug was also fixed with that. (I haven't fully verified that the offending bit of the code was changed; the collision code is hard for me to navigate).

If anyone can still reproduce, let me know.

migrated

(Unassigned)

Confirmed

null, raytracing

Minecraft 1.8.4, Minecraft 1.8.6, Minecraft 15w36d, Minecraft 15w45a, Minecraft 15w49a, ..., Minecraft 1.13.1, Minecraft 1.13.2, Minecraft 18w48a, Minecraft 18w48b, Minecraft 19w02a

Minecraft 19w03a

Retrieved