Sitting while in sneak mode can drop you through the floor
Laike-Endaril opened this issue ยท 10 comments
- Stand on top of a (bottom-half) slab
- Face straight down
- Hold sneak
- Right click to sit (while still holding sneak)
This will cause you to sit, and then immediately stop sitting. You will go through the floor...sometimes. Unsure of exact qualifications, but could reproduce fairly often in a dedicated test (no other mods).
I'm assuming the surrounding blocks of the slab are also slabs. There's nothing I can do to prevent that, because even when sitting down without holding sneak and then standing up in that configuration, you will fall through the floor. The code to determine where to place the player when they stop sitting is on Minecraft's side (same one as for Minecarts and Horses).
Ah, makes sense. In this case, it was a single slab in the air (and therefore the only place to put the player upon no-longer-sitting).
Well, if you can catch the unmount event, you might be able to offset the player position up one half block (teleport), but that may in turn cause one tick of suffocation in a 2-block-high area. Not sure.
In any case, not completely game breaking or anything...so long as it's not above lava/the void :P
Doung a few extra blockstate checks here
Sit/src/main/java/bl4ckscor3/mod/sit/SitHandler.java
Lines 35 to 40 in f2635dc
I don't want to have to check multiple block states at possible positions just for this.
I don't see any reason to avoid that. This code is called relatively infrequently, and only on user interaction, so even a few hundred block accesses won't hurt performance. Sure, players could abuse it and spam right click to lag the server a little bit... but it's also trivial to cause way bigger issues with just a bit of redstone so I don't consider that an issue.
Another possible option:
- Let MC position the player on unmount, like it's doing now, and then immediately do a check...
- If the player's feet (their block position) is a collidable block, check their head position (up one) and the position above that (up 2). If both are non-collidable, move the player up 1 block. Otherwise, leave them where they are
Very minimal checks, and never makes any situation worse than it currently is...except in extreme edge cases where you have exposed lava held 2 blocks high via signs, with the top of a half slab on the ground being 1.5 blocks down from the bottom of the lava, maybe...
In any case, I think it would solve most "reasonable" placement issues. If you wanted to go one step further, then after the "one block up" check fails, you'd move on to "one block East", "one block North", etc. Probably wouldn't want to adjust position more than a certain amount though if you did this
How would such a detection look? I don't want to have to check multiple block states at possible positions just for this.
Would it be possible to at least prevent sitting in such unsafe configuration in the first place? It should be possible to predict when the vanilla code would place the player in an unsafe place, and disallow sitting there (maybe with a configuration option?)
Having a floor of but slabs (usually since it can prevent mob spawning) it does get annoying to be push under the floor... I imagine what it will do if people were on a skyblock type modpack... yikes...
I would suggest that when standing, the player will stand on top when it comes to slabs.
Yet this bug could be useful to make secret entrances.
Perhaps to make the key for going under CTRL+Shift to go under the slab.
I simply want to add that a similar bug happen when sitting in front of a path block. Totally not game breaking, just wanted it reported ;)
Huh, I can't reproduce this. Simply can't sit on a slab when the shift is being held.