-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(multiplayer sleep) Option to round up instead. #8
Comments
it is calculated in the fittingly named you could of course always just add 1 to required players after line 11, but that means that you'd also "round up" if there is nothing to round (2 players with 100% would then need 3 players). So, to enable you to round up, you'd have to check whether the division by 100 would turn out with a rest after the division. i threw this thing together real quick execute store result score @s multSleep.tmp if entity @a[nbt={Dimension:0}]
scoreboard players operation totalPlayers multSleep.count = @s multSleep.tmp
execute store result score @s multSleep.tmp if entity @a[scores={multSleep.count=99..}]
scoreboard players operation sleepingPlayers multSleep.count = @s multSleep.tmp
scoreboard players operation requiredPlayers multSleep.count = totalPlayers multSleep.count
scoreboard players operation #roundup multSleep.tmp = totalPlayers multSleep.count
scoreboard players operation #roundup multSleep.tmp *= requiredPercent multSleep.count
scoreboard players operation #roundup multSleep.tmp %= #100 multSleep.count
scoreboard players operation requiredPlayers multSleep.count *= requiredPercent multSleep.count
scoreboard players operation requiredPlayers multSleep.count /= #100 multSleep.count
execute if score #roundup multSleep.tmp matches 1.. run scoreboard players add requiredPlayers multSleep.count 1
scoreboard players operation requiredPlayers multSleep.count -= sleepingPlayers multSleep.count
scoreboard players operation @s multSleep.tmp = requiredPlayers multSleep.count |
Tried this for minecraft 1.15 and it does not seem to be working. |
@FredrikM97 sorry for the late reply, but what part of this isn't working? I'll need some more info than just "it isn't working". Are you using the roundup code I provided or are you referring to something else? Does it not produce the correct amount of people that it should? And if so, too little or too many? Does it break entirely and doesn't produce anything anymore? |
Tried to use the round up code but the datapack stops working (probobly being disabled by the server) in minecraft 1.15. Could potentially be a crash? |
no, the server doesn't just disable a datapack, at worst it disables a faulty function. Are you on a vanilla server or a third party one (spigot/bukkit/paper/etc)? because I just did some testing and it works exactly as expected for me on a vanilla server in 1.15.2 |
Would it be possible to create an option or a version of the data pack where the amount of players required to sleep is rounded up instead of down?
I tried to make the change myself, but i have a hard time wrapping my head around how data packs work, so pointing me towards the point where the rounding actually takes place, would be appreciated as well.
The text was updated successfully, but these errors were encountered: