Class StevesRealisticSleepApi

java.lang.Object
io.github.steveplays28.stevesrealisticsleep.api.StevesRealisticSleepApi

public class StevesRealisticSleepApi extends Object
Realistic Sleep's API. This class contains methods and ways to grab information from Realistic Sleep that may be useful to other mods.
  • Constructor Details

    • StevesRealisticSleepApi

      public StevesRealisticSleepApi()
  • Method Details

    • getSleepProgress

      public static float getSleepProgress(@NotNull @NotNull net.minecraft.world.level.Level level)
      Parameters:
      level - The level (aka dimension)
      Returns:
      The sleep progress of the level as a percentage.
      Since:
      v1.8.4
    • getTimeOfDay

      public static int getTimeOfDay(@NotNull @NotNull net.minecraft.world.level.Level level)
      Parameters:
      level - The level (aka dimension)
      Returns:
      The time of day of the level in ticks, with the day count filtered out using a modulo operator. This means that when Minecraft returns the time of day of a level, the day count doesn't have any effect on the resulting time. Equal to (int) level.getLevelData().getDayTime() % DAY_LENGTH.
      Since:
      v1.8.4
    • isSleeping

      public static boolean isSleeping(@NotNull @NotNull net.minecraft.world.level.Level level)
      Parameters:
      level - The level (aka dimension)
      Returns:
      Whether players are sleeping in this world (time is passing at an accelerated rate). The level will be casted to either a ServerLevel or ClientLevel depending on the side this method is called from. Prefer the sides' respective API methods instead.
    • isSleeping

      public static boolean isSleeping(@NotNull @NotNull net.minecraft.client.multiplayer.ClientLevel level)
      Parameters:
      level - The clientside level (aka dimension)
      Returns:
      Whether players are sleeping in this level (time is passing at an accelerated rate).
    • isSleeping

      public static boolean isSleeping(@NotNull @NotNull net.minecraft.server.level.ServerLevel level)
      Parameters:
      level - The serverside level (aka dimension)
      Returns:
      Whether players are sleeping in this level (time is passing at an accelerated rate).
    • getConsecutiveSleepTicks

      public static int getConsecutiveSleepTicks(net.minecraft.server.level.ServerLevel level)
      Parameters:
      level - The serverside level (aka dimension)
      Returns:
      The consecutive amount of sleep ticks. Returns 0 when no players are sleeping.