@@ -0,0 +1,2611 @@
+package cat.nyaa.nyaacore.utils;%0A%0Aimport org.bukkit.GameMode;%0Aimport org.bukkit.World;%0Aimport org.bukkit.block.Block;%0Aimport org.bukkit.entity.Player;%0Aimport org.bukkit.util.Vector;%0A%0Aimport java.lang.reflect.Constructor;%0Aimport java.lang.reflect.Method;%0A%0Apublic class RayTraceUtils %7B%0A    public static Block rayTraceBlock(Player player) throws ReflectiveOperationException %7B%0A        float distance = player.getGameMode() == GameMode.CREATIVE ? 5.0F : 4.5F;%0A        Vector start = player.getEyeLocation().toVector();%0A        Vector end = start.clone().add(player.getEyeLocation().getDirection().multiply(distance));%0A        return rayTraceBlock(player.getWorld(), start, end, false, false, true);%0A    %7D%0A%0A    public static Block rayTraceBlock(World world, Vector start, Vector end, boolean stopOnLiquid, boolean ignoreBlockWithoutBoundingBox, boolean returnLastUncollidableBlock) throws ReflectiveOperationException %7B%0A        Class craftWorld = ReflectionUtils.getOBCClass(%22CraftWorld%22);%0A        Method getHandleMethod = ReflectionUtils.getMethod(craftWorld, %22getHandle%22);%0A        Class%3C?%3E vec3D = ReflectionUtils.getNMSClass(%22Vec3D%22);%0A        Class%3C?%3E nmsWorld = ReflectionUtils.getNMSClass(%22World%22);%0A        Class%3C?%3E mopClass = ReflectionUtils.getNMSClass(%22MovingObjectPosition%22);%0A        Method mop_getBlockPosMethod = ReflectionUtils.getMethod(mopClass, %22a%22);%0A        Class%3C?%3E baseBlockPosition = ReflectionUtils.getNMSClass(%22BaseBlockPosition%22);%0A        Method bbp_getX = ReflectionUtils.getMethod(baseBlockPosition, %22getX%22);%0A        Method bbp_getY = ReflectionUtils.getMethod(baseBlockPosition, %22getY%22);%0A        Method bbp_getZ = ReflectionUtils.getMethod(baseBlockPosition, %22getZ%22);%0A        Object worldServer = getHandleMethod.invoke(world);%0A        Method rayTraceMethod = ReflectionUtils.getMethod(nmsWorld, %22rayTrace%22, vec3D, vec3D, boolean.class, boolean.class, boolean.class);%0A        Object mop = rayTraceMethod.invoke(worldServer, toVec3D(start), toVec3D(end),%0A                stopOnLiquid, ignoreBlockWithoutBoundingBox, returnLastUncollidableBlock);%0A        if (mop != null) %7B%0A            Object blockPos = mop_getBlockPosMethod.invoke(mop);%0A            return world.getBlockAt((int) bbp_getX.invoke(blockPos), (int) bbp_getY.invoke(blockPos), (int) bbp_getZ.invoke(blockPos));%0A        %7D%0A        return null;%0A    %7D%0A%0A    public static Object toVec3D(Vector v) throws ReflectiveOperationException %7B%0A        Constructor%3C?%3E vec3d = ReflectionUtils.getNMSClass(%22Vec3D%22).getConstructor(double.class, double.class, double.class);%0A        return vec3d.newInstance(v.getX(), v.getY(), v.getZ());%0A    %7D%0A%7D%0A

add RayTraceUtils