mojira.dev
MC-151488

Glitch on teleporting falling block

Repro steps:

  • Create a single player world, creative, allow cheats

  • Give yourself a command block

  • Set the command block to "repeat"

  • Type this command:

tp @e[type=minecraft:falling_block] ~ ~1 ~
  • Turn on "always active"

  • Place a floating sand block nearby

Expected:

  • The sand block constantly gets teleported in 0.5 blocks above the command block.

Actual:

  • The sand block gets teleported above the command block.

  • The sand block is deleted.

  • An invisible entity? is created.

  • The user glitches when touching it.

Code analysis:

Found in this comment by @unknown.

Linked issues

Attachments

Comments 6

In my experience my block became an invisible and glitched enitity (like you said) at the original position i placed it on, not above it

 

Can confirm in 20w51a.

This is interesting. If you relog you will notice that it is actually floating where you placed it and that stopping the command block and updating the falling block acts normally.

Code Analysis: (Yarn - 1.17.1)

FallingBlock.class (Physical Block)

public void scheduledTick(...) {
    if (canFallThrough(...) && pos.getY() >= world.getBottomY()) {
        FallingBlockEntity fallingBlockEntity = new FallingBlockEntity(...);
        ...
        world.spawnEntity(fallingBlockEntity);
    }
}

When a falling block ticks, it creates a falling block entity.

 

FallingBlockEntity.class (Entity)

public void tick() {
    ...
    if (this.timeFalling++ == 0) {
        blockPos2 = this.getBlockPos();
        if (this.world.getBlockState(blockPos2).isOf(block)) {
            this.world.removeBlock(blockPos2, false);
        } else if (!this.world.isClient) {
            this.discard();
            return;
        }
    }
    ...
}

When a falling block ticks for the first time, it checks if the block where it's at is the block that it's supposed to replace. If it is, it will remove the block. If it's not and it's the server, it deletes the falling block.

In your instance, the block ticks, the command block moves it, and then the falling block entity ticks and realizes that the air above the command block is not sand, so it deletes itself.
The sand block never gets removed because of this, although for the client, the sand replaced the block if the server was too slow to tell it that it moved, so you get an invisible block.

The solution to fix this is... don't use: 

tp @e[type=minecraft:falling_block] ~ ~1 ~

Use: (It will grab the falling block after its ticked once)

tp @e[type=minecraft:falling_block,nbt={Time:1}] ~ ~1 ~

Or create a falling block using a command, such as:

/summon minecraft:falling_block ~ ~1 ~ {BlockState:{Name:"minecraft:sand"},Time:1}

If Mojang wants to fix this tho, all they need to do is simply set the timeFalling to 1 if the falling block is teleported and has a timeFalling set to 0, while making sure to also delete the original block

 

Fixed in 22w03a

This seems to still be present, at least partially, in 22w12a. The player isn't glitching, but the falling block isn't constantly teleported above the command block as expected.

Edit: on second thought, this is probably a separate bug.

Can confirm in 1.19.4

Gec Diaconu

(Unassigned)

Confirmed

(Unassigned)

Minecraft 1.14, Minecraft 1.14.1 Pre-Release 1, 1.15.2, 20w51a, 22w12a, 1.19.4

Retrieved