npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

cosmic-reach-dag

v1.5.1

Published

A modern dynamic asset generator for Cosmic Reach

Readme

Cosmic Reach Dynamic Asset Generator

The second generation of the "Cosmic Reach Modding API" for modern Cosmic Reach

Cosmic Reach is a game developed by FinalForEach. I do not own any rights to assets in the game.

Installation

If you want to quickly set up a new mod, use this template (cosmic-reach-dag-mod-template on GitHub)

Demo mod

Adds a stone breaker which runs on an interaction (only breaks stone)

import { Texture, Mod, Writer, Directions, RunTriggerAction, BlockEventPredicate } from "cosmic-reach-dag";

main();

async function main() {
    // Create the mod
    const mod = new Mod("test");

    // Our custom stone breaker block
    await createStoneBreaker(mod);

    // Compiles and writes the mod to a directory
    // (creates ./mod-demo/test/ for the mod content)
    const writer = new Writer(mod);
    writer.write("./mod-demo/");
}

async function createStoneBreaker(mod) {
    // Create and register our block with the mod
    const block = mod.createBlock("stone_breaker");

    /*
     # Add a state to the block
     The state ID can be a string, map, or object.
     In this case, we just want to make a single state.

     When a block has only a single state, calling it
     "default" is Cosmic Reach's convention.
    */
    const state = block.createState("default");

    /*
     # Create the state's model
     A state requires a block model. Without it, the game
     can't load the block.
     
     Block states do not come with a block model by
     default, so we would have to write our own.

     Thankfully, however, Cosmic Reach comes with a default
     block model which we can reference in a parent.
    */
    const model = state.createBlockModel();
    model.setParent("base:models/blocks/cube.json"); // new Identifier("base", "cube") also works here

    /*
     # Load the textures we want to use
     Subfolders are automatically created when the texture
     ID has a slash in the name.

     The second argument is the location of the file which
     will be parsed and eventually copied to the output
     directory.

     When used on a block, it will automatically put it
     in the /<mod>/textures/blocks/ directory.
     Vice versa for items.
    */
    const side = await Texture.loadFromFile("stone_breaker/side", "assets/stone-breaker-side.png");
    const end = await Texture.loadFromFile("stone_breaker/end", "assets/stone-breaker-end.png");

    /*
     # Set the texture overrides
     Block models have "texture slots" that tell the game
     which face should use which texture.

     When setting a parent, it's possible (and often
     required) to override its texture slots to get the
     look we want.
    */
    model.addTextureOverride(side, "side");
    model.addTextureOverride(end, "top");
    model.addTextureOverride(end, "bottom");

    /*
     # Creating the block events
     The name "trigger sheet" (an alias for block events)
     comes from the first version of this library.

     Triggers can be added here with sheet.addTrigger().

     Similarly to models, the game comes with default block
     events. If not specified, the block can't be placed.

     For sheets that override the default events (onBreak,
     and onPlace), use the library's boilerplate method
     `addDefaultEvents(triggerSheet)` to add back the
     defaults.
    */
    const triggerSheet = state.createTriggerSheet();
    triggerSheet.setParent("base:block_events_default");

    // Directions.cardinals is a list of NESW, up, and down `Direction`s
    // This will add a trigger for all six primary directions
    for(const direction of Directions.cardinals) {
        // Create the action (base:run_trigger)
        const action = new RunTriggerAction({
            xOff: direction.x,
            yOff: direction.y,
            zOff: direction.z,
            triggerId: "onBreak"
        });

        // Add an `if` block (checks if a block in the current direction is ore_replaceable)
        action.if(
            new BlockEventPredicate({
                block_at: {
                    xOff: direction.x,
                    yOff: direction.y,
                    zOff: direction.z,
                    has_tag: "ore_replaceable"
                }
            })
        );

        // When the block is interacted with, run the action
        triggerSheet.addTrigger("onInteract", action);
    }
}