Skip to content

Instantly share code, notes, and snippets.

View JXSnack's full-sized avatar

JXSnack

View GitHub Profile
@JXSnack
JXSnack / RaycastUtil.java
Created December 23, 2024 20:03
Modern approach to sending a raycast from the mouse cursor into the 3d world. Minecraft Fabric, tested for 1.20.1
import net.minecraft.client.MinecraftClient;
import net.minecraft.util.hit.HitResult;
import net.minecraft.util.math.*;
import net.minecraft.world.RaycastContext;
import org.joml.Matrix4f;
import org.joml.Vector3f;
import org.joml.Vector4f;
public class RaycastUtil {
// Don't worry about screenX and screenY. No scary names.