Skip to content

Commit

Permalink
Update hunger.go
Browse files Browse the repository at this point in the history
  • Loading branch information
CJMustard1452 authored Jul 24, 2024
1 parent e0610de commit 3b298a6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions server/player/hunger.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ func (m *hungerManager) Food() int {
// SetFood sets the food level of a player. The level passed must be in a range of 0-20. If the level passed
// is negative, the food level will be set to 0. If the level exceeds 20, the food level will be set to 20.
func (m *hungerManager) SetFood(level int) {
m.mu.Lock()
defer m.mu.Unlock()

if level < 0 {
level = 0
} else if level > 20 {
level = 20
}
m.mu.Lock()
defer m.mu.Unlock()
m.foodLevel = level
}

Expand Down

0 comments on commit 3b298a6

Please sign in to comment.