Skip to content

implement beds , respawn anchors #938

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

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open

implement beds , respawn anchors #938

wants to merge 31 commits into from

Conversation

FDUTCH
Copy link
Contributor

@FDUTCH FDUTCH commented Nov 17, 2024

No description provided.

Copy link
Member

@TwistedAsylumMC TwistedAsylumMC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed a few problems after a quick look

Copy link
Member

@TwistedAsylumMC TwistedAsylumMC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still a few of my previous comments that have not been addressed, found some more issues after another look through

Comment on lines 238 to 242
// SpawnBlock represents a block using which player can set his spawn point.
type SpawnBlock interface {
SpawnBlock() bool
Update(pos cube.Pos, u item.User, w *world.World)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use proper grammer in the docs and also document the methods of the interface. Update is a very ambiguous name and doesn't hint towards being related to spawn points

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have changed the method name but the documentation is still needing to be updated

Copy link
Member

@TwistedAsylumMC TwistedAsylumMC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have had another look, there are still unresolved comments that I have previously provided. I am not going to review this PR anymore until every single comment has been acted on or you've replied with a valid counter argument. I have gone through and resolved all the comments you have addressed but there are still many that remain

@DaPigGuy
Copy link
Member

Please fix merge conflicts

@FDUTCH
Copy link
Contributor Author

FDUTCH commented Dec 1, 2024

Please fix merge conflicts

bro , I'm dead ☠️
I don't know how to resolve merge conflict

# Conflicts:
#	server/player/handler.go
#	server/player/player.go
#	server/session/session.go
#	server/world/tick.go
#	server/world/world.go
@DaPigGuy DaPigGuy mentioned this pull request Dec 15, 2024
89 tasks
@DaPigGuy DaPigGuy requested review from Sandertv and removed request for DaPigGuy December 16, 2024 07:11
Copy link
Contributor

@xNatsuri xNatsuri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

most of the pr looks good just from a quick glance saw this issue

# Conflicts:
#	server/player/player.go
#	server/session/session.go
@FDUTCH FDUTCH requested a review from DaPigGuy December 23, 2024 15:38
@DaPigGuy DaPigGuy added the feature New feature or request label Dec 29, 2024
@DaPigGuy DaPigGuy added this to the v0.11.0 milestone Jan 4, 2025
type RespawnAnchor struct {
solid
bassDrum
Charge int
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document this

@FDUTCH
Copy link
Contributor Author

FDUTCH commented Jan 13, 2025

after making Bed.Sleeper as *world.EntityHandle appeared dead locks when placing, breaking and sleeping

This reverts commit 737c961.

I'm stupid
Copy link
Member

@TwistedAsylumMC TwistedAsylumMC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have had another look over and found some inconsistencies with your implementation compared to vanilla, or at least what is documented on the wiki. If any of this is incorrect for Bedrock then I am happy to ignore those. There are also still multiple unresolved comments that myself and @DaPigGuy have left previously, please make sure you scroll through https://github.com/df-mc/dragonfly/pull/938/files and look at any unresolved comment and either make the requested changes or reply with a counter reason


sleeper := headSide.Sleeper
if sleeper != nil {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary whitespace

// MaxCount returns the maximum number of items that a stack may be composed of. The number returned must
// MaxCount returns the maximum number of items a stack may be composed of. The number returned must
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is irrelevant, please remove it

// Sleep makes the player sleep at the given position. If the position does not map to a bed (specifically the head side),
// the player will not sleep.
func (p *Player) Sleep(pos cube.Pos) {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary whitespace

b.Sleeper = p.H()
tx.SetBlock(pos, b, nil)

tx.World().SetRequiredSleepDuration(time.Second * 5)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be time.Millisecond * 5050

A player sleeps in a bed for 101 in-game ticks, or 5.05 seconds before the time skips to the next day.

}

time := w.Time() % world.TimeFull
if (time < world.TimeNight || time >= world.TimeSunrise) && !tx.ThunderingAt(pos) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic does not match the behaviour documented on the wiki:

A player sleeps by using a bed during a thunderstorm, or at night (between 12542 and 23459 ticks in clear weather, when stars appear in the sky, or between 12010 and 23991 ticks in rainy weather). Players can sleep during a thunderstorm even if they are in a biome where it does not rain (i.e. desert)

Comment on lines +983 to +999
// spawnLocation returns position and world where player should be spawned.
func (p *Player) spawnLocation() (playerSpawn cube.Pos, w *world.World, spawnBlockBroken bool, previousDimension world.Dimension) {
tx := p.tx
w = tx.World()
previousDimension = w.Dimension()
playerSpawn = w.PlayerSpawn(p.UUID())
if b, ok := tx.Block(playerSpawn).(block.RespawnBlock); ok && b.CanRespawnOn() {
return playerSpawn, w, false, previousDimension
}

// We can use the principle here that returning through a portal of a specific dimension inside that dimension will
// always bring us back to the overworld.
w = w.PortalDestination(w.Dimension())
worldSpawn := w.Spawn()
return worldSpawn, w, playerSpawn != worldSpawn, previousDimension
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function does not return accurate spawn positions. block.RespawnBlock should have a method which returns the position where the player should respawn since it's not at the same place where the bed/respawn anchor is located.

https://minecraft.wiki/w/Bed#Setting_the_spawn_point
https://minecraft.wiki/w/Respawn_Anchor#Respawning

@cjmustard
Copy link
Contributor

@TwistedAsylumMC are these changes above all that need to be altered before this PR is ready for master?

I might be able to get these done relatively quickly

cjmustard added a commit to cjmustard/dragonfly that referenced this pull request Mar 1, 2025
cjmustard added a commit to cjmustard/dragonfly that referenced this pull request Mar 1, 2025
cjmustard added a commit to cjmustard/dragonfly that referenced this pull request Mar 1, 2025
cjmustard added a commit to cjmustard/dragonfly that referenced this pull request Mar 1, 2025
cjmustard added a commit to cjmustard/dragonfly that referenced this pull request Mar 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants