package net.mattias.cobblesnapshot.util;

import net.mattias.cobblesnapshot.CobbleSnapshot;
import net.mattias.cobblesnapshot.event.ScreenshotHandler;
import net.mattias.cobblesnapshot.item.ModItems;
import net.minecraft.client.KeyMapping;
import net.minecraft.client.Minecraft;
import net.minecraft.world.item.ItemStack;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.Mod;
import net.neoforged.neoforge.client.event.InputEvent;
import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent;
import org.lwjgl.glfw.GLFW;

@Mod.EventBusSubscriber(modid = CobbleSnapshot.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public class ScreenshotKeybind {
    public static final KeyMapping TAKE_SNAPSHOT = new KeyMapping(
            "key.cobblesnapshot.take_snapshot",
            GLFW.GLFW_KEY_P,
            "key.categories.misc"
    );

    @SubscribeEvent
    public static void registerKeybindings(RegisterKeyMappingsEvent event) {
        event.register(TAKE_SNAPSHOT);
    }

    @Mod.EventBusSubscriber(modid = CobbleSnapshot.MOD_ID, value = Dist.CLIENT)
    public static class ClientForgeEvents {
        @SubscribeEvent
        public static void onKeyInput(InputEvent.Key event) {
            Minecraft mc = Minecraft.getInstance();

            // Check if the snapshot key is pressed and player is in-game
            if (TAKE_SNAPSHOT.isDown() && mc.player != null) {
                // Create a new Image Film item
                ItemStack imageFilm = new ItemStack(ModItems.IMAGE_FILM.get());

                // Capture screenshot
                ScreenshotHandler.captureScreenshot(imageFilm);

                // Optional: Add the image film to player's inventory
                if (!mc.player.addItem(imageFilm)) {
                    mc.player.drop(imageFilm, false);
                }
            }
        }
    }
}
Cannot resolve symbol 'EventBusSubscriber' Cannot resolve symbol 'EventBusSubscriber' Cannot resolve symbol 'EventBusSubscriber'

package net.mattias.cobblesnapshot.util;

import net.mattias.cobblesnapshot.CobbleSnapshot;
import net.minecraft.client.Minecraft;
import net.minecraft.client.Screenshot;
import net.minecraft.network.chat.Component;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class ScreenshotUtil {
    private static final DateTimeFormatter FILE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH-mm-ss");

    public static String captureScreenshot() {
        Minecraft mc = Minecraft.getInstance();

        // Create mod screenshots directory if it doesn't exist
        Path screenshotDir = mc.gameDirectory.toPath().resolve("screenshots").resolve("cobblesnapshot");
        try {
            Files.createDirectories(screenshotDir);
        } catch (IOException e) {
            CobbleSnapshot.LOGGER.error("Could not create screenshot directory", e);
            return null;
        }

        // Generate unique filename
        String timestamp = LocalDateTime.now().format(FILE_FORMATTER);
        String filename = "cobblesnapshot_" + timestamp + ".png";
        File screenshotFile = screenshotDir.resolve(filename).toFile();

        // Capture screenshot
        try {
            Screenshot.grab(screenshotFile,
                    mc.getWindow().getWidth(),
                    mc.getWindow().getHeight(),
                    mc.getMainRenderTarget(),
                    null);

            // Optional: Notify player
            mc.player.sendSystemMessage(Component.literal("📸 Screenshot saved: " + filename));

            return screenshotFile.getAbsolutePath();
        } catch (Exception e) {
            CobbleSnapshot.LOGGER.error("Failed to capture screenshot", e);
            mc.player.sendSystemMessage(Component.literal("❌ Failed to capture screenshot"));
            return null;
        }
    }
} Cannot resolve method 'grab(File, int, int, RenderTarget, null)'

NeoForge 1.21