#cannot read property 'subscribe' of undefined

1 messages · Page 1 of 1 (latest)

true oak
#
world.beforeEvents.playerPlaceBlock.subscribe(async (event) => {
  const { block, player } = event;
  const { x, y, z } = block.location;

  if (!player.hasTag("admin")) {
    const cooldown = getScore(player, "cooldown");

    if (y !== -54) {
      system.run(() => {
        player.sendMessage(`§cYou cannot build here.`);
        player.playSound("random.break");
      });
      event.cancel = true;
      return;
    }

    if (y === block.dimension.heightRange.min) {
      return;
    }

    if (cooldown > 0) {
      system.run(() => {
        player.sendMessage(`§eYou are on a §6${cooldown}s§e cooldown!`);
        player.playSound("random.break");
      });
      event.cancel = true;
      return;
    }

    const perm = event.permutationBeingPlaced;
    const blockBelow = block.below();
    system.run(() => {
      player.playSound("random.orb");
      blockBelow.setType(perm.type.id);
      blockBelow.setPermutation(perm);
      player.runCommand("scoreboard players set @s cooldown 30");
    });

    event.cancel = true;
  }
});
#

what changed?

noble stump
#

you need beta API to use playerPlaceBlock

chrome oxide
#

lol

noble stump
chrome oxide