Skip to content

Commit

Permalink
Make sure player is on the floor when using its location for the slee…
Browse files Browse the repository at this point in the history
…ping bag (closes #76)
  • Loading branch information
lucaargolo committed Aug 14, 2021
1 parent 663406c commit 232ecbf
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ class SleepingBag(settings: Settings): Item(settings) {
val sleepingPos = rayTraceContext.run {
if(this.type == HitResult.Type.BLOCK) {
return@run BlockPos(this.pos)
}else{
}else if(player.isOnGround){
return@run player.blockPos
}else{
return@run null
}
}
if (player.isSleeping || !player.isAlive) {
Expand All @@ -55,7 +57,7 @@ class SleepingBag(settings: Settings): Item(settings) {
if (player.world.isDay) {
return Either.left(PlayerEntity.SleepFailureReason.NOT_POSSIBLE_NOW)
}
if (isSleepingBagObstructed(player.world, sleepingPos, player.horizontalFacing)) {
if (sleepingPos == null || isSleepingBagObstructed(player.world, sleepingPos, player.horizontalFacing)) {
return Either.left(PlayerEntity.SleepFailureReason.OBSTRUCTED)
}
if (!player.isCreative) {
Expand Down

0 comments on commit 232ecbf

Please sign in to comment.