mojira.dev
MC-304421

"attack_range" component breaks hit result

How to Reproduce

/give @p diamond_sword[attack_range={}]

Hover crosshair over button on a block (Seems to affect any non-full sized blocks like buttons, banners, signs, grass, etc)


Result

Unable to press button and block outline shows on block behind it

image-20251120-162030.png

Expected

Outline on button and being able to press it

Suggested Fix (from testing)

In ProjectileUtil#getHitEntitiesAlong(final Entity source, final Vec3 origin, final Vec3 from, final Predicate<Entity> matching, Vec3 to, final float entityMargin, final Block clipType), when it creates the new ClipContext, instead of passing ``Vec3 to`` , instead pass ``Vec3 from`` argument from getHitEntitiesAlong arguments

This fixes it from testing

@Mixin(ProjectileUtil.class)
public abstract class MixinProjectileUtil {
    // set argument ``to`` in``new ClipContext`` with ``from`` from the ``getHitEntitiesAlong`` arguments
    // in turn, itll use the minRange for the hit result clip context fixing the issue
    @ModifyArg(method = "getHitEntitiesAlong(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/phys/Vec3;Ljava/util/function/Predicate;Lnet/minecraft/world/phys/Vec3;FLnet/minecraft/world/level/ClipContext$Block;)Lcom/mojang/datafixers/util/Either;", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/ClipContext;<init>(Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/level/ClipContext$Block;Lnet/minecraft/world/level/ClipContext$Fluid;Lnet/minecraft/world/entity/Entity;)V"), index = 1)
    private static Vec3 mfp$fixMC_304421(Vec3 to, @Local(argsOnly = true, ordinal = 1) Vec3 from) {
        return from;
    }
}

Environment

Windows 10

Attachments

Comments 1

can confirm

can reproduce

lowercasebtw

(Unassigned)

Confirmed

(Unassigned)

1.21.11 Pre-Release 1

1.21.11 Pre-Release 2

Retrieved