mojira.dev
MC-207866

Some Entities get stuck in upwards (soul sand) bubble columns

The bug:

Tnt, Falling blocks, and Xp orbs (only those that I know of currently, might be more) can get stuck in up going (soul sand) bubble columns. This is due to the order or events in the entities tick phase where the onGround tag perpetuates downward motion instead of upwards due to being in the column. (Watch video to understand better)

Example: https://youtu.be/drtWuTpykA4

[media]

The Setup:

Build the following:

(WARNING!! IT WILL EXPLODE BETWEEN TNT. YOU MUST REBUILD IT WHEN TESTING THE OTHER TNT) 

[media][media]

Fire the Tnt one at a time to see the issue. 

You can use the following command a few blocks above the soul sand to test xp orbs.

/summon minecraft:experience_orb ~ ~8 ~ {Motion:[0.0,-9.0,0.0]}

Code Analysis:

Using 20w49a yarn/fabric mappings:

We will be looking at the Tnt entity for this:

public class TntEntity
//remove code
public void tick() {
    if (!this.hasNoGravity()) {
        this.setVelocity(this.getVelocity().add(0.0, -0.04, 0.0));
    }
    this.move(MovementType.SELF, this.getVelocity());
    this.setVelocity(this.getVelocity().multiply(0.98));
    if (this.onGround) {
        this.setVelocity(this.getVelocity().multiply(0.7, -0.5, 0.7));
    }
   //remove code 
}

Here, we have the tick method of Tnt. For this, let us assume that the Tnt has enough downward motion to reach the soul sand of the bubble column (lets say -10.0 b/gt)

First we will add gravity to the motion making it -10.04 b/gt.

Next we will do a move method.

Without showing the code, what will happen is that it will collide with the soul sand, set it's velocity to 0 b/gt and set onGround to true then check more block collisions, in this case, bubble column. From 0 b/gt, it will set the velocity to 0.7 b/gt from the "onBubbleColumnCollision" method in the entity class.

Thirdly, (back in the Tnt tick method) we will multiply all axis motion by 0.98 (drag), thus making the y motion now 0.686 b/gt. 

Fourthly, as onGround was set to true by the move method, it will multiple the Y axis by -0.5, thus making the velocity -0.343 b/gt

As we end up with a negative velocity, the onGround will be set to true in the next move method as it will collide with the soul sand and the cycle will continue. This makes the bubble column not work.

A Potential Fix:

If an entity has collided with a bubble column in the "checkBlockCollision()", set the OnGround tag to False. This may have unforeseen consequences, but I can't think of any as of now

 

Linked issues

Attachments

Comments 4

Here's a clip of it affecting Grian. [1.19.4]
https://youtube.com/clip/UgkxPW1Ayt-80nNjLMUBZwOXQ4hb5QdyuE82

It's the same bug, except the tnt starts of by being on the soul sand with downwards momentum from the water pushing it down

I want to confirm this for 1.20.2. I'm trying to make a tnt launcher that pushes tnt up with bubble column, and had to do a very weird workaround to make sure the tnt isn't touching the soul sand when it enters the bubble column, else it gets stuck inside the soul sand and destroys the machine

it seems to me that, as most other entities, TNT should be pushed up if it enters the bubble column, even if it's sliding along the ground, and I probably shouldn't have to do this workaround

[media]

(had to add a gap under where the tnt enters so it doesn't ever touch the soulsand)

Kyle Weber

(Unassigned)

Community Consensus

Platform

Normal

Entities

bubble-column, upwards

Minecraft 1.13.1, 1.15 Pre-Release 2, 1.16.4, 20w49a, 20w51a, ..., 1.18.1, 1.19.4, 23w12a, 1.20.2, 23w43b

Retrieved