bl4ckscor3 / Sit

A Minecraft mod that lets you sit on slabs and stairs.
https://www.curseforge.com/minecraft/mc-mods/sit
MIT License
20 stars 9 forks source link

Sitting while in sneak mode can drop you through the floor #3

Closed Laike-Endaril closed 3 years ago

Laike-Endaril commented 5 years ago
  1. Stand on top of a (bottom-half) slab
  2. Face straight down
  3. Hold sneak
  4. 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).

bl4ckscor3 commented 5 years ago

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).

Laike-Endaril commented 5 years ago

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

Barteks2x commented 5 years ago

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?)

bl4ckscor3 commented 5 years ago

How would such a detection look? I don't want to have to check multiple block states at possible positions just for this.

Laike-Endaril commented 5 years ago

Another possible option:

  1. Let MC position the player on unmount, like it's doing now, and then immediately do a check...
  2. 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

Barteks2x commented 5 years ago

Doung a few extra blockstate checks here https://github.com/bl4ckscor3/Sit/blob/f2635dcaa26328e62e57f81303df014a6bc47c04/src/main/java/bl4ckscor3/mod/sit/SitHandler.java#L35-L40 definitely wouldn't hurt anything. Even some simplified checks for the currently known issues, not exhaustive search for all the possible unsafe situations would be a huge improvement.

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.

Thunder-Nova commented 4 years ago

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.

FallenAvatar commented 3 years ago

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 ;)

K0-RR commented 3 years ago

Huh, I can't reproduce this. Simply can't sit on a slab when the shift is being held.

bl4ckscor3 commented 3 years ago

You're right. I will publish an update tomorrow that will not allow the player to sit when they sneak-rightclick, as there is another bug associated with not doing so.