From bee74680e607c2e29b038329f62181238911cd83 Mon Sep 17 00:00:00 2001 From: MiniDigger | Martin Date: Sun, 14 Jan 2024 11:04:49 +0100 Subject: add remapped patches as a test --- .../server/players/SleepStatus.java.patch | 76 ++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 patch-remap/mache-vineflower/net/minecraft/server/players/SleepStatus.java.patch (limited to 'patch-remap/mache-vineflower/net/minecraft/server/players/SleepStatus.java.patch') 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 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 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 + } + } -- cgit v1.2.3