#break block

1 messages · Page 1 of 1 (latest)

tall basalt
#
world.afterEvents.playerBreakBlock.subscribe((event) => {
    const player = event.player; 
    const block = event.brokenBlockPermutation


    const blockType = block.type.id


    if (blockType === "minecraft:dirt") {
        player.runCommandAsync('say test'); 
    }
});

gleaming nymph
#

does not work

tall basalt
#

Try now

gleaming nymph
#

does not work

tall basalt
gleaming nymph
#

thanks

crude summit
#

This is like a chatgpt conversion

gleaming nymph
#

sorry I forgot that you can tell me how to do it for which it only works if you have the tag (TTTT)

crude summit
#

&& player.hasTag('')

gleaming nymph
rain bison
tall basalt
# tall basalt ```js world.afterEvents.playerBreakBlock.subscribe((event) => { const player...

you can also use a switch statement

world.afterEvents.playerBreakBlock.subscribe((event) => {
    const player = event.player; 
    const block = event.brokenBlockPermutation


    const blockType = block.type.id

    switch (blockType) {
        case 'minecraft:dirt':
            player.sendMessage("dirt")
        break
        case 'minecraft:stone':
            player.sendMessage("stone")
        break
        default:
            player.sendMessage("error")
        break
    }
});
crude summit
#

For tag i think jt would like this:

world.afterEvents.playerBreakBlock.subscribe((event) => {
    const player = event.player; 
    const block = event.brokenBlockPermutation


    const blockType = block.type.id


    if (blockType === "minecraft:dirt" && player.hasTag('tag here')) {
        player.runCommandAsync('say test'); 
    }
});

gleaming nymph
crude summit
#

Hmm ok

#

How about:

world.afterEvents.playerBreakBlock.subscribe((event) => {
    const player = event.player; 
    const block = event.brokenBlockPermutation


    const blockType = block.type.id


    if (blockType === "minecraft:dirt") {
        if(player.hasTag('tag') player.runCommandAsync('say test'); 
    }
});

Just a sub if

gleaming nymph
#
world.afterEvents.playerBreakBlock.subscribe((event) => {
    const player = event.player; 
    const block = event.brokenBlockPermutation


    const blockType = block.type.id

    switch (blockType) {
        case 'minecraft:dirt':
            player.sendMessage("dirt")
        break
        case 'minecraft:stone':
            player.sendMessage("stone")
        break
        default:
            player.sendMessage("error")
        break
    }
});
#

I place it or && player.hashTag('')

crude summit
#

Try beside the player.sendMessage()

#
world.afterEvents.playerBreakBlock.subscribe((event) => {
    const player = event.player; 
    const block = event.brokenBlockPermutation


    const blockType = block.type.id

    switch (blockType) {
        case 'minecraft:dirt':
            if(player.hasTag('tag')) player.sendMessage("dirt")
        break
        case 'minecraft:stone':
            player.sendMessage("stone")
        break
        default:
            player.sendMessage("error")
        break
    }
});
tall basalt
#
world.afterEvents.playerBreakBlock.subscribe((event) => {
  const player = event.player; 
  const block = event.brokenBlockPermutation


  const blockType = block.type.id
  switch (blockType) {
      case 'minecraft:dirt':
        if (!player.hasTag("TTTT")) return
          player.sendMessage("dirt")
      break
      case 'minecraft:stone':
        if (!player.hasTag("TTTT")) return
          player.sendMessage("stone")
      break
      default:
          player.sendMessage("error")
      break
  }
});
crude summit
#

Yes

gleaming nymph
#

default:
player.sendMessage("error")
break

c all the other blocks??

crude summit
tall basalt
crude summit
#

yes

crude summit
#

French

gleaming nymph
#

thanks

tall basalt
gleaming nymph
#

sorry

tall basalt
#

idk what you mean xD

gleaming nymph
#

can I delete it? default:
player.sendMessage("error")
break

tall basalt
#

yes

crude summit
#

or the exceptions

tall basalt
#

yes

crude summit
#

aahhh

#

Thanks

gleaming nymph
#

also I have another question what to do when you have a scoreboard = 10 or higher its mark Lvl 10

crude summit
#

i think it's better to use /execute for that

#

or @p[scores={}]

gleaming nymph
#

I am but I would like to do it in javascript without command block

crude summit
#

example command is

/give @a[scores={coins=5..}] apple

This would give the player an apple if the player has a score in objective coins of more than 5

#

This doesn't require cmd blocks

gleaming nymph
#

I do it but I would like to do it without command block only in javascript so that I can learn and that it will help me in but future project

tall basalt
#

function getScore(scoreboardValue, player) {
  try {
    return world.scoreboard.getObjective(scoreboardValue).getScore(player.scoreboardIdentity)
  } catch {
    return 0
  }
}

//usage
if (getScore("money", player) >= 10) {
  player.sendMessage("ok")
}
crude summit
#

Thank you also

tall basalt
#

but Idk if the arrow is wrong > or <

#

idk

#

I have a weakness with that

#

XD

crude summit
#

Do you know to make it min to max?

#

like 5 to 12 score

gleaming nymph
#

no

halcyon vessel
#

This is a navigation script, and I can open a menu by long pressing on the iron block while I am holding the compass, but I can create only one button to navigate to, and I want to create more than one button to navigate to in several places.

rotund falconBOT
#
Debug Result

There are 52 errors in this [code](#1188205406242209873 message).
Please read the attached file for the result.

crude summit
#

View this

#

@halcyon vessel

tall basalt
halcyon vessel
#

Do you mean a page in this room?

crude summit
#

Make new

#

#1067535382285135923

halcyon vessel
#

okay

gleaming nymph
#

function getScore(scoreboardValue, player) {
try {
return world.scoreboard.getObjective(scoreboardValue).getScore(player.scoreboardIdentity)
} catch {
return 0
}
}

//usage
if (getScore("money", player) >= 10) {
player.sendMessage("ok")
}

#

[index.js] ran with error: [ReferenceError: 'player' is not defined

tall basalt
#
const score = getScore("money", player);

if (score >= 5 && score <= 12) {
  player.sendMessage("ok")
}
halcyon vessel
tall basalt
gleaming nymph
# tall basalt .

how do I fix this problem [index.js] ran with error: [ReferenceError: 'player' is not defined

tall basalt
#

I mean you need to add something that define the player

gleaming nymph
#

can you give me an example because I really have no idea how to do it

tall basalt
#
world.afterEvents.playerBreakBlock.subscribe((event) => {
  const player = event.player; 
  const block = event.brokenBlockPermutation

  const score = getScore("money", player);

  const blockType = block.type.id
  switch (blockType) {
      case 'minecraft:dirt':
        if (!player.hasTag("TTTT")) return
        if (score >= 5 && score <= 12) {
            player.sendMessage("ok")
        }
          player.sendMessage("dirt")
      break
      case 'minecraft:stone':
        if (!player.hasTag("TTTT")) return
          player.sendMessage("stone")
      break
      default:
          player.sendMessage("error")
      break
  }
});

function getScore(scoreboardValue, player) {
  try {
    return world.scoreboard.getObjective(scoreboardValue).getScore(player.scoreboardIdentity)
  } catch {
    return 0
  }
}
crude summit
halcyon vessel
#

I was created

gleaming nymph
#

I would like to detect who breaks a block and gives it to a scoreboard called minor and that it has a tag named TTTT and that it can reach a score of 10 it goes up in level and it adds to a scoreboard called MinorLVL 1

halcyon vessel
#

Hey guys who can help me

crude summit
halcyon vessel
#

okay

crude summit
crude summit
# gleaming nymph I would like to detect who breaks a block and gives it to a scoreboard called mi...

Im thinking it would be like this,im not sure:

world.afterEvents.playerBreakBlock.subscribe((event) => {
  const player = event.player; 
  const block = event.brokenBlockPermutation
  const score = getScore("minor", player);
  const minorlv = getObjective("MinorLv")
  const blockType = block.type.id
  if(score == 10 && player.hasTag('TTTT')) {
    minorlv.addScore(player, 1);
  }
});

function getScore(scoreboardValue, player) {
  try {
    return world.scoreboard.getObjective(scoreboardValue).getScore(player.scoreboardIdentity)
  } catch {
    return 0
  }
}

@tall basalt what do you think

gleaming nymph
#

thanks

crude summit
#

No not yet,make a backup and test if it works

tall basalt
# crude summit Im thinking it would be like this,im not sure: ```js world.afterEvents.playerBre...
world.afterEvents.playerBreakBlock.subscribe((event) => {
  const player = event.player; 
  const block = event.brokenBlockPermutation
  const score = getScore("minor", player);
  const blockType = block.type.id
  if(score == 10 && player.hasTag('TTTT')) {
    addScore("MinorLv",player, 1);
  }
});

function getScore(scoreboardValue, player) {
  try {
    return world.scoreboard.getObjective(scoreboardValue).getScore(player.scoreboardIdentity)
  } catch {
    return 0
  }
}

function addScore(scoreboardValue, player, number) {
  try {
    let score = world.scoreboard.getObjective(scoreboardValue).getScore(player.scoreboardIdentity)
    return world.scoreboard.getObjective(scoreboardValue).setScore(player, (score + number))
  } catch {
    return 0
  }
}
#

try this

crude summit
#

@gleaming nymph

gleaming nymph
#

world.afterEvents.playerBreakBlock.subscribe((event) => {
const player = event.player;
const block = event.brokenBlockPermutation
const score = getScore("MineurXp", player);
const minorlv = getObjective("MinorLvl")
const blockType = block.type.id
if(score == 10 && player.hasTag('mineur')) {
minorlv.addScore(player, 1);
}
});

function getScore(scoreboardValue, player) {
try {
return world.scoreboard.getObjective(scoreboardValue).getScore(player.scoreboardIdentity)
} catch {
return 0
}
}

#

[Scripting] Unhandled promise rejection: CommandError: Syntax error: Unexpected "scorebaord": at ">>scorebaord<< objective"

crude summit
#

I might also use this later

gleaming nymph
#

[Scripting] Unhandled promise rejection: CommandError: Syntax error: Unexpected "scorebaord": at ">>scorebaord<< objective"

gleaming nymph
crude summit
#

Can i know what you mean

gleaming nymph
#
world.afterEvents.playerBreakBlock.subscribe((event) => {
    const player = event.player; 
    const block = event.brokenBlockPermutation
    const score = getScore("MineurXp", player);
    const blockType = block.type.id
    if(score == 10 && player.hasTag('mineur')) {
      addScore("MineurLvl",player, 1);
    }
  });
  
  function getScore(scoreboardValue, player) {
    try {
      return world.scoreboard.getObjective(scoreboardValue).getScore(player.scoreboardIdentity)
    } catch {
      return 0
    }
  }
  
  function addScore(scoreboardValue, player, number) {
    try {
      let score = world.scoreboard.getObjective(scoreboardValue).getScore(player.scoreboardIdentity)
      return world.scoreboard.getObjective(scoreboardValue).setScore(player, (score + number))
    } catch {
      return 0
    }
  }
#

[Scripting] Unhandled promise rejection: CommandError: Syntax error: Unexpected "scorebaord": at ">>scorebaord<< objective"

gleaming nymph
tall basalt
#

try it now


world.afterEvents.playerBreakBlock.subscribe((event) => {
  const player = event.player; 
  const block = event.brokenBlockPermutation
  const score = getScore("MineurXp", player);
  const blockType = block.type.id
  if(score == 10 && player.hasTag('mineur')) {
    addScore("MineurLvl", player, 1);
  }
});

function getScore(scoreboardValue, player) {
  try {
    return world.scoreboard.getObjective(scoreboardValue).getScore(player.scoreboardIdentity)
  } catch {
    return 0
  }
}

function addScore(scoreboardValue, player, number) {
  try {
      const newScore = getScore(scoreboardValue, player) + number;
      return world.scoreboard.getObjective(scoreboardValue).setScore(player.scoreboardIdentity, newScore)
  } catch {
      return 0
  }
}
#

its working for me idk if you get any errors

#

for me its working

gleaming nymph
#

how can I do so that it removes 10 can to execute and that it adds a Mineur2 tag

gleaming nymph
tall basalt
#

send the error

gleaming nymph
#

there is no error c me who but deceive

tall basalt
#

xd

gleaming nymph
#

xd

gleaming nymph
#
case 'minecraft:stone':
          if (!player.hasTag("mineur") && !player.hasTag("mineur2") && !player.hasTag("mineur3") && !player.hasTag("mineur4") && !player.hasTag("mineur5") && !player.hasTag("mineur6") && !player.hasTag("mineur7") && !player.hasTag("mineur8") && !player.hasTag("mineur9") && !player.hasTag("mineur10") && !player.hasTag("mineur11") && !player.hasTag("mineur12") && !player.hasTag("mineur13") && !player.hasTag("mineur14") && !player.hasTag("mineur15") && !player.hasTag("mineur16") && !player.hasTag("mineur17") && !player.hasTag("mineur18") && !player.hasTag("mineur19" && !player.hasTag("mineur20"))) return                   
            player.runCommand("scoreboard players add @s MineurXp 100")
            player.runCommand(`titleraw @s actionbar {"rawtext":[{"text":"§a+100xp"}]}`)
        break
#

The Tag (mineur19 , mineur20) does not work or and the error