-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented beds #606
base: master
Are you sure you want to change the base?
Implemented beds #606
Conversation
…/explosions # Conflicts: # server/block/block.go # server/block/explosion.go
Co-authored-by: Raptor <t14raptor@gmail.com>
# Conflicts: # server/block/block.go # server/block/stone_bricks.go
Co-authored-by: DaPigGuy <mcpepig123@gmail.com>
# Conflicts: # server/session/entity_metadata.go
# Conflicts: # server/block/register.go # server/player/player.go # server/session/entity_metadata.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've left a couple of comments, some of which we already discussed in the VC.
w.SetBlock(pos, b, nil) | ||
} | ||
|
||
w.SetRequiredSleepDuration(time.Second * 5) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I fully understand why Player.Sleep()
sets this to 5 seconds and Player.Wake()
sets this to 0 seconds. Can this not just be something internal in World?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by "something internal"? You must be sleeping in a bed for at least 5 seconds before the day progresses, and that cool down gets reset back to 5 every time someone else starts to sleep.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean having only a (constant) required sleep duration in world's settings and updating/tracking how much longer must be slept inside of World automatically using an additional field, instead of having a SetRequiredSleepDuration
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That won't work though. The sleep duration is reset in vanilla if another player starts sleeping, or if a player stops and then starts sleeping. If you're suggesting we should make the default required sleep duration configurable via world settings, maybe, but that doesn't entirely make sense since vanilla doesn't support it anyway.
if t.w.set.RequiredSleepTicks > 0 { | ||
t.w.set.RequiredSleepTicks-- | ||
if t.w.set.RequiredSleepTicks-1 <= 0 { | ||
sleep = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would probably keep t.w.set.RequiredSleepTicks
static and just have a separate unexported field in World that you change. That way Player doesn't have to set the required sleep ticks to 5 seconds on sleep and 0 on wake, that can just be world internal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above conversation.
# Conflicts: # server/player/player.go # server/session/entity_metadata.go # server/session/handler_player_action.go # server/session/session.go # server/session/world.go
# Conflicts: # server/player/player.go # server/session/entity_metadata.go # server/session/handler_player_action.go
|
||
sidePos := pos.Side(face) | ||
o, ok := w.Block(sidePos).(Bed) | ||
return o, sidePos, ok |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably check that only one side is the head
return o, sidePos, ok | |
return o, sidePos, ok && b.Head != o.Head |
|
||
w := p.World() | ||
if b, ok := w.Block(pos).(block.Bed); ok { | ||
if b.User != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if b.User != nil { | |
if b.User != nil || !b.Head { |
if sl, ok := e.(sleeper); ok { | ||
if pos, ok := sl.Sleeping(); ok { | ||
m[protocol.EntityDataKeyBedPosition] = blockPosToProtocol(pos) | ||
m.SetFlag(protocol.EntityDataKeyPlayerFlags, protocol.EntityDataFlagSleeping) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protocol.EntityDataFlagSleeping
was wrongly used here when merging changes from master branch
@@ -733,6 +743,8 @@ func (w *World) RemoveEntity(e Entity) { | |||
viewers := slices.Clone(c.v) | |||
c.Unlock() | |||
|
|||
w.tryAdvanceDay() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would bypass the 5 second timer if any entity were to be removed.
No description provided.