AlmostReliable / ponderjs

A Minecraft mod for packdevs to create custom Ponder scenes with KubeJS.
https://www.curseforge.com/minecraft/mc-mods/ponder
MIT License
25 stars 5 forks source link

Create ParticleInstructions #2

Closed LLytho closed 2 years ago

LLytho commented 2 years ago

Example code:

onEvent("ponder.tag", (event) => {
    event.createTag("particle_test", "minecraft:blaze_powder", "Test name", "Some test description!", [
        "minecraft:blaze_powder",
    ]);
});

onEvent("ponder.registry", (event) => {
    /**
     * Prints all particle names in the client.txt which can be used for `scene.particles.simple()`.
     */
    event.printParticleNames();

    event
        .create("particle_testing", ["minecraft:blaze_powder"])
        .tag("kubejs:particle_test")
        .scene("particles", "How to particle", (scene, util) => {
            scene.showStructure();
            scene.idle(10);

            const pos = [4, 1.5, 4];
            const start = [0, 1, 0];
            const end = [2, 2, 3];
            const tickLength = 20;
            const idleLength = tickLength * 3;

            /**
             * Using `scene.particles.` returns an object to set additional options
             *
             * .density(number) -> Sets the density of the particles.
             * .gravity(number) -> Sets the gravity of the particles.
             * .hasPhysics(true or false) -> Sets if the particles have physics.
             * .stoppedByCollision(true or false) -> Sets if the particles stop by collision.
             * .roll(number) -> Do a barrell roll!
             * .scale(number) -> Scale the particles between 0.01 and 4.
             * .lifetime(number) -> Set the lifetime of the particles.
             *
             * .motion(vec3) -> Sets the motion of the particles.
             * .speed(vec3) -> Sets the speed of the particles. Affects the motion if given.
             * .area(vec3) -> Sets the area of the particles.
             * .delta(vec3) -> Sets the delta of the particles. Same as the particle command.
             */
            scene.addKeyframe();
            scene.particles.simple(tickLength, "glow", pos);
            scene.particles.simple(tickLength, "glow", start).density(10).area(end);
            scene.idle(idleLength);

            scene.addKeyframe();
            scene.particles.simple(tickLength, "small_flame", pos);
            scene.particles.simple(tickLength, "small_flame", start).density(10).motion([0, 0, -0.1]).area(end);
            scene.idle(idleLength);

            scene.addKeyframe();
            scene.particles.item(tickLength, "minecraft:diamond_block", pos).motion([-0.09, 0.3, 0]).density(8);
            scene.particles.item(tickLength, "minecraft:diamond_block", start).area(end);
            scene.idle(idleLength);

            scene.addKeyframe();
            scene.particles.block(tickLength, "minecraft:diamond_block", pos);
            scene.particles.block(tickLength, "minecraft:diamond_block", start).density(4).area(end);
            scene.idle(idleLength);

            scene.addKeyframe();
            scene.particles.dust(tickLength, "#00FFF0", start).density(5).motion([0, 0, -0.1]).area(end).roll(10);
            scene.idle(idleLength);

            scene.addKeyframe();
            scene.particles
                .dust(tickLength, "#FF0000", "#0000FF", start)
                .density(2)
                .scale(2.1)
                .motion([0, 0, -0.1])
                .area(end)
                .roll(3);
            scene.idle(idleLength);
        });
});