// Give XP for chopping Dynamic Trees branches, scaled by radius (1–10 XP)
BlockEvents.broken(event => {

    if (!event.server || !event.player) return;

    const id = event.block.id;

    // Only target Dynamic Trees branches (ANY namespace)
    if (!id.endsWith("_branch")) return;

    const playerName = event.player.username;
    const category = "skill_tree_for_pufferfishs_skills:chopping_wood";

    // Read DT radius from blockstate
    let radius = event.block.properties["radius"];

    if (!radius) radius = 1;

    // XP = radius clamped to a maximum of 10, minimum of 1
    const xp = Math.min(10, Math.max(1, radius));

    // Award XP silently
    event.server.runCommandSilent(
        `puffish_skills experience add ${playerName} ${category} ${xp}`
    );
});
