Package net.minecraft.server.world
Class SleepManager
java.lang.Object
net.minecraft.server.world.SleepManager
A sleep manager allows easy tracking of whether nights should be skipped
on a server world.
- Mappings:
Namespace Name named net/minecraft/server/world/SleepManagerintermediary net/minecraft/class_5838official auu
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanResetTime(int percentage, List<ServerPlayerEntity> players) Returns if the night can actually be skipped at the tick this is called.booleancanSkipNight(int percentage) Returns if the number of sleeping players has reached apercentageout of all players.voidResets the number of sleeping players to 0.intgetNightSkippingRequirement(int percentage) Returns the number of sleepers needed to skip a night with the givenpercentage.intReturns the number of sleeping players.booleanupdate(List<ServerPlayerEntity> players) Updates the sleeping player and total player counts.
-
Field Details
-
total
private int totalThe total number of players in a server world.- Mappings:
Namespace Name Mixin selector named totalLnet/minecraft/server/world/SleepManager;total:Iintermediary field_28866Lnet/minecraft/class_5838;field_28866:Iofficial aLauu;a:I
-
sleeping
private int sleepingThe number of players sleeping in a server world.- Mappings:
Namespace Name Mixin selector named sleepingLnet/minecraft/server/world/SleepManager;sleeping:Iintermediary field_28867Lnet/minecraft/class_5838;field_28867:Iofficial bLauu;b:I
-
-
Constructor Details
-
SleepManager
public SleepManager()
-
-
Method Details
-
canSkipNight
public boolean canSkipNight(int percentage) Returns if the number of sleeping players has reached apercentageout of all players.This allows initiating the night sleeping process, but still needs players to have slept long enough (checked in canResetTime) to actually skip the night.
- Parameters:
percentage- the percentage of players required, as obtained from the game rule- Mappings:
Namespace Name Mixin selector named canSkipNightLnet/minecraft/server/world/SleepManager;canSkipNight(I)Zintermediary method_33812Lnet/minecraft/class_5838;method_33812(I)Zofficial aLauu;a(I)Z
-
canResetTime
Returns if the night can actually be skipped at the tick this is called.This is usually tested after canSkipNight, which is less performance intensive to check.
- Parameters:
percentage- the percentage of players required, as obtained from the game ruleplayers- the list of all players in a world where the night would be skipped- Mappings:
Namespace Name Mixin selector named canResetTimeLnet/minecraft/server/world/SleepManager;canResetTime(ILjava/util/List;)Zintermediary method_33813Lnet/minecraft/class_5838;method_33813(ILjava/util/List;)Zofficial aLauu;a(ILjava/util/List;)Z
-
getNightSkippingRequirement
public int getNightSkippingRequirement(int percentage) Returns the number of sleepers needed to skip a night with the givenpercentage.- Parameters:
percentage- the percentage of players required, as obtained from the game rule- Mappings:
Namespace Name Mixin selector named getNightSkippingRequirementLnet/minecraft/server/world/SleepManager;getNightSkippingRequirement(I)Iintermediary method_33816Lnet/minecraft/class_5838;method_33816(I)Iofficial bLauu;b(I)I
-
clearSleeping
public void clearSleeping()Resets the number of sleeping players to 0.- Mappings:
Namespace Name Mixin selector named clearSleepingLnet/minecraft/server/world/SleepManager;clearSleeping()Vintermediary method_33811Lnet/minecraft/class_5838;method_33811()Vofficial aLauu;a()V
-
getSleeping
public int getSleeping()Returns the number of sleeping players.- Mappings:
Namespace Name Mixin selector named getSleepingLnet/minecraft/server/world/SleepManager;getSleeping()Iintermediary method_33815Lnet/minecraft/class_5838;method_33815()Iofficial bLauu;b()I
-
update
Updates the sleeping player and total player counts.- Parameters:
players- the list of all players in a server world- Returns:
trueif the sleeping players or total players have changed- Mappings:
Namespace Name Mixin selector named updateLnet/minecraft/server/world/SleepManager;update(Ljava/util/List;)Zintermediary method_33814Lnet/minecraft/class_5838;method_33814(Ljava/util/List;)Zofficial aLauu;a(Ljava/util/List;)Z
-