import { world, system } from "@minecraft/server";
world.afterEvents.playerPlaceBlock.subscribe(data => {
if (data.block.permutation.matches('minecraft:sandstone')) {
const blocklocx = data.block.x
const blocklocy = data.block.y
const blocklocz = data.block.z
system.runTimeout(() => {
data.player.runCommandAsync(`setblock ${blocklocx} ${blocklocy} ${blocklocz} air`)
}, 120);
if (data.player.hasTag('clutch') || data.player.hasTag('bridge')) {
data.player.runCommandAsync('give @p sandstone 1 0 {"can_place_on":{"block":["gold_block","dirt","grass","sandstone","planks"]}}')
}
}
})```
my code is to after place a block i will get back the block in the give command, but i doesnt work. im in stable version
#why this doesnt work need helpp
1 messages · Page 1 of 1 (latest)
No Errors
No errors in [code](#1229237367018229860 message)
Which part is not working exactly?
in the if player hastag part
the block isnt given to me
- Does the player have any of those tags?
- Have you tried running the command in-game?
oh i just tested it then it gave me this error
but why i do that in command block it works .-.
my brain isnt braining
Absolutely no idea
ello
eloo
import { world, system } from "@minecraft/server";
world.afterEvents.playerPlaceBlock.subscribe(data => {
if (data.block.permutation.matches('minecraft:sandstone')) {
const player = data.player
const blocklocx = data.block.x
const blocklocy = data.block.y
const blocklocz = data.block.z
system.runTimeout(() => {
player.runCommandAsync(`setblock ${blocklocx} ${blocklocy} ${blocklocz} air`)
}, 120);
if (player.hasTag('clutch') || player.hasTag('bridge')) {
player.runCommandAsync('give @p sandstone 1 0 {"minecraft:can_place_on":{"blocks":["gold_block","dirt","grass","sandstone","planks"]}}')
}
}
})
maybe this works
lemme try
Was he just missing the namespace? lol
where dont say thats in my script lol
his mistake ig
- he used
can_place_oni useminecraft:can_place_on - he used
blocki useblocks
Its just a supposition
💀
hel nah i miss that
Ah
ty guys
you like them dont you?
I have a cat so yeah
Can i eat it`?
NOO ;w; (Anyway #off-topic please)
oki
did it worked?
yep
how can i miss the 's'
perfect, if you have any other problems, ping the king ( King :3 )
i forgot often .subscribe
Also you don’t have to use commands because apparently the native method is stable
wat method
.setCanPlaceOn it’s part of the ItemStack class