### Run Screen Effects Builder (Deno CLI) Source: https://github.com/trioplane/screeneffects/blob/main/README.md Command to execute the Deno script for building screen effects. This script converts sprite sheets into animation frames. Ensure you are in the 'screen_effects' folder and have Deno and ffmpeg installed. ```bash deno run --allow-all .\buildScreenEffects.js ``` ```bash deno run --allow-all .\buildScreenEffects.js filename.png ``` -------------------------------- ### Configure Screen Effects Builder (Deno) Source: https://github.com/trioplane/screeneffects/blob/main/README.md Configuration settings for the Deno script used to build screen effects. This script processes sprite sheets into animation frames for the datapack. It requires Deno and ffmpeg to be installed. ```javascript // -------------CONFIGS--------------- // Replace with the namespace you use! const NAMESPACE = "example"; // This logs what the builder is currently doing. // If compiling is taking a while, disabling this will improve compilation time. const debugMode = false; // If you want the font JSON files to be formatted, make this boolean true. const prettyPrintFontFiles = false; // If you want to see the ffmpeg logs, make this boolean true. // If compiling is taking a while, disabling this will improve compilation time. const showFFMPEGLogs = false; // ----------------------------------- ``` -------------------------------- ### Complete Datapack Integration Example (mcfunction) Source: https://context7.com/trioplane/screeneffects/llms.txt Demonstrates the full workflow for integrating screen effects into a Minecraft datapack. This includes defining effects in the load function, registering them using the provided API, and triggering them with specific commands. ```mcfunction # In your load function (e.g., mynamespace:load) # Register with minecraft:load function tag # Define all your screen effects data modify storage mynamespace:scrfx_data screen_effects set value [ \ { \ name: "mynamespace:level_complete", \ tps: 1, \ frame_count: 60, \ path: "mynamespace:scrfx/levelcomplete", \ callbacks: { \ "30": "playsound minecraft:ui.toast.challenge_complete master @s ~ ~ ~ 1 1", \ "59": "function mynamespace:after_level_complete" \ } \ }, \ { \ name: "mynamespace:damage_vignette", \ tps: 2, \ frame_count: 10, \ path: "mynamespace:scrfx/damagevignette" \ } \ ] # Register the screen effects group function scrfx:api/register_screen_effect/register_group {storage: "mynamespace:scrfx_data", path: "screen_effects"} # --- # Trigger function example (mynamespace:show_level_complete) data modify storage scrfx:in id set value "mynamespace:level_complete" execute as @s run function scrfx:play # Trigger on damage example (called from advancement reward or custom damage detection) data modify storage scrfx:in id set value "mynamespace:damage_vignette" execute as @s run function scrfx:play ``` -------------------------------- ### Register Screen Effects in Datapack (Minecraft Function) Source: https://github.com/trioplane/screeneffects/blob/main/README.md Example of how to register custom screen effects within a Minecraft datapack. This involves defining the effect's name, duration (tps), frame count, and asset path in a storage object. ```mcfunction # To add your own screen effects to the global registry, # simply copy what is shown here. data modify storage example:scrfx_data screen_effects set value [ \ { \ name: "examples:toast", \ tps: 1, \ frame_count: 31, \ path: "example:scrfx/exampletoast" \ }, \ { \ name: "examples:transition", \ tps: 1, \ frame_count: 69, \ path: "example:scrfx/exampletransition", \ callbacks: { \ "26": "say This frame covers the whole screen" \ } \ }, \ ] function scrfx:api/register_screen_effect/register_group {storage: "example:scrfx_data", path: "screen_effects"} ``` -------------------------------- ### Build Screen Effects from Spritesheets with JavaScript Source: https://context7.com/trioplane/screeneffects/llms.txt The buildScreenEffects.js utility converts vertical PNG spritesheets into individual animation frames and corresponding font JSON files. It utilizes ffmpeg for cropping and generates the necessary Minecraft resource pack structure. Configuration options include namespace, debug mode, pretty printing, and ffmpeg log visibility. ```javascript // Configure the builder in buildScreenEffects.js const NAMESPACE = "mynamespace"; // Your resource pack namespace const debugMode = false; // Enable verbose logging const prettyPrintFontFiles = false; // Format JSON output const showFFMPEGLogs = false; // Show ffmpeg output // Run from terminal inside the screen_effects folder // Build all spritesheets: // deno run --allow-all ./buildScreenEffects.js // Build a single spritesheet: // deno run --allow-all ./buildScreenEffects.js myanimation.png // Output structure after building: // ../assets/{NAMESPACE}/font/scrfx/myanimation0.json // ../assets/{NAMESPACE}/font/scrfx/myanimation1.json // ../assets/{NAMESPACE}/textures/font/scrfx/myanimation0.png // ../assets/{NAMESPACE}/textures/font/scrfx/myanimation1.png ``` -------------------------------- ### Playing Screen Effects (MCFunction) Source: https://github.com/trioplane/screeneffects/blob/main/README.md Demonstrates the MCFunction commands required to play a screen effect. It involves setting the desired screen effect identifier in the 'scrfx:in id' storage and then executing the 'scrfx:play' function. ```mcfunction data modify storage scrfx:in id set value "ns:identifier" execute as Trplnr run function scrfx:play ``` -------------------------------- ### Register Multiple Screen Effects with MCFunction Source: https://context7.com/trioplane/screeneffects/llms.txt Register multiple screen effects at once by storing their definitions in a list within your datapack's storage and then calling the `scrfx:api/register_screen_effect/register_group` function. This is the recommended method for registering animations, allowing for efficient batch registration. ```mcfunction # Store screen effect definitions in your namespace's storage data modify storage mynamespace:scrfx_data screen_effects set value [ \ { \ name: "mynamespace:toast_notification", \ tps: 1, \ frame_count: 31, \ path: "mynamespace:scrfx/toastanimation" \ }, \ { \ name: "mynamespace:screen_transition", \ tps: 1, \ frame_count: 69, \ path: "mynamespace:scrfx/transitionanimation", \ callbacks: { \ "26": "say Screen is fully covered", \ "50": "function mynamespace:on_transition_complete" \ } \ }, \ { \ name: "mynamespace:achievement_popup", \ tps: 2, \ frame_count: 46, \ path: "mynamespace:scrfx/achievementanimation" \ } \ ] # Register all screen effects from the storage path function scrfx:api/register_screen_effect/register_group {storage: "mynamespace:scrfx_data", path: "screen_effects"} ``` -------------------------------- ### Play Screen Effects on Players with MCFunction Source: https://context7.com/trioplane/screeneffects/llms.txt Play a registered screen effect on players by setting the desired effect ID in the `scrfx:in` storage and then executing the `scrfx:play` function as the target player(s). This allows for targeted or broad application of screen animations. ```mcfunction # Play screen effect on a specific player data modify storage scrfx:in id set value "mynamespace:toast_notification" execute as @p run function scrfx:play # Play screen effect on all players data modify storage scrfx:in id set value "mynamespace:screen_transition" execute as @a run function scrfx:play # Play screen effect on players with a specific tag data modify storage scrfx:in id set value "mynamespace:achievement_popup" execute as @a[tag=show_achievement] run function scrfx:play # Play screen effect on the nearest player within 10 blocks data modify storage scrfx:in id set value "mynamespace:warning_flash" execute as @p[distance=..10] run function scrfx:play ``` -------------------------------- ### Screen Effect Definition Schema (TypeScript) Source: https://context7.com/trioplane/screeneffects/llms.txt Defines the structure for a screen effect, including its name, playback speed (tps), frame count, sprite path, and optional frame-specific callbacks. The 'name' and 'path' use a resource location format, 'tps' and 'frame_count' are integers, and 'callbacks' map frame numbers to Minecraft commands. ```typescript // Screen Effect Definition Schema { /** * Unique identifier for the screen effect, preferably namespaced * Format: "namespace:effect_name" */ name: , /** * Ticks per frame - controls playback speed * 1 = fastest (20 fps), 2 = 10 fps, 20 = 1 fps * Must be greater than 0 */ tps: , /** * Total number of frames in the animation * Must match the actual frame count from the spritesheet */ frame_count: , /** * Font resource location path without the frame number suffix * Points to: assets/{namespace}/font/scrfx/{path}{frame_number}.json */ path: , /** * Optional: Commands to execute at specific frame numbers * Keys are frame numbers as strings, values are mcfunction commands */ callbacks?: { "": "", "": "" } } // Example with all properties: // { // name: "mypack:explosion_effect", // tps: 1, // frame_count: 24, // path: "mypack:scrfx/explosion", // callbacks: { // "0": "playsound minecraft:entity.generic.explode master @s", // "12": "particle minecraft:explosion ~ ~1 ~ 1 1 1 0.1 10" // } // } ``` -------------------------------- ### Register a Single Screen Effect Definition with MCFunction Source: https://context7.com/trioplane/screeneffects/llms.txt Register individual screen effects using the `scrfx:api/register_screen_effect/register_definition` function when you need to add a single animation without batch registration. This involves storing the definition in storage and then calling the registration function. ```mcfunction # Store a single screen effect definition data modify storage mynamespace:scrfx_data single_effect set value { \ name: "mynamespace:warning_flash", \ tps: 1, \ frame_count: 15, \ path: "mynamespace:scrfx/warningflash" \ } # Register the single definition function scrfx:api/register_screen_effect/register_definition {storage: "mynamespace:scrfx_data", path: "single_effect"} ``` -------------------------------- ### Screen Effect Schema Definition (TypeScript) Source: https://github.com/trioplane/screeneffects/blob/main/README.md Defines the structure for a screen effect group, which is a list of individual screen effect definitions. Each definition includes properties for the effect's name, frame timing (tps), frame count, font path, and optional frame-specific callbacks. ```TypeScript [ // A screen effect group is just a list of screen effect definitions. { /** * The name of the screen effect, * preferrably namespaced. */ name: , /** * How fast each frame * shows up measured in ticks. * * Just like fps but well in ticks. * * Must be above zero. */ tps: , /** * How many frames are in the animation. */ frame_count: , /** * The font resource location * of the animation with the * number at the end removed. */ path: , /** * Defines what commands run in a certain frame. * Optional. */ callbacks?: { "": "", ... } } ] ``` -------------------------------- ### Purge Running Screen Effects (mcfunction) Source: https://context7.com/trioplane/screeneffects/llms.txt Clears all currently active screen effects for all players. This function is essential for cleanup operations, such as during datapack reloads or when effects need to be forcefully terminated. ```mcfunction # Stop all running screen effects on all players function scrfx:purge_running_screen_effects # Example: Clean up before unloading your datapack function scrfx:purge_running_screen_effects say All screen effects have been stopped ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.