From ec3597979c029746555dfd5c0e5c101804229668 Mon Sep 17 00:00:00 2001 From: liach <7806504+liach@users.noreply.github.com> Date: Sat, 27 Feb 2021 04:56:42 -0600 Subject: [PATCH] Map the new SleepManager (#2087) * zzz Signed-off-by: liach * Fixed some bad stuff and more docs Signed-off-by: liach Co-authored-by: liach --- .../server/world/ServerWorld.mapping | 1 + .../server/world/SleepManager.mapping | 41 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 mappings/net/minecraft/server/world/SleepManager.mapping diff --git a/mappings/net/minecraft/server/world/ServerWorld.mapping b/mappings/net/minecraft/server/world/ServerWorld.mapping index b7b3e52cd6..dae99cd99d 100644 --- a/mappings/net/minecraft/server/world/ServerWorld.mapping +++ b/mappings/net/minecraft/server/world/ServerWorld.mapping @@ -21,6 +21,7 @@ CLASS net/minecraft/class_3218 net/minecraft/server/world/ServerWorld FIELD field_26933 dragonParts Lit/unimi/dsi/fastutil/ints/Int2ObjectMap; FIELD field_26934 entityList Lnet/minecraft/class_5574; FIELD field_26935 entityManager Lnet/minecraft/class_5579; + FIELD field_28859 sleepManager Lnet/minecraft/class_5838; METHOD (Lnet/minecraft/server/MinecraftServer;Ljava/util/concurrent/Executor;Lnet/minecraft/class_32$class_5143;Lnet/minecraft/class_5268;Lnet/minecraft/class_5321;Lnet/minecraft/class_2874;Lnet/minecraft/class_3949;Lnet/minecraft/class_2794;ZJLjava/util/List;Z)V ARG 1 server ARG 2 workerExecutor diff --git a/mappings/net/minecraft/server/world/SleepManager.mapping b/mappings/net/minecraft/server/world/SleepManager.mapping new file mode 100644 index 0000000000..3752e9d19e --- /dev/null +++ b/mappings/net/minecraft/server/world/SleepManager.mapping @@ -0,0 +1,41 @@ +CLASS net/minecraft/class_5838 net/minecraft/server/world/SleepManager + COMMENT A sleep manager allows easy tracking of whether nights should be skipped + COMMENT on a {@linkplain ServerWorld server world}. + FIELD field_28866 total I + COMMENT The total number of players in a server world. + FIELD field_28867 sleeping I + COMMENT The number of players sleeping in a server world. + METHOD method_33811 clearSleeping ()V + COMMENT Resets the number of sleeping players to 0. + METHOD method_33812 canSkipNight (I)Z + COMMENT Returns if the number of sleeping players has reached a {@code percentage} + COMMENT out of all players. + COMMENT + COMMENT

This allows initiating the night sleeping process, + COMMENT but still needs players to have slept long enough (checked in {@linkplain + COMMENT #canResetTime(int, List) canResetTime}) to actually skip the night. + ARG 1 percentage + COMMENT the percentage of players required, as obtained from the game rule + METHOD method_33813 canResetTime (ILjava/util/List;)Z + COMMENT Returns if the night can actually be skipped at the tick this is called. + COMMENT + COMMENT

This is usually tested after {@linkplain #canSkipNight(int} canSkipNight}, + COMMENT which is less performance intensive to check. + ARG 1 percentage + COMMENT the percentage of players required, as obtained from the game rule + ARG 2 players + COMMENT the list of all players in a world where the night would be skipped + METHOD method_33814 update (Ljava/util/List;)Z + COMMENT Updates the sleeping player and total player counts. + COMMENT + COMMENT @return {@code true} if the sleeping players or total players have + COMMENT changed + ARG 1 players + COMMENT the list of all players in a server world + METHOD method_33815 getSleeping ()I + COMMENT Returns the number of sleeping players. + METHOD method_33816 getNightSkippingRequirement (I)I + COMMENT Returns {@linkplain #sleeping the number of sleepers} needed to skip + COMMENT a night with the given {@code percentage}. + ARG 1 percentage + COMMENT the percentage of players required, as obtained from the game rule