[suggestion] environmentDetector.canSleep()
Quezler opened this issue ยท 0 comments
Describe your idea
A built-in method for the Environment Detector to check when a player is allowed to sleep.
Describe alternatives you've considered if you've any
Lua equivalent (that i'm currently using), accurate-ish, some > might need to be >= and vice versa:
-- https://minecraft.fandom.com/wiki/Bed#Sleeping
function can_sleep(day_ticks)
-- maybe check for nether/end dimension? (though honestly, why even check for sleep in those dims?)
if detector.isThunder() then
return true
end
if detector.isRaining() then
return day_ticks > 12010 and 23991 > day_ticks
end
return day_ticks > 12542 and 23459 > day_ticks
end
As you can see it already uses two of the detector methods, so imo the overlap makes it a nice candidate to be added.
Additional context
Nothing much, i merely used this to make a slide-out bed with Create that's accessible while players can sleep in beds.
Linked Issues
No response