#[Resolved] why isnt this working?

1 messages · Page 1 of 1 (latest)

vapid mango
#

You mean player.dimension.id?

#

Also specify the y and z there's a change it will throw an error.

#
function createBarrierAt(player, location) {
    const barrierBlock = player.dimension.getBlock({ x: location.x, y: location.y, z: location.z });

    if (!barrierBlock) {
        console.warn('Could not find a block at specified location.');
        return;
    }

    const barrierPerm = BlockPermutation.resolve('minecraft:barrier');
    barrierBlock.setPermutation(barrierPerm);
}

system.afterEvents.scriptEventReceive.subscribe((d) => {
    const { id, message } = d;
    if (id != "b:place") return;

    if (message == "barrier") {
        system.run(() => {
            for (const player of world.getAllPlayers()) {
                const barrierLocation = {
                    dimension: player.dimension.id,
                    x: Math.floor(player.location.x - 1),
                    y: Math.floor(player.location.y),
                    z: Math.floor(player.location.z)
                };
                createBarrierAt(player, barrierLocation);
            }
        });
    }
});
#

also on the functions one the location.dimension it doesn't make sense tbh

#

maybe you mean player.dimension.getBlock({})

void axleBOT
#
Debug Result

JavaScript/TypeScript code blocks not detected in [message](#1242268742461820960 message).
You can either send the script in code block highlighted in JS format:

​`​`​`js
world.sendMessage("Hello World");
​`​`​`

Or Send an attachment end in .js to debug the file.

dawn wind
#

ignoring the manifest thing thats what a runtime error is

void axleBOT
#
Debug Result

JavaScript/TypeScript code blocks not detected in [message](#1242268742461820960 message).
You can either send the script in code block highlighted in JS format:

​`​`​`js
world.sendMessage("Hello World");
​`​`​`

Or Send an attachment end in .js to debug the file.

dawn wind
#

it doesnt error until you actually run the code that causes the error

void axleBOT
#
No Errors

No errors in [code](#1242268742461820960 message)

vapid mango
#

What are you trying to do specifically?

dawn wind
#

looking at this code it seems like its fine. If the other script is what errors thats probably where the issue is

dawn wind
vapid mango
#

Also why you're using system.run?

#

It's already an afterEvents

#

Just remove it

#

vanilla data class doesn't exist afaik it's a bundle

#

Just put [Resolved]