#javascript coding help

7 messages · Page 1 of 1 (latest)

gloomy coyote
#

anyone know how to fix this
[Scripting][error]-TypeError: not a function at _destroyConnectedBlocks (main.js:73) at veinmine (main.js:60) at <anonymous> (main.js:89)

class VeinMiner {
    constructor(dimension, blockId) {
        this.blocksBroken = -1
        this.dimension = dimension
        this.blockId = blockId
        this.queue = []
    }

    veinmine(player, blockLocation) {
        this._destroyConnectedBlocks(blockLocation)

        for (const bl of this.queue) {
            // make sure that the block has not been destroyed while this function was waiting in the queue and it hasnt reached the block limit
            if (this.dimension.getBlock(bl).id == this.blockId && this.blocksBroken < 150) {
                this._destroyConnectedBlocks(bl)
            }
        }

        player.addEffect(MinecraftEffectTypes.hunger, 20, Math.min(Math.ceil(this.blocksBroken / 3.5), 255))
    }

    _destroyConnectedBlocks(blockLocation) {
        this.dimension.runCommand(`setblock ${blockLocation.x} ${blockLocation.y} ${blockLocation.z} air 0 destroy`)
        this.blocksBroken++

        let blockLocations = new BlockLocation(blockLocation.x + 1, blockLocation.y + 1, blockLocation.z + 1).blocksBetween(new BlockLocation(blockLocation.x - 1, blockLocation.y - 1, blockLocation.z - 1))

        for (const bl of blockLocations) {
            let block = this.dimension.getBlock(bl)
            if (block.id == this.blockId) {
                this.queue.push(bl)
            }
        }
    }
}

world.events.blockBreak.subscribe(e => {
    if (e.player.isSneaking && !e.player.hasTag('veinminer:veinminerDisabled')) {
        new VeinMiner(e.block.dimension, e.brokenBlockPermutation.type.id).veinmine(e.player, e.block.location)
    }
})```
uneven mossBOT
#
⚠️ Please do not screenshot code as it causes a number of issues:
💠💠💠
  1. Ease of assistance - If someone wants to copy your code and correct it, they cannot. Making it easy for people to help you is in your best interests.
  2. Editorialising - It's common to try to make images small in size, which means you're likely to crop out code relevant to your issue.
  3. Accessibility - Wide images can be hard to read on mobile devices, and are impossible for screen readers.
  4. Legibility - You cannot read screenshots of code directly, instead you have to open them in an enlarged context.
  5. Bandwidth usage/clutter - Some of our members use metered connections, and it is wasteful for them to download images of text.

For a small amount of code, please use a codeblock (!!help.codeblocks), while an external repository (see !!help.code) is suitable for larger codebases.

gloomy coyote
raw nexus
#

you can put it on pastebin

gloomy coyote
#

i change it

#

do u have any idea to fix that error?