Skip to content

Commit 3cbaf46

Browse files
committed
Revert "fix names & Bed.Head trouble"
This reverts commit 737c961. I'm stupid
1 parent 737c961 commit 3cbaf46

File tree

2 files changed

+23
-38
lines changed

2 files changed

+23
-38
lines changed

server/block/bed.go

+9-21
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ func (Bed) SideClosed(cube.Pos, cube.Pos, *world.Tx) bool {
4242

4343
// BreakInfo ...
4444
func (b Bed) BreakInfo() BreakInfo {
45-
return newBreakInfo(0.2, alwaysHarvestable, nothingEffective, oneOf(b)).withBreakHandler(func(pos cube.Pos, tx *world.Tx, _ item.User) {
46-
headSide, _, ok := b.head(pos, tx)
45+
return newBreakInfo(0.2, alwaysHarvestable, nothingEffective, oneOf(b)).withBreakHandler(func(pos cube.Pos, w *world.Tx, _ item.User) {
46+
headSide, _, ok := b.head(pos, w)
4747
if !ok {
4848
return
4949
}
@@ -201,8 +201,8 @@ func (b Bed) DecodeNBT(data map[string]interface{}) interface{} {
201201
}
202202

203203
// head returns the head side of the bed. If neither side is a head side, the third return value is false.
204-
func (b Bed) head(pos cube.Pos, tx *world.Tx) (Bed, cube.Pos, bool) {
205-
headSide, headPos, ok := b.side(pos, tx)
204+
func (b Bed) head(pos cube.Pos, w *world.Tx) (Bed, cube.Pos, bool) {
205+
headSide, headPos, ok := b.side(pos, w)
206206
if !ok {
207207
return Bed{}, cube.Pos{}, false
208208
}
@@ -213,14 +213,14 @@ func (b Bed) head(pos cube.Pos, tx *world.Tx) (Bed, cube.Pos, bool) {
213213
}
214214

215215
// side returns the other side of the bed. If the other side is not a bed, the third return value is false.
216-
func (b Bed) side(pos cube.Pos, tx *world.Tx) (Bed, cube.Pos, bool) {
216+
func (b Bed) side(pos cube.Pos, w *world.Tx) (Bed, cube.Pos, bool) {
217217
face := b.Facing.Face()
218218
if b.Head {
219219
face = face.Opposite()
220220
}
221221

222222
sidePos := pos.Side(face)
223-
o, ok := tx.Block(sidePos).(Bed)
223+
o, ok := w.Block(sidePos).(Bed)
224224
return o, sidePos, ok
225225
}
226226

@@ -237,19 +237,7 @@ func (Bed) CanRespawnOn() bool {
237237
return true
238238
}
239239

240-
func (Bed) RespawnOn(pos cube.Pos, u item.User, tx *world.Tx) {}
241-
242-
// SleepOn called to set Bed.Head if succeed startSleeping called.
243-
func (b Bed) SleepOn(pos cube.Pos, sleeper world.Sleeper, tx *world.Tx, startSleeping func() bool) {
244-
head, headPos, ok := b.head(pos, tx)
245-
if !ok {
246-
return
247-
}
248-
if startSleeping() {
249-
head.Sleeper = sleeper.H()
250-
tx.SetBlock(headPos, head, nil)
251-
}
252-
}
240+
func (Bed) RespawnOn(pos cube.Pos, u item.User, w *world.Tx) {}
253241

254242
// RespawnBlock represents a block using which player can set his spawn point.
255243
type RespawnBlock interface {
@@ -260,7 +248,7 @@ type RespawnBlock interface {
260248
}
261249

262250
// supportedFromBelow ...
263-
func supportedFromBelow(pos cube.Pos, tx *world.Tx) bool {
251+
func supportedFromBelow(pos cube.Pos, w *world.Tx) bool {
264252
below := pos.Side(cube.FaceDown)
265-
return tx.Block(below).Model().FaceSolid(below, cube.FaceUp, tx)
253+
return w.Block(below).Model().FaceSolid(below, cube.FaceUp, w)
266254
}

server/player/player.go

+14-17
Original file line numberDiff line numberDiff line change
@@ -1205,28 +1205,25 @@ func (p *Player) Sleep(pos cube.Pos) {
12051205
}
12061206

12071207
ctx, sendReminder := event.C(p), true
1208+
if p.Handler().HandleSleep(ctx, &sendReminder); ctx.Cancelled() {
1209+
return
1210+
}
12081211

1209-
b.SleepOn(pos, p, p.tx, func() bool {
1210-
if p.Handler().HandleSleep(ctx, &sendReminder); ctx.Cancelled() {
1211-
return false
1212-
}
1213-
1214-
p.sleeping = true
1215-
1216-
tx.World().SetRequiredSleepDuration(time.Second * 5)
1212+
b.Sleeper = p.H()
1213+
tx.SetBlock(pos, b, nil)
12171214

1218-
p.data.Pos = pos.Vec3Middle().Add(mgl64.Vec3{0, 0.5625})
1219-
p.sleepPos = pos
1215+
tx.World().SetRequiredSleepDuration(time.Second * 5)
12201216

1221-
if sendReminder {
1222-
tx.BroadcastSleepingReminder(p)
1223-
}
1217+
p.data.Pos = pos.Vec3Middle().Add(mgl64.Vec3{0, 0.5625})
1218+
p.sleeping = true
1219+
p.sleepPos = pos
12241220

1225-
tx.BroadcastSleepingIndicator()
1226-
p.updateState()
1227-
return true
1228-
})
1221+
if sendReminder {
1222+
tx.BroadcastSleepingReminder(p)
1223+
}
12291224

1225+
tx.BroadcastSleepingIndicator()
1226+
p.updateState()
12301227
}
12311228

12321229
// Wake forces the player out of bed if they are sleeping.

0 commit comments

Comments
 (0)