Give yourself some netherite boots with this command:
item replace entity @p armor.feet with minecraft:netherite_boots{display:{Name:'{"text":"Step-boots","color":"#0FF82E","italic":false}'},AttributeModifiers:[{AttributeName:"generic.step_height",Name:"generic.step_height",Amount:2.0,Operation:0,UUID:[I;1024845256,1045783364,1007170712,1113454942]}]}
You can only move while sneaking: (where x is step_height)
when there are x+1 solid blocks below you (for x <10)
when there are 10 solid blocks below you (for x >= 10)
Linked issues
is duplicated by 5
relates to 2
Attachments
Comments 6
Players cannot move while sneaking when player's generic.step_height ≥(Collidable block's hitbox total height under the player)+1.5.
For example, if there are only 2 solid blocks under players, they cannot move while sneaking when their generic.step_height is ≥3.5.
Code analysis by @Nickid2018 :
This is because player avoids to fall from block edge, but the checking method is wrong.
@Override
protected Vec3 maybeBackOffFromEdge(Vec3 var0, MoverType var1) {
if (!this.abilities.flying && var0.y <= 0.0 && (var1 == MoverType.SELF || var1 == MoverType.PLAYER) && this.isStayingOnGroundSurface() && this.isAboveGround()) {
double var2 = var0.x;
double var3 = var0.z;
double var4 = 0.05;
while (var2 != 0.0 && this.level().noCollision(this, this.getBoundingBox().move(var2, -this.maxUpStep(), 0.0))) {
if (var2 < 0.05 && var2 >= -0.05) {
var2 = 0.0;
continue;
}
if (var2 > 0.0) {
var2 -= 0.05;
continue;
}
var2 += 0.05;
}
while (var3 != 0.0 && this.level().noCollision(this, this.getBoundingBox().move(0.0, -this.maxUpStep(), var3))) {
if (var3 < 0.05 && var3 >= -0.05) {
var3 = 0.0;
continue;
}
if (var3 > 0.0) {
var3 -= 0.05;
continue;
}
var3 += 0.05;
}
while (var2 != 0.0 && var3 != 0.0 && this.level().noCollision(this, this.getBoundingBox().move(var2, -this.maxUpStep(), var3))) {
var2 = var2 < 0.05 && var2 >= -0.05 ? 0.0 : (var2 > 0.0 ? (var2 -= 0.05) : (var2 += 0.05));
if (var3 < 0.05 && var3 >= -0.05) {
var3 = 0.0;
continue;
}
if (var3 > 0.0) {
var3 -= 0.05;
continue;
}
var3 += 0.05;
}
var0 = new Vec3(var2, var0.y, var3);
}
return var0;
}
It should search the collision from player's feet to its max step height, not just move the collision box to the max step height and check whether it collides.
I don't know if this is already mentioned by the code analysis post, but the player's scale also plays into this. The smaller the player's scale, the smaller the block's collision below them can be (Assuming a constant step size of 0.6) so they stop moving while crouching. A scale of 0.25 and step size of 1 cannot crouchwalk on closed trap doors for example.
Actually, the cheaking method of prevent falling when sneaking checks if they move down a distance equal to their max step height whether it collides.
If it doesn't collide, player won't move.
For example, when a player of step_height 0.6 and scale 0.25 is standing on a closed trapdoor without blocks under it, trapdoor's thickness=0.1875, player's height=1.5*0.25, 0.6-1.5*0.25=0.225>0.1875, so he can't move when sneaking.
Also, a player with scale 1 and step_height 4 can move while sneaking on a floating block 2 blocks above the ground, because his feet is in the ground if he moves 4 blocks down.
From my testing, seems like any step_height value >= 2.5 will prevent you from move while sneaking if you're standing in a single full block (with no other blocks below it).
If you put a slab below the block you're standing on, you'll be able to move again.