#HELP

1 messages · Page 1 of 1 (latest)

hushed gulch
#

Well, I would like to know how to make the protection script that is in an addon but this is all I get. I don't know how to set it to only protect specific coordinates. Someone would please help me, and maybe if it has

import { world } from "mojang-minecraft"

world.events.blockBreak.subscribe(event => {
if (event.player.hasTag("creative") == false) {
const permutation = event.brokenBlockPermutation
const block = event.block
//Blacklist
var b = ["minecraft:stone"]
if (b.includes(permutation.type.id)) {
} else {
block.setPermutation(permutation)
}
}
})

#

HELP

ionic pond
#

Outdated code

hushed gulch
ionic pond
# hushed gulch So how would it be, could you help me please?
import { world } from "@minecraft/server";

// ---------------------------
// Configuration Section
// ---------------------------
const protectedBlockConfig = {
    x: 15, // Set the X-coordinate of the protected block
    y: 10, // Set the Y-coordinate of the protected block
    z: 20  // Set the Z-coordinate of the protected block
};

// ---------------------------
// Main Script
// ---------------------------
world.beforeEvents.playerBreakBlock.subscribe(event => {
    const player = event.player;
    const blockLocation = event.block.location;

    // Check if the block being broken is at the protected coordinates
    if (blockLocation.x === protectedBlockConfig.x &&
        blockLocation.y === protectedBlockConfig.y &&
        blockLocation.z === protectedBlockConfig.z) {

        // Prevent the block from being broken
        event.cancel = true;
        // Notify the player
        player.sendMessage("This block is protected.");
    }
});```
hushed gulch
ionic pond
hushed gulch
#

I just can't find which blocks it will detect in the specific area

ionic pond
#

Are you trying to protect one single block or an area of blocks

#

@hushed gulch

hushed gulch
#

An area of ​​all blocks