Dusk[Forge/Fabric]

Dusk[Forge/Fabric]

7M Downloads

[Bug]: Dusk is incompatible with mod that allow sleeping at day

Cheaterpaul opened this issue ยท 1 comments

commented

Describe the bug you're experiencing

Correct sleep event

Your sleep time check should be done in the appropriated event.

public static void onPlayerSleep(PlayerSleepInBedEvent event)
{
if (event.isCanceled())
{
return;
}
if (Dusk.config.getCommonConfig().disableSleep.get() || (event.getEntity().level().getDayTime() % 24000) < Dusk.config.getCommonConfig().minSleepTime.get())
{
event.setResult(Player.BedSleepingProblem.NOT_POSSIBLE_NOW);
event.setCanceled(true);
}
if (event.getEntity().level().isClientSide())
{
return;
}
((ServerPlayer) event.getEntity()).setRespawnPosition(event.getEntity().level().dimension(), event.getPos(), event.getEntity().getYRot(), false, true);

The PlayerSleepInBedEvent is not supposed to check the sleep time. For that there is the dedicated SleepingTimeCheckEvent. This way your sleep time is compatible with other mods.

Besides the time check (event.getEntity().level().getDayTime() % 24000) < Dusk.config.getCommonConfig().minSleepTime.get() the rest is fine in the PlayerSleepInBedEvent event

Problem with sleeping time

I do not know if this is intended or overlooked, but some mods allow player to sleep at day, which is completely ignored by this mod. I do not know how this should be solved correctly, maybe you have an idea.

Reproducability

^^

Mod up to date

  • Before submitting this issue I updated to the newest version and reproduced it

Minecraft version

1.20.1

Modloader version

Forge

Logs

source code

commented

Its simple to solve, if you want to allow day sleeping just move the minimum day time in the config to an earlier point, 0 to disable^^
Changed the even in 3.3