#break block
1 messages · Page 1 of 1 (latest)
does not work
Try now
does not work
Sorry I forgot to add minecraft: try now
thanks
This is like a chatgpt conversion
sorry I forgot that you can tell me how to do it for which it only works if you have the tag (TTTT)
&& player.hasTag('')
I already tried
average online conversation.
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
}
});
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');
}
});
thank you but I already understand where to place it
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
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('')
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
}
});
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
}
});
Yes
default:
player.sendMessage("error")
break
c all the other blocks??
Were almost same,i think i guessed it right
no its mean when the block doesn't exist its send this error
yes
merci
French
thanks
no its mean when the broken block its not in the list, if you break like grass its say the error
sorry
Like a default function?
idk what you mean xD
can I delete it? default:
player.sendMessage("error")
break
yes
Like if the block doesn't have custom functions in case break
or the exceptions
yes
also I have another question what to do when you have a scoreboard = 10 or higher its mark Lvl 10
I am but I would like to do it in javascript without command block
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
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
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")
}
Thank you also
no
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.
There are 52 errors in this [code](#1188205406242209873 message).
Please read the attached file for the result.
could you please create a new post
Do you mean a page in this room?
okay
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
const score = getScore("money", player);
if (score >= 5 && score <= 12) {
player.sendMessage("ok")
}
I do not know how
here
.
how do I fix this problem [index.js] ran with error: [ReferenceError: 'player' is not defined
.
bc the player is not defined
I mean you need to add something that define the player
like here
can you give me an example because I really have no idea how to do it
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
}
}
I dont know in pc,but in mobile it has a plus button
Thanks
I was created
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
Hey guys who can help me
Sorry i still dont know how,the code was fine
okay
Sounds like your making a mining sim map
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
thanks
No not yet,make a backup and test if it works
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
@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"
Test this
I might also use this later
[Scripting] Unhandled promise rejection: CommandError: Syntax error: Unexpected "scorebaord": at ">>scorebaord<< objective"
It marks me, can I launch it?
Can i know what you mean
@gleaming nymph use this
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"
in my console it marks me when I launch with your script
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
how can I do so that it removes 10 can to execute and that it adds a Mineur2 tag
sorry, there's something else that's giving me this error
send the error
there is no error c me who but deceive
oh I didn't read it well
xd
xd
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