FallingBlock Behaving Oddly

I figured it would be simple enough to summon some falling blocks in a circle pattern to make a shockwave type thing, but now I’m about 4 hours and 2 circle drawing algorithms in, and its proving to be not simple. I’ve found an okay algorithm, and I still need to customize it to my needs, but I can’t seem to summon falling blocks properly. I’m using the below code to create a test command:

        Sponge.getCommandManager().register(this, CommandSpec.builder()
                .executor((src, args) -> {
                    if(src instanceof Player) {
                        World world = ((Player) src).getWorld();
                        Vector3i location = ((Player) src).getLocation().getPosition().toInt();
                        Optional<Entity> entityOptional = world.createEntity(EntityTypes.FALLING_BLOCK, location.toDouble().add(0.5, 15, 0.5));
                        if(entityOptional.isPresent() && entityOptional.get() instanceof FallingBlock) {
                            FallingBlock block = (FallingBlock) entityOptional.get();
                            block.offer(Keys.CAN_PLACE_AS_BLOCK, true);
                            block.offer(Keys.CAN_DROP_AS_ITEM, true);
                            block.offer(Keys.FALL_TIME, 120);
                            BlockState blockState = world.getBlock(location.sub(0, 1, 0));
                            block.offer(Keys.FALLING_BLOCK_STATE, blockState);
                            boolean success = world.spawnEntity(block, Cause.of(NamedCause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build())));
                            if(!success) {
                                world.setBlock(location, blockState);
                            }
                        }
                    }
                    return CommandResult.success();
                })
                .build(), "test2");

The block falls fine, but then it just disappears, and I can’t figure out why. I’ve tried messing with the location and the fall time and all that, but I just can’t seem to get it right. The above code is virtually identical to the code used to create a shockwave, except with a different summon location. Below is a video illustrating the behavior

Does anyone know what I’m doing wrong? I just want these blocks to fall and solidify :cry: (also, the only mod I have besides the test plugin is sponge, so yeah…)

1 Like

What if you summon a FallingBlock via commands? Just for testing.

I can’t get to a computer now, but I know that placing a gravel above air works, but spawning a gravel with the command above does not

I’d be double checking the difference in the NBT between the 2, there is probably some data you are missing or is unimplemented in Sponge.

I don’t know what Key creates it, but if a FallingSand entity doesn’t have a Time tag, or has it set to 0, it disappears immediately if a block at its location doesn’t have the same ID. You’ll need to set that to 1. I’m pretty sure FALL_TIME doesn’t cover that, since a FallingSand entity can exist without falling (e.g. if it’s inside minecraft:piston_extension).

1 Like

I think it does have something to do with that… Here are the results of what @ryantheleach suggested:

The only difference, besides position, I can find is in the Time tag, which is -109 for my summoned block, and 13 for the block dropped naturally (placing a sand), see image below:

So, does anyone now which key this is? I looked through quickly and couldn’t find it.

If that is truly the Time tag, that should be renamed. If a FallingSand entity exists inside the piston extension block, it can be on the ground (i.e. not falling at all) while it’s Time tag increases.

Disagree strongly, FALL is required to disambiguate it from other TIME’s what would you suggest?

EXISTENCE_TIME or LIFE_TIME, since they accurately represent the tag’s function.

“When Time goes above 600, or above 100 while the block is below Y=0, the entity is deleted.”

and? Time still increases while the entity exists, whether or not it is actually falling.

An absolutely consistant way to summon a falling block where none was before, is to set the location to the blockstate first, and then spawn the falling block. Falling block spawnpoints must be at (x.5, y.?, z.5) coordinates to fall and land without being destroyed, some glitching happens if they are spawned and fall to offset positions, but dead-center of the column they are fine.

Here is video demo and pastebin of a single-class plugin demo that will make a ring of blocks 3 away from the player, falling from 15 high in the sky, made of the material the player stands on when waving a clayball. Other than the multiple conversions of position vectors, its quite simple process, its just converting the player position to the dead-center of the block he is in, and offsetting by integer multiples in the horizontal direction, and that location is then raised into the air for the actual spawnpoint

I’ve got plugins that make cave-ins surrounding a player locally, and sudden sinkhole formations that hollow out a volume below and then let everything on the surface just fall straight down making buildings will slice up like bread as they fall beautifully, demonstrated in my other videos on my channel.
Spawning an entity of the block at the center xz of the block makes the solid block disappear. Spawning it in air, you get a lot of stuck-up blocks from time to time (try my plugin without changing air to the block first, you’ll see about 60% of the time they hover)

1 Like

Thanks! It works perfectly! At least… as long as I set the block. Without setting the block, it fails. Regardless, it should be sufficient. What I don’t understand is why it doesn’t work anyway…

Glad you’re happy :wink: Yeah, I struggled with that problem as well, even way back in time with falling block demos, and investigating various keys for fall-time etc, didn’t seem consistant. It is an extra step, and I have no idea how it might botch up any block-edit logging plugins, but thats what causes and filtering are for :slight_smile: From time to time, I reinvestigate falling blocks… I tried to port a tornado generating plugin I made in bukkit into sponge, its less of a tornado and more of a vomiting chewing machine with holes and dropped blocks everywhere, but one day, I will make it work right.

1 Like

As @TheBoomer mentioned, the way falling blocks are designed means that if it can’t delete the block it was spawned from, it’ll disappear. My guess is that the lag from the server to your client was enough to cause it to appear to spawn and fall, when in fact it disappeared within the first tick.

This odd behaviour also means if you wanted it to fall for a specified number of ticks and disappear, you could set the time to be eg -399 as the tick time always goes up.

Then it is to do with the Time tag. If Time is greater than 0, it behaves normally. However, if Time is 0, then if there is a block at that location with the same block ID, then it will replace the block. If there is none, it despawns.