#playerInteractWithBlock not working on 1.21.50

1 messages · Page 1 of 1 (latest)

magic thistle
#
  const block = ev.block
  const player = ev.player
  
  if(block.typeId == "minecraft:diamond_block"){
    
    player.playSound("note.harp")
  }
})```

With the transition to the new version, I encountered a problem that the playerInteractWithBlock event stopped working correctly, instead of the sound being activated when pressed, I have to put a block on it so that the sound is produced, are there any ways to solve the problem?
floral meteor
#

after events will only trigger if you interact with something and it swings your arms

#

to make every block interactable use before events, it also applies in itemUse too even if the item isn't usable in the first plaue

#
world.beforeEvents.playerInteractWithBlock.subscribe((ev, { block, player } = ev) => {
  if (block.typeId === 'minecraft:diamond_block') {
    system.run(() => player.playSound('note.harp') );
  }
});```