#BlockBreak Location and Sign content before breaking

1 messages · Page 1 of 1 (latest)

patent hemlock
#

How to get the location of the broken block in blockbreak event?
i cant get the sign's component, it returns undefined, and i can't copy the text of the sign for the sign replacement

  world.events.blockBreak.subscribe(block => {
    let {x, y, z} = block.player.location //location of player
    let blockPermutation = block.brokenBlockPermutation
    let blockID = blockPermutation.type.id
    let sign = block.player.dimension.getBlock(block.block.location)
    const content = sign.getComponent('sign') //this returns undefined idk why
    const text = content.getText().split("\n")
    console.warn(text)
    dimension.fillBlocks(block.block.location,block.block.location,blockPermutation) // and this doesn't include the sign's text for some reason
  })
mint veldt
#

BlockEvent.block.location

#
world.events.blockBreak.subscribe(block => {
    let {x, y, z} = block.player.location //location of player
    let blockPermutation = block.brokenBlockPermutation
    let blockID = blockPermutation.type.id
    console.warn(block.block.location) // get the location of the broke block
  })

i believe it's like this, the block.block.location looks weird

patent hemlock
patent hemlock
#

BlockBreak Location and Sign content before breaking

mint veldt
#

i think to save the text of the sign u might have to use the BlockSignComponent

solid harbor
#

you cant get components before breaking that block

#

bc blockBreak runs after you break that block

graceful geyser
#

BlockBreakEvent is an AfterEvent not a BeforeEvent which means that you can’t get the components of a block because the block is has been broken

solar verge
#

getComponent on blockHit, then w8 for blockBreak

fossil vine
#

block hit is also an event?

solar verge
patent hemlock
solar verge
patent hemlock
#

okay let me try

#

it works, thanks

solar verge
#

np

#

hb test with haste 2 with gold shovel efficiency V