Class Reach

java.lang.Object
dev.myriadclient.api.player.Reach

public final class Reach extends Object
What the player can reach and see, measured from the eyes as the server does. Ranges are the player's attribute values (4.5 for blocks and 3 for entities in survival), so they follow creative mode and attribute changes.
  • Method Summary

    Modifier and Type
    Method
    Description
    static net.minecraft.world.phys.Vec3
    aimPoint(net.minecraft.world.entity.Entity entity)
    The point on entity's box closest to the eyes, where a hit or rotation should aim.
    static double
    How far blocks can be reached from the eyes, in blocks (4.5 in survival, 5 in creative); 0 outside a world.
    static boolean
    canReach(net.minecraft.core.BlockPos pos)
    Whether the server would accept interacting with the block at pos: the nearest point of its block space is within block reach of the eyes.
    static boolean
    canReach(net.minecraft.core.BlockPos pos, double range)
    canReach(BlockPos) with a reach of range.
    static boolean
    canReach(net.minecraft.world.entity.Entity entity)
    Whether the server would accept hitting entity (its box within entity reach).
    static boolean
    canReach(net.minecraft.world.phys.Vec3 point)
    Whether point is within block reach of the eyes; false outside a world.
    static boolean
    canSee(net.minecraft.world.phys.BlockHitResult hit)
    Whether a look from your eyes at hit's point would land on that face of that block: the face points towards you (you're past the plane it's in, a slab's top half way up) and nothing comes first, neither another block nor another face of this one (from above, a look at the top of a side face enters through the top).
    static boolean
    canSee(net.minecraft.world.phys.Vec3 point)
    Whether nothing solid lies between the eyes and point.
    static boolean
    canSee(net.minecraft.world.phys.Vec3 from, net.minecraft.world.phys.Vec3 to)
    Whether nothing solid lies between two points: a ray against blocks' collision shapes, fluids ignored (so grass and other blocks you walk through don't block it).
    static List<net.minecraft.world.phys.Vec3>
    clickPoints(net.minecraft.core.BlockPos pos, net.minecraft.core.Direction face, boolean spread)
    Points where the block at pos can really be clicked on its side facing face: on its outline (a slab's top is half way up, a candle is a sliver in the middle, a stair has two tops), not the cube around it, and only where no other part of the block covers it.
    static double
    How far entities can be hit from the eyes, in blocks (3 in survival, 5 in creative); 0 outside a world.
    static net.minecraft.world.phys.Vec3
    The player's eye position this tick (not interpolated for the frame), where reach is measured from; Vec3.ZERO outside a world.
    static boolean
    faceExposed(net.minecraft.core.BlockPos pos, net.minecraft.core.Direction face)
    Whether face of the block at pos points towards the eyes (the eyes are past its plane).
    static @Nullable net.minecraft.world.phys.BlockHitResult
    hitFor(net.minecraft.core.BlockPos pos, boolean mustSee)
    static @Nullable net.minecraft.world.phys.BlockHitResult
    hitFor(net.minecraft.core.BlockPos pos, boolean mustSee, double range)
    A click on the block at pos for opening, breaking or using it: the nearest point within range on the nearest face of its real outline (a slab's top is half way up), preferring faces you can see.
    static @Nullable net.minecraft.world.phys.BlockHitResult
    rayHit(float yaw, float pitch, net.minecraft.core.BlockPos pos, double range)
    Where looking along yaw/pitch from the eyes first meets the full block space at pos, within range: the point and face a server would see you aiming at.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • blockRange

      public static double blockRange()
      How far blocks can be reached from the eyes, in blocks (4.5 in survival, 5 in creative); 0 outside a world.
    • entityRange

      public static double entityRange()
      How far entities can be hit from the eyes, in blocks (3 in survival, 5 in creative); 0 outside a world.
    • eyes

      public static net.minecraft.world.phys.Vec3 eyes()
      The player's eye position this tick (not interpolated for the frame), where reach is measured from; Vec3.ZERO outside a world.
    • canSee

      public static boolean canSee(net.minecraft.world.phys.Vec3 from, net.minecraft.world.phys.Vec3 to)
      Whether nothing solid lies between two points: a ray against blocks' collision shapes, fluids ignored (so grass and other blocks you walk through don't block it). False outside a world.
    • canSee

      public static boolean canSee(net.minecraft.world.phys.Vec3 point)
      Whether nothing solid lies between the eyes and point.
    • canReach

      public static boolean canReach(net.minecraft.world.phys.Vec3 point)
      Whether point is within block reach of the eyes; false outside a world.
    • canReach

      public static boolean canReach(net.minecraft.world.entity.Entity entity)
      Whether the server would accept hitting entity (its box within entity reach).
    • canReach

      public static boolean canReach(net.minecraft.core.BlockPos pos)
      Whether the server would accept interacting with the block at pos: the nearest point of its block space is within block reach of the eyes. That's how the server and Grim (2b2t) measure, so it's the whole reach a click on the block's near side gets, not a distance to its centre.
    • canReach

      public static boolean canReach(net.minecraft.core.BlockPos pos, double range)
      canReach(BlockPos) with a reach of range.
    • aimPoint

      public static net.minecraft.world.phys.Vec3 aimPoint(net.minecraft.world.entity.Entity entity)
      The point on entity's box closest to the eyes, where a hit or rotation should aim.
    • hitFor

      public static @Nullable net.minecraft.world.phys.BlockHitResult hitFor(net.minecraft.core.BlockPos pos, boolean mustSee)
    • hitFor

      public static @Nullable net.minecraft.world.phys.BlockHitResult hitFor(net.minecraft.core.BlockPos pos, boolean mustSee, double range)
      A click on the block at pos for opening, breaking or using it: the nearest point within range on the nearest face of its real outline (a slab's top is half way up), preferring faces you can see. Each face is tried at its point nearest the eyes (so the whole reach counts), then at its centre in case something hides the edge. With mustSee, only visible faces count (strict anti-cheats check this). Null if no face qualifies, or outside a world.
    • clickPoints

      public static List<net.minecraft.world.phys.Vec3> clickPoints(net.minecraft.core.BlockPos pos, net.minecraft.core.Direction face, boolean spread)
      Points where the block at pos can really be clicked on its side facing face: on its outline (a slab's top is half way up, a candle is a sliver in the middle, a stair has two tops), not the cube around it, and only where no other part of the block covers it. For each part of the outline with a side that way, its centre and its point nearest your eyes (a little in from the edges), and with spread a 3x3 grid over it too, for blocks where where you click matters (a slab's half, a door's hinge). For an empty space (air), the cube's. Empty outside a world, or if every part of that side is covered. Reach isn't checked.
    • canSee

      public static boolean canSee(net.minecraft.world.phys.BlockHitResult hit)
      Whether a look from your eyes at hit's point would land on that face of that block: the face points towards you (you're past the plane it's in, a slab's top half way up) and nothing comes first, neither another block nor another face of this one (from above, a look at the top of a side face enters through the top). Reach isn't checked; false outside a world.
    • faceExposed

      public static boolean faceExposed(net.minecraft.core.BlockPos pos, net.minecraft.core.Direction face)
      Whether face of the block at pos points towards the eyes (the eyes are past its plane). A face pointing away can't be seen however the player turns; servers that check clicks reject them. Measured against the full cube, not the block's real outline.
    • rayHit

      public static @Nullable net.minecraft.world.phys.BlockHitResult rayHit(float yaw, float pitch, net.minecraft.core.BlockPos pos, double range)
      Where looking along yaw/pitch from the eyes first meets the full block space at pos, within range: the point and face a server would see you aiming at. Null if the look misses it (other blocks in the way aren't checked), or outside a world. Pass the server rotation (Myriad.rotations().serverYaw()) to check what an action will look like.