TransWikia.com

How do I detect any block around an entity using the /execute command in Minecraft?

Arqade Asked on October 22, 2020

I’m trying to create an RPG launcher kind of device to make a tutorial on for my YouTube channel. I am using crossbows and firework rockets and so far I have succeeded in having the firework rocket explode when flying above grass blocks. Is there any way to detect when the rocket flies into any block, rather than a particular block / category?

2 Answers

Try the following:

/execute unless block X Y Z minecraft:air run SOMETHING...

Theoretically this should work, as minecraft:air is a block type, and should be detectable using the /execute command.

But I’m not sure, because I don’t have access to Minecraft yet. When I do, I’ll test this out.

Correct answer by ExpertCoder14 on October 22, 2020

You could use the command /execute as @e[type=minecraft:firework_rocket] at @s anchored eyes unless block ^ ^ ^1 air run summon minecraft:creeper ~ ~ ~ {Fuse:0s,ignited:1b} in a repeating command block, which checks if the block infront of the firework rocket is not air, which causes an explosion, though pressing F3 + B (and looking at the blue line) reveals that the facing direction can be a bit wonky with fireworks.

I'd also recommend having /execute as @e[type=minecraft:firework_rocket] at @s anchored eyes unless block ^ ^ ^1 air run kill @s in a chain command block to make sure the explosion only happens once

Having an area full of string would make the system more reliable, as the rocket could pass through the string but be facing string, a non-air block

Answered by Macks on October 22, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP