aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower/net/minecraft/server/players/SleepStatus.java.patch
diff options
context:
space:
mode:
authorMiniDigger | Martin <[email protected]>2024-01-14 11:04:49 +0100
committerMiniDigger | Martin <[email protected]>2024-01-14 11:04:49 +0100
commitbee74680e607c2e29b038329f62181238911cd83 (patch)
tree708fd1a4a0227d9071243adf2a42d5e9e96cde4a /patch-remap/mache-vineflower/net/minecraft/server/players/SleepStatus.java.patch
parent0a44692ef6ff6e255d48eb3ba1bb114166eafda9 (diff)
downloadPaper-bee74680e607c2e29b038329f62181238911cd83.tar.gz
Paper-bee74680e607c2e29b038329f62181238911cd83.zip
add remapped patches as a testsoftspoon
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/server/players/SleepStatus.java.patch')
-rw-r--r--patch-remap/mache-vineflower/net/minecraft/server/players/SleepStatus.java.patch76
1 files changed, 76 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/server/players/SleepStatus.java.patch b/patch-remap/mache-vineflower/net/minecraft/server/players/SleepStatus.java.patch
new file mode 100644
index 0000000000..3c9f6b9baf
--- /dev/null
+++ b/patch-remap/mache-vineflower/net/minecraft/server/players/SleepStatus.java.patch
@@ -0,0 +1,76 @@
+--- a/net/minecraft/server/players/SleepStatus.java
++++ b/net/minecraft/server/players/SleepStatus.java
+@@ -1,25 +1,33 @@
+ package net.minecraft.server.players;
+
++import java.util.Iterator;
+ import java.util.List;
+ import net.minecraft.server.level.ServerPlayer;
+ import net.minecraft.util.Mth;
+ import net.minecraft.world.entity.player.Player;
+
+ public class SleepStatus {
++
+ private int activePlayers;
+ private int sleepingPlayers;
+
++ public SleepStatus() {}
++
+ public boolean areEnoughSleeping(int requiredSleepPercentage) {
+ return this.sleepingPlayers >= this.sleepersNeeded(requiredSleepPercentage);
+ }
+
+ public boolean areEnoughDeepSleeping(int requiredSleepPercentage, List<ServerPlayer> sleepingPlayers) {
+- int i = (int)sleepingPlayers.stream().filter(Player::isSleepingLongEnough).count();
+- return i >= this.sleepersNeeded(requiredSleepPercentage);
++ // CraftBukkit start
++ int j = (int) sleepingPlayers.stream().filter((eh) -> { return eh.isSleepingLongEnough() || eh.fauxSleeping; }).count();
++ boolean anyDeepSleep = sleepingPlayers.stream().anyMatch(Player::isSleepingLongEnough);
++
++ return anyDeepSleep && j >= this.sleepersNeeded(requiredSleepPercentage);
++ // CraftBukkit end
+ }
+
+ public int sleepersNeeded(int requiredSleepPercentage) {
+- return Math.max(1, Mth.ceil((float)(this.activePlayers * requiredSleepPercentage) / 100.0F));
++ return Math.max(1, Mth.ceil((float) (this.activePlayers * requiredSleepPercentage) / 100.0F));
+ }
+
+ public void removeAllSleepers() {
+@@ -32,19 +40,29 @@
+
+ public boolean update(List<ServerPlayer> players) {
+ int i = this.activePlayers;
+- int i1 = this.sleepingPlayers;
++ int j = this.sleepingPlayers;
++
+ this.activePlayers = 0;
+ this.sleepingPlayers = 0;
++ Iterator iterator = players.iterator();
++ boolean anySleep = false; // CraftBukkit
+
+- for (ServerPlayer serverPlayer : players) {
+- if (!serverPlayer.isSpectator()) {
+- this.activePlayers++;
+- if (serverPlayer.isSleeping()) {
+- this.sleepingPlayers++;
++ while (iterator.hasNext()) {
++ ServerPlayer entityplayer = (ServerPlayer) iterator.next();
++
++ if (!entityplayer.isSpectator()) {
++ ++this.activePlayers;
++ if (entityplayer.isSleeping() || entityplayer.fauxSleeping) { // CraftBukkit
++ ++this.sleepingPlayers;
+ }
++ // CraftBukkit start
++ if (entityplayer.isSleeping()) {
++ anySleep = true;
++ }
++ // CraftBukkit end
+ }
+ }
+
+- return (i1 > 0 || this.sleepingPlayers > 0) && (i != this.activePlayers || i1 != this.sleepingPlayers);
++ return anySleep && (j > 0 || this.sleepingPlayers > 0) && (i != this.activePlayers || j != this.sleepingPlayers); // CraftBukkit
+ }
+ }