FakeSneaking (伪潜行)
A client side NeoForge mod for Minecraft 1.21.1 that sneaks for you at block edges, so you cannot walk off a ledge, a bridge, a roof or a corner.
| Minecraft | 1.21.1 |
| NeoForge | 21.1.255 |
| Java | 21 |
| Mod id | fakesneaking |
| Version | 1.1.0 |
| Side | client only (@Mod(dist = Dist.CLIENT)) |
| Adds | nothing on the server: no blocks, items, entities, effects, commands or packets |
What it does
FakeSneaking is one client side on/off switch. Turn it on and the client starts sneaking by itself whenever you are about to step off an edge. Turn it off and the mod does nothing at all.
- The state is not an effect and not a potion, just a switch. It stays on until you turn it off and is remembered across restarts (
config/fakesneaking-client.toml). - The sneak it produces is a completely ordinary vanilla sneak: the vanilla crouch pose, the vanilla sneaking speed and the vanilla
ServerboundPlayerCommandPacket. The server and every other player see a normally sneaking player. - An automatic sneak cannot be cancelled by hand: while you stand at the edge, releasing the sneak key does nothing. Turn the state off, or step away from the edge.
- A sneak you started yourself is never touched. The mod only ever adds the sneak input; it never takes one away, so leaving an edge or turning the state off leaves your own sneak key alone.
How an edge is decided
Only vanilla decides what an edge is - the mod asks vanilla's own anti-fall question instead of inventing a rule of its own.
- While moving a mixin at the head of vanilla's
Player#maybeBackOffFromEdgetakes the movement the game is about to apply and asks "would sneaking shorten or cancel this?" - exactly the question vanilla asks for a sneaking player. If the answer is yes, the sneak input is set, which also makes that same vanilla call protect that same movement, in the same tick. Because the real movement vector is used, this is correct for every direction (forward, diagonal, sideways, backwards) and for every speed, including moving several blocks in a single tick. - While standing still there is no movement to ask about, so the same question is asked from the player's position in all eight horizontal directions. The band around the edge is two pixels (2/16 of a block): the sneak holds while you are over the edge or up to two pixels back inside it, and ends as soon as you have walked those two pixels in. The diagonals are included because vanilla reduces a diagonal movement with the joint
canFallAtLeast(d0, d1)test, which is what makes a concave ("inner") corner an edge. - The helpers (
isAboveGround,canFallAtLeast) are line for line ports of vanilla's, so step height, partial blocks (slabs, stairs, …) and everything else behave exactly like vanilla. - Anything vanilla does not protect is not protected here either: flying, swimming, riding, water, lava, climbing and being airborne (jumping off a ledge) are left to the game.
Key bindings
Two placeholders are registered in the controls screen under the FakeSneaking category.
| Binding | Default |
|---|---|
| FakeSneaking Combo First | The key bound to 'sneaking' in the game |
| FakeSneaking Combo Second | Z |
- Both bound: press the first key, then the second one, to toggle the state.
- Only one bound: that single key toggles the state.
- Neither bound: there is no shortcut.
The default first key is Shift, which is also the vanilla sneak key. Vanilla sneaking is never blocked or changed - the binding is only read to detect the toggle.
中文速览
- 纯客户端开关:按键切换(默认先按
Shift再按Z),状态写入config/fakesneaking-client.toml,重启后保留。 - 开启后,当你走到"原版潜行会阻止掉落"的边缘时自动潜行,且无法手动取消;离开边缘(退回边缘内侧 2 像素)自动取消;你自己的手动潜行完全不受影响。
- 判定完全复用原版逻辑,不自己编规则:
- 移动时,用真实的移动向量在
Player#maybeBackOffFromEdge开头问原版"这一步会不会被潜行拦下"——任意方向(前后左右、斜向)、任意速度(一 tick 移动数格也行)都正确。 - 静止时,按玩家所在位置在八个水平方向问同一个问题,带宽 2 像素(2/16 格)。
- 原版不防掉落的情况(飞行、游泳、骑乘、水中、岩浆、梯子、空中跳跃等)本模组同样不介入。
- 移动时,用真实的移动向量在
- 服务端不加载:模组声明为
dist = Dist.CLIENT,mixin 配置也只在客户端生效,不新增任何服务端内容。

