Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-267768

Entity reach attribute cannot exceed block reach attribute

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • None
    • 23w51b
    • None
    • Unconfirmed
    • (Unassigned)

      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);
      }

            Unassigned Unassigned
            roro1506HD Romaric Gomez
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: