mojira.dev
MC-267768

Entity reach attribute cannot exceed block reach attribute

The generic.entity_interaction_range attribute cannot exceed the generic.block_interaction_range attribute. This can easily be reproduced by the following steps:

  • Spawn a pig in front of you

  • Run /attribute @s minecraft:generic.block_interaction_range base set 0

  • Notice how you can't interact with the pig

This comes from the `net.minecraft.client.renderer.GameRenderer#pick` method, let's take a look (23w51b, mojang mappings):

double d = this.minecraft.player.blockInteractionRange();
double e = this.minecraft.player.entityInteractionRange();
double g = Math.max(d, e);
// Here, it picks the nearest block in front of the player based on the block interaction range.
// What should be noted, is that this Entity#pick method NEVER returns null, when no block
// is in range, it returns a BlockHitResult#miss
this.minecraft.hitResult = entity2.pick(d, f, false);
Vec3 vec3 = entity2.getEyePosition(f);
double h = g;
double i = Mth.square(h);
// Based on the previous comment, it means this condition will always be false. 
// A quick fix (tested with Fabric 23w51b) is to add a second condition: 
// if (... && this.minecraft.hitResult.getType() != HitResult.Type.MISS) {
if (this.minecraft.hitResult != null) {
    i = this.minecraft.hitResult.getLocation().distanceToSqr(vec3);
    h = Math.sqrt(i);
}

Linked issues

Comments 2

Duplicate of MC-267385, fixed in next snapshot.

Oh didn't catch that one when searching, oops! 

roro1506HD

(Unassigned)

Unconfirmed

(Unassigned)

23w51b

Retrieved