Class Reach
java.lang.Object
dev.myriadclient.api.player.Reach
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 TypeMethodDescriptionstatic net.minecraft.world.phys.Vec3aimPoint(net.minecraft.world.entity.Entity entity) The point onentity's box closest to the eyes, where a hit or rotation should aim.static doubleHow far blocks can be reached from the eyes, in blocks (4.5 in survival, 5 in creative); 0 outside a world.static booleancanReach(net.minecraft.core.BlockPos pos) Whether the server would accept interacting with the block atpos: the nearest point of its block space is within block reach of the eyes.static booleancanReach(net.minecraft.core.BlockPos pos, double range) canReach(BlockPos)with a reach ofrange.static booleancanReach(net.minecraft.world.entity.Entity entity) Whether the server would accept hittingentity(its box within entity reach).static booleancanReach(net.minecraft.world.phys.Vec3 point) Whetherpointis within block reach of the eyes; false outside a world.static booleancanSee(net.minecraft.world.phys.BlockHitResult hit) Whether a look from your eyes athit'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 booleancanSee(net.minecraft.world.phys.Vec3 point) Whether nothing solid lies between the eyes andpoint.static booleancanSee(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 atposcan really be clicked on its side facingface: 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 doubleHow 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.Vec3eyes()The player's eye position this tick (not interpolated for the frame), where reach is measured from;Vec3.ZEROoutside a world.static booleanfaceExposed(net.minecraft.core.BlockPos pos, net.minecraft.core.Direction face) Whetherfaceof the block atpospoints towards the eyes (the eyes are past its plane).static @Nullable net.minecraft.world.phys.BlockHitResulthitFor(net.minecraft.core.BlockPos pos, boolean mustSee) hitFor(BlockPos, boolean, double)within block reach.static @Nullable net.minecraft.world.phys.BlockHitResulthitFor(net.minecraft.core.BlockPos pos, boolean mustSee, double range) A click on the block atposfor opening, breaking or using it: the nearest point withinrangeon 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.BlockHitResultrayHit(float yaw, float pitch, net.minecraft.core.BlockPos pos, double range) Where looking alongyaw/pitchfrom the eyes first meets the full block space atpos, withinrange: the point and face a server would see you aiming at.
-
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.ZEROoutside 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 andpoint. -
canReach
public static boolean canReach(net.minecraft.world.phys.Vec3 point) Whetherpointis 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 hittingentity(its box within entity reach). -
canReach
public static boolean canReach(net.minecraft.core.BlockPos pos) Whether the server would accept interacting with the block atpos: 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 ofrange. -
aimPoint
public static net.minecraft.world.phys.Vec3 aimPoint(net.minecraft.world.entity.Entity entity) The point onentity'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(BlockPos, boolean, double)within block reach. -
hitFor
public static @Nullable net.minecraft.world.phys.BlockHitResult hitFor(net.minecraft.core.BlockPos pos, boolean mustSee, double range) A click on the block atposfor opening, breaking or using it: the nearest point withinrangeon 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. WithmustSee, 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 atposcan really be clicked on its side facingface: 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 withspreada 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 athit'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) Whetherfaceof the block atpospoints 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 alongyaw/pitchfrom the eyes first meets the full block space atpos, withinrange: 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.
-