#BlockEvents.rightClicked Question

5 messages · Page 1 of 1 (latest)

summer zenithBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

steady goblet
#

BlockEvents.rightClicked Question

#
    BlockEvents.rightClicked(event => {
        function placeStructure(dimension, structure, posX, posY, posZ, rotation, mirror) {
            let rotations = [180, 'clockwise_90', 'counterclockwise_90', 'none']
            let mirrors = ['front_back', 'left_light', 'none']
            let rotation_ = rotations[rotation]
            let mirror_ = mirrors[mirror]

            event.server.runCommandSilent(`execute in ${dimension} positioned ${posX} ${posY} ${posZ} run place template ${structure} ~ ~ ~ ${rotation_} ${mirror_}`);
        }

        const structures = {
            'minecraft:igloo/bottom': {
                'EAST': '3 2',
                'WEST':  '3 1',
                'NORTH': '1 2',
                'SOUTH': '1 1'
            }
        }

        let heldItem = event.player.getmainHandItem().getId()
        let block = event.getBlock()
        let blockPos = block.getPos()

        let world = 'minecraft:overworld'
        if (heldItem == 'minecraft:diamond' && block.id == 'minecraft:diamond_block')
            for (let [id, directions]in structures ) {
                 let structure_id = id
                for (let [facing, value]in directions) {
                    let Srotation = value.split(' ')[0]
                    let Smirror = value.split(' ')[1]
                    if (event.player.facing = facing) {
                       placeStructure(world, structure_id, blockPos.x, blockPos.y, blockPos.z, Srotation, Smirror)
                       event.block.set('minecraft:air')
                    }
                }
            }
        })```
#

A script that places a structure when right-clicking a block.
But it didn't work correctly.