Bed obstruction checks are unlike Minecraft #785

Closed
opened 2020-07-19 19:40:21 +02:00 by ryvnf · 17 comments
Contributor

In MineClone 2 you cannot use a bed that does not have two air blocks above it. This greatly limits what people can build. It is for example not possible to build usable bunk beds, and it is impossible to have a usable bed in a house that is not 3 blocks tall on the inside. This annoying limitation does not exist in Minecraft.

I will attempt to make a fix for this later, which clones the Minecraft behavior as described here on the Minecraft wiki:

When choosing where the respawn the player, the northwesternmost (lowest X- and
Z-coordinates) location of the seven adjacent to the head of the bed is chosen
first. If this location is obstructed, the next choice is to its south (+Z),
rather than the east (+X). Only when all seven locations around the head are
obstructed are the three remaining ones adjacent to the foot then to be
considered.

For a location to be unobstructed, the block at the level of the bed must be air
or non-solid (e.g. torches, but not glass) and there must be a space with a
solid block below it and two non-colliding blocks for the player to stand in 0-2
blocks below the bed. It does not matter if the bed itself has blocks above it.
The bed never spawns the player on or directly below itself even if all other
locations are obstructed. If a bed is obstructed, the player's spawnpoint is
cleared after they respawn. That is, even if the bed is subsequently made usable
again, the player continues to respawn at the world spawn until interacting with
the bed again.

In MineClone 2 you cannot use a bed that does not have two air blocks above it. This greatly limits what people can build. It is for example not possible to build usable bunk beds, and it is impossible to have a usable bed in a house that is not 3 blocks tall on the inside. This annoying limitation does not exist in Minecraft. I will attempt to make a fix for this later, which clones the Minecraft behavior as described [here](https://minecraft.gamepedia.com/Bed#Setting_the_spawn_point) on the Minecraft wiki: > When choosing where the respawn the player, the northwesternmost (lowest X- and > Z-coordinates) location of the seven adjacent to the head of the bed is chosen > first. If this location is obstructed, the next choice is to its south (+Z), > rather than the east (+X). Only when all seven locations around the head are > obstructed are the three remaining ones adjacent to the foot then to be > considered. > > For a location to be unobstructed, the block at the level of the bed must be air > or non-solid (e.g. torches, but not glass) and there must be a space with a > solid block below it and two non-colliding blocks for the player to stand in 0-2 > blocks below the bed. It does not matter if the bed itself has blocks above it. > The bed never spawns the player on or directly below itself even if all other > locations are obstructed. If a bed is obstructed, the player's spawnpoint is > cleared after they respawn. That is, even if the bed is subsequently made usable > again, the player continues to respawn at the world spawn until interacting with > the bed again.
Contributor

If we speak about beds I'd like to add a reference to Wuzzy/MineClone2#765 as well. Btw I almost realized how it works but unsure for myself, to start fixing it or better wait for more eperienced developer

If we speak about beds I'd like to add a reference to https://git.minetest.land/Wuzzy/MineClone2/issues/765 as well. Btw I almost realized how it works but unsure for myself, to start fixing it or better wait for more eperienced developer
Contributor

Yeah, 2 block-tall houses should be fine for beds. I ended up digging a 2x1 hole in the floor and place the bed in it, so I can keep my house the height I built it initially. It makes the bed look a bit weird, but at least I could use it after that. I hope this will be tweaked.

Yeah, 2 block-tall houses should be fine for beds. I ended up digging a 2x1 hole in the floor and place the bed in it, so I can keep my house the height I built it initially. It makes the bed look a bit weird, but at least I could use it after that. I hope this will be tweaked.
Contributor

I dont upvote for the moment only for the reason that I saw many bugs in original java-version of MC in many versions, when you stand up from the bed without as much space around: eg. find your head in stone block, or you cant move unless dont break something, or you teleport 3-4 nodes away from your bed, etc... So I supposed the limitations of Minetest/Mineclone2 aren't as bad if we want to avoid some bugs by design... But of course it would be not bad, if it would ever possible

I dont upvote for the moment only for the reason that I saw many bugs in original java-version of MC in many versions, when you stand up from the bed without as much space around: eg. find your head in stone block, or you cant move unless dont break something, or you teleport 3-4 nodes away from your bed, etc... So I supposed the limitations of Minetest/Mineclone2 aren't as bad if we want to avoid some bugs by design... But of course it would be not bad, if it would ever possible
Author
Contributor

@kay27 if you want to have a go at fixing this you can go ahead. I haven't even started yet myself and haven't worked on beds before. But please let me know if you decide against doing it, so I can attempt to solve it then.

@kay27 if you want to have a go at fixing this you can go ahead. I haven't even started yet myself and haven't worked on beds before. But please let me know if you decide against doing it, so I can attempt to solve it then.
Member

The reason why I added the restriction because I wanted to avoid that the player gets stuck with the head inside a solid node when leaving the bed and suffocating.

This restriction could be lifted if the checks you describe are applied.

The reason why I added the restriction because I wanted to avoid that the player gets stuck with the head inside a solid node when leaving the bed and suffocating. This restriction could be lifted if the checks you describe are applied.
Wuzzy added the
nodes
#P6: low
missing feature
labels 2020-07-23 21:04:51 +02:00

You may want to take a look at Minecraft's latest snapshot, which came with an improvement to how players are placed from beds (tries to place them around).

You may want to take a look at Minecraft's latest snapshot, which came with an improvement to how players are placed from beds (tries to place them around).
Contributor

I think it might be safely done right now for all cases but respawn. During respawn you suppose to appear right in the bed, awaken. And it happens like 1:51:20 in this video if you'd take a look: https://youtu.be/KP_a_i-Qk-g

The easiest I can do is to set spawn point not to bed but to the place you stayed before going to sleep.

I think it might be safely done right now for all cases but respawn. During respawn you suppose to appear right in the bed, awaken. And it happens like 1:51:20 in this video if you'd take a look: https://youtu.be/KP_a_i-Qk-g The easiest I can do is to set spawn point not to bed but to the place you stayed before going to sleep.
Contributor

Here I had a clear path to my bed, I got as close as possible to the block that I placed my bed on, but it looks like it didn't like that I was not on the same level as the bed.

Screenshot

I don't know why you have to be extremely close to the bed, when this looks close enough to be able to use it. What could the drawbacks possibly be that you have to be restricted from sleeping if you're not closer?

Here I had a clear path to my bed, I got as close as possible to the block that I placed my bed on, but it looks like it didn't like that I was not on the same level as the bed. ![Screenshot](https://i.imgur.com/AN8PDdt.png) I don't know why you have to be extremely close to the bed, when this looks close enough to be able to use it. What could the drawbacks possibly be that you have to be restricted from sleeping if you're not closer?
Contributor

Fixed all listed above

7bbb7438ae

Please feel free to write if find something's wrong, for reopening

Fixed all listed above https://git.minetest.land/Wuzzy/MineClone2/commit/7bbb7438aefb30b12e4b998f6b40392e328f2f22 Please feel free to write if find something's wrong, for reopening
kay27 closed this issue 2020-09-08 16:18:12 +02:00

@kay27 it says your spawn bed is missing or blocked and respawns at world spawn if there isn't a bed at your spawn point (which there isn't if spawn point != bed pos)

@kay27 it says your spawn bed is missing or blocked and respawns at world spawn if there isn't a bed at your spawn point (which there isn't if spawn point != bed pos)
Contributor

@anon5 not exactly but thanks for reminding, I should check it too. World spawn point choice is important but its also important not to awake having the head in ceiling blocks and minimal height of 2 nodes for bed is important too. Actually Im not sure its a big problem to respawn at the same place when the bed is destroyed. Dont you know any minors excepting wiki mismatch? Place can become dangerous, right?

@anon5 not exactly but thanks for reminding, I should check it too. World spawn point choice is important but its also important not to awake having the head in ceiling blocks and minimal height of 2 nodes for bed is important too. Actually Im not sure its a big problem to respawn at the same place when the bed is destroyed. Dont you know any minors excepting wiki mismatch? Place can become dangerous, right?
Contributor

@anon5:

@kay27 it says your spawn bed is missing or blocked and respawns at world spawn if there isn't a bed at your spawn point (which there isn't if spawn point != bed pos)

Waiting for your further feedback thankfully,

daede2a183

@anon5: > @kay27 it says your spawn bed is missing or blocked and respawns at world spawn if there isn't a bed at your spawn point (which there isn't if spawn point != bed pos) Waiting for your further feedback thankfully, https://git.minetest.land/Wuzzy/MineClone2/commit/daede2a183ed3f36699c11935d199389e87c80a2

With the new checks I respawned on the roof of hut with a 2 block high interior.

With the new checks I respawned on the roof of hut with a 2 block high interior.

I think MineClone 2 should implement the same checks as mc.

I think MineClone 2 should implement the same checks as mc.
Contributor

I don't know it. According official MC wiki it searches by x and z axises but almost nothing said about y. But... you know what I mean: we can't just ignore it, if there is some space upper or lower that the bed position why not to take it? So my current algorithm just unspins the spiral from the center (where the bed placed) and for every x/z pair chechs the y availability in a sequence: 0, +1, -1, +2, -2, +3, -3, +4, -4. The sequence is defined here and can be easily changed: https://git.minetest.land/Wuzzy/MineClone2/src/branch/master/mods/PLAYER/mcl_spawn/init.lua#L128

So if we shrink it for eg. just set to {0, 1, -1, 2, -2} it will hopefully avoid teleporting you to the roof but may cause another problem as geting you out of the house :(

I really appreciate you feedback (thank you so much for it!) but still don't know what is the best way of searches. Hope you do? :) How MC handles the altitude? What I should change?

I don't know it. According official MC wiki it searches by x and z axises but almost nothing said about y. But... you know what I mean: we can't just ignore it, if there is some space upper or lower that the bed position why not to take it? So my current algorithm just unspins the spiral from the center (where the bed placed) and for every x/z pair chechs the y availability in a sequence: 0, +1, -1, +2, -2, +3, -3, +4, -4. The sequence is defined here and can be easily changed: https://git.minetest.land/Wuzzy/MineClone2/src/branch/master/mods/PLAYER/mcl_spawn/init.lua#L128 So if we shrink it for eg. just set to ```{0, 1, -1, 2, -2}``` it will hopefully avoid teleporting you to the roof but may cause another problem as geting you out of the house :( I really appreciate you feedback (thank you so much for it!) but still don't know what is the best way of searches. Hope you do? :) How MC handles the altitude? What I should change?
kay27 reopened this issue 2020-09-09 14:15:11 +02:00
Contributor

@anon5 I tested beds in Minecraft 1.16.2.

They behave not as described in wiki.

If you surround the bed by some blocks, just one layer, you appear at the world spawn point and find you personal spawn point erased even if you 'undig' the bed back - you'll need to click it again to set as respawn point back.

So 7 blocks from wiki seem to be outdated or wrong information... And it's no prob to repeat Minecraft's behavior... But we shouldn't just copy Minecraft, I'm thinking what to do

@anon5 I tested beds in Minecraft 1.16.2. They behave not as described in wiki. If you surround the bed by some blocks, just one layer, you appear at the world spawn point and find you personal spawn point erased even if you 'undig' the bed back - you'll need to click it again to set as respawn point back. So 7 blocks from wiki seem to be outdated or wrong information... And it's no prob to repeat Minecraft's behavior... But we shouldn't just copy Minecraft, I'm thinking what to do
Contributor

Let's please continue here: Wuzzy/MineClone2#833

Let's please continue here: https://git.minetest.land/Wuzzy/MineClone2/issues/833
kay27 closed this issue 2020-09-09 22:44:36 +02:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
6 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: VoxeLibre/VoxeLibre#785
No description provided.