How to setblock snow_layer only if block below is a full-block?

How to setblock snow_layer only if block below is a full-block? - From below of lots of long narrow identical windows of contemporary construction in sunlight

Or is there actually any way to do that?

Basically I do a /setblock ~ ~ ~ snow_layer at the player but if it's above something that snow layer can't be on (eg. slab,sign,grass) it just looks buggy. :/ I could avoid it with causing a block update right after creating it.

Any idea is helpful even if you're not sure if it works or not! (best would be a one command block method)

As you can see on the picture looking for {OnGround:true} doesn't solve it all the time: enter image description here

UPDATE: I could do a /setblock above it, but that may remove other block, so I'm looking for a safer idea.

UPDATE 2: Changed title to represent the problem more clearly.



Best Answer

After trying many things, I finally came up with a solution that works all the time (I hope) and doesn't change any block:

Instead of creating the snow layer with:

/setblock ~ ~ ~ snow_layer

I use the command:

/summon FallingSand ~ ~ ~ {Block:"minecraft:snow_layer",Time:1,DropItem:false}

wich does the job quite well, and because of DropItem:false it doesn't even drop the snow if placing it fails. :)

NOTE:

Summoning falling sand at the same block where there's an existing one will cause it to be deleted, so only summon the sand if there's air! In my example:

Summon FallingSand that become a snow_layer AT every player:

/execute @a ~ ~ ~ detect ~ ~ ~ air 0 /summon FallingSand ~ ~ ~ {...}




Pictures about "How to setblock snow_layer only if block below is a full-block?"

How to setblock snow_layer only if block below is a full-block? - Patient showing stop gesture in light clinic
How to setblock snow_layer only if block below is a full-block? - From below of geometric minimalist wooden construction under white ceiling in modern building
How to setblock snow_layer only if block below is a full-block? - From below of aged metal clock tower located in city center with high towers








More answers regarding how to setblock snow_layer only if block below is a full-block?

Answer 2

I could do a /setblock above it, but that may remove other block, so I'm looking for a safer idea.

The /setblockcommand allows for an old block handing mode of "keep", which means that it will only replace air. Because of this, we can safely use a block that will immediately turn back to air (like a snow_layer) to cause a block update. Running a command like this at the same time as your current one should fix things:

/setblock ~ ~1 ~ snow_layer 0 keep

Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

Images: Ave Calvar Martinez, SHVETS production, Andreea Ch, Samson Katt