I am working on a data pack where I want to be able to summon a falling block entity, and instantly turn it into its solid block variant.
I have tried setting the block below it to a solid block, but that takes 2 ticks for the block to turn solid, and I don't want to overwrite blocks that were previously there.
I have already tried setting the "OnGround" tag to 1b, but that didn't change anything and the NBT was instantly reset.
I can't see anyway to do it. It seems it only become solid when it has gravity and has a solid block beneath it.
You can summon a block underneath it at the same time with a check to make sure it only replaces air. This probably wouldn't work if there was a fence or button etc beneath it.
If it needs to be instantly solid why not set a solid block there? If you need to do something to it while it's an entity, could you summon a marker, or area_effect_cloud, do what you need to and then setblock at the markers location?
You are correct, I've been setting the block below to solid if it's air, and removing it. This does not work with water, buttons, path blocks, or any other non full block.
The reason I can't use setblock is because that command needs to be hardcoded (as far as I'm aware). I am using the NBT data of items in the players inventory to determine what the block type should be (if you are holding a gold block it should place a gold block, etc). You can modify what type of block a falling_block entity is, but cannot do the same with setblock, at least without hardcoding every single block.
I think you are right. You would have to use something like "if nbt = a then setblock a, if nbt = b then setblock b" etc. Out of interest what command are you using to check the nbt and change the Falling_Block type?
I would suggest asking at: https://www.reddit.com/r/MinecraftCommands/. There are a lot of people there who are very good at commands and may know a solution. The only thing I can think of is hard coding it all in commands blocks or a Datapack, which would be tedious if you have a lot of block choices.
For this particular project, I want it to work with every single placeable block, so that would be way too much effort to hardcode that.
The command I'm using is pretty simple:
/data modify entity @e[tag=placed,type=falling_block,limit=1] BlockState.Name set from entity @s SelectedItem.id
Then if the resulting falling block has a blockstate of sand, that means that the player is holding either nothing or a non-block item, so I kill it in that case.
Ah, I see, and since you want the Falling Block to become solid and update straight away it doesn't matter that changing the BlockState nbt doesn't change the look of the block until it updates, cool. Hopefully someone on the Reddit thread can help in some way.
I am working on a data pack where I want to be able to summon a falling block entity, and instantly turn it into its solid block variant.
I have tried setting the block below it to a solid block, but that takes 2 ticks for the block to turn solid, and I don't want to overwrite blocks that were previously there.
I have already tried setting the "OnGround" tag to 1b, but that didn't change anything and the NBT was instantly reset.
Any help would be greatly appreciated!
-TechnoBro03
I can't see anyway to do it. It seems it only become solid when it has gravity and has a solid block beneath it.
You can summon a block underneath it at the same time with a check to make sure it only replaces air. This probably wouldn't work if there was a fence or button etc beneath it.
If it needs to be instantly solid why not set a solid block there? If you need to do something to it while it's an entity, could you summon a marker, or area_effect_cloud, do what you need to and then setblock at the markers location?
You are correct, I've been setting the block below to solid if it's air, and removing it. This does not work with water, buttons, path blocks, or any other non full block.
The reason I can't use setblock is because that command needs to be hardcoded (as far as I'm aware). I am using the NBT data of items in the players inventory to determine what the block type should be (if you are holding a gold block it should place a gold block, etc). You can modify what type of block a falling_block entity is, but cannot do the same with setblock, at least without hardcoding every single block.
-TechnoBro03
I think you are right. You would have to use something like "if nbt = a then setblock a, if nbt = b then setblock b" etc. Out of interest what command are you using to check the nbt and change the Falling_Block type?
I would suggest asking at: https://www.reddit.com/r/MinecraftCommands/. There are a lot of people there who are very good at commands and may know a solution. The only thing I can think of is hard coding it all in commands blocks or a Datapack, which would be tedious if you have a lot of block choices.
For this particular project, I want it to work with every single placeable block, so that would be way too much effort to hardcode that.
The command I'm using is pretty simple:
/data modify entity @e[tag=placed,type=falling_block,limit=1] BlockState.Name set from entity @s SelectedItem.id
Then if the resulting falling block has a blockstate of sand, that means that the player is holding either nothing or a non-block item, so I kill it in that case.
-TechnoBro03
Ah, I see, and since you want the Falling Block to become solid and update straight away it doesn't matter that changing the BlockState nbt doesn't change the look of the block until it updates, cool. Hopefully someone on the Reddit thread can help in some way.
I have no idea if what I'm suggesting is possible, but if you set up a code that detects where the entity is in relation to the block beneath it?