I tried out the execute command which should summon tnt when there is netherite and say no when there isnt but it doesnt work. Command:
execute if block ~ ~ ~ minecraft:ancient_debris run summon minecraft:tnt ~ ~ ~ else run say no
Please fix this.
Comments 8
That doesnt make sense. I also want
execute if block ~ ~ ~ minecraft:netherite_block run setblock ~ ~ ~ diamond block else run setblock ~ ~ ~ netherite_block
which doesnt work. Your method
execute if block ~ ~ ~ minecraft:diamond_block run setblock ~ ~ ~ netherite_block
Then, another that’s
execute unless block ~ ~ ~ minecraft:diamond_block run setblock ~ ~ ~ diamond_block
doesnt work either. It always places a diamond block even if there is already a diamond block. Its supposed to swap these blocks.
This isn't the place to get command help - if you have found a specific bug with a command, then you can report it.
Here’s what I’ve got:
/execute if block 0 -60 0 minecraft:diamond_block run setblock 0 -60 0 minecraft:netherite_block
/execute unless block 0 -60 0 minecraft:diamond_block run setblock 0 -60 0 minecraft:diamond_block
your coordinates will vary. I tried with both being always active and repeating command blocks. This made them swap too fast to actually observe. I’d recommended a redstone clock (first activates, wait, second, wait, back to first).
Alternatively though, if you’re trying to swap specific blocks, you could do two “if” ones and just specify what block it’s looking for and what it’s replacing (diamond->netherite, netherite->diamond). I’d recommend going to some place like r/MinecraftCommands or YouTube for more help.
"else" is not valid syntax at all, The others are correct, this is misused commands, not a bug.
To swap a block, replace netherite blocks with a temporary block (eg sponges), then replace diamond blocks with netherite blocks, and then replace sponges with diamond blocks.
I’m not an expert with commands, but I don’t think that’s the right syntax. I see why one would think that, but this is essentially two commands in one (the summon and the say), which can’t really be done like this. In normal programming languages, what you’ve got would work (probably with some minor tweaks).
I think what you need is your if command as it’s own command.
execute if block ~ ~ ~ minecraft:ancient_debris run summon minecraft:tnt
Then, another that’s
execute unless block ~ ~ ~ minecraft:ancient_debris run say no