#STRUCTURE GENERATOR

1 messages · Page 1 of 1 (latest)

twin valley
#

Hello!
Excuse me, can someone help me? I want to generate a relatively large structure but I can't because I think the limit is 40x38 or something like that, so I made a block that will generate throughout the world, and I connected it to a script so that when the player is near it it will generate, but I don't know what I have wrong, could someone help me please? D:

import { world, system } from '@minecraft/server';

/** @type {import("@minecraft/server").BlockCustomComponent} */
const generateStructureComponent = {
onUpdate(event) {
console.log('Block update detected'); // Línea de depuración
const block = event.block;
const dimension = world.getDimension("overworld");

    // Verificar si el bloque es rg:delta
    if (block.id === "rg:delta") {
        const x = block.location.x;
        const y = block.location.y;
        const z = block.location.z;

        // Ejecutar el comando para cargar la estructura
        const command = structure load delta_estructura ${x - 18} ${y - 5} ${z - 18};
        console.log(Executing command: ${command}); // Línea de depuración
        dimension.runCommand(command);

        // Desactivar la actualización para que no se ejecute repetidamente
        block.removeCustomComponent("rg:generate_structure");
    }
}

};

// Registrar el componente personalizado
world.beforeEvents.worldInitialize.subscribe(({ blockComponentRegistry }) => {
console.log('Registering custom component for structure generation'); // Línea de depuración
blockComponentRegistry.registerCustomComponent(
"rg:generate_structure",
generateStructureComponent
);
});

light umbra
twin valley
twin valley
light umbra
#

any errors?

twin valley
twin valley
# light umbra any errors?

Look, I changed it and now I have it like this: import { world, system } from "@minecraft/server";

world.beforeEvents.worldInitialize.subscribe((data) => {
const { itemComponentRegistry, blockComponentRegistry } = data;

blockComponentRegistry.registerCustomComponent("rg:generate_structure", {
    onTick: (data) => {
        const block = data.block;
        const { x, y, z } = block.location;
        const dimension = data.dimension;

        system.run(() => {
            const command = `execute as @a run structure load delta ~ ~ ~`;
            dimension.runCommand(command);
        });
    }
});

});

#

But it doesn't work :c

light umbra
#

does your block.json have rg:generate_structure in it

twin valley
# light umbra any errors?

I DID IT NOW!! 😄
It looks like this: import { world, system } from "@minecraft/server";

world.beforeEvents.worldInitialize.subscribe((data) => {
const { itemComponentRegistry, blockComponentRegistry } = data;

blockComponentRegistry.registerCustomComponent("rg:generate_structure", {
    onTick: (data) => {
        const block = data.block;
        const { x, y, z } = block.location;
        const dimension = data.dimension;

        system.run(() => {
            // Ejecutar el comando para cargar la estructura
            const command = `structure load delta ${x - 18} ${y - 5} ${z - 18}`;
            console.log(`Executing command: ${command}`); // Línea de depuración
            dimension.runCommand(command);
        });
    }
});

});

twin valley