Skip to content
This repository was archived by the owner on Dec 29, 2023. It is now read-only.

Commit f20dd87

Browse files
committed
Implement [PaperBin-????] Optimise WorldServer#everyoneDeeplySleeping
1 parent f372603 commit f20dd87

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ Titanium implements patches from other engines as well. **All credits go to the
205205
[Yatopia-0047] Smarter statistics ticking
206206
207207
[InsanePaper-269] Cache Chunk Coordinations
208+
209+
[PaperBin-????] Optimise WorldServer#everyoneDeeplySleeping
208210
```
209211

210212
## Contributing
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
From b1abadfae17d9045a98d9c940ed2ba5daa57b583 Mon Sep 17 00:00:00 2001
2+
From: Peridot <[email protected]>
3+
Date: Thu, 4 Aug 2022 00:34:23 +0200
4+
Subject: [PATCH] Implement [PaperBin-????] Optimise
5+
WorldServer#everyoneDeeplySleeping
6+
7+
8+
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
9+
index 111a25632..247c0ae3a 100644
10+
--- a/src/main/java/net/minecraft/server/EntityHuman.java
11+
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
12+
@@ -1781,6 +1781,16 @@ public abstract class EntityHuman extends EntityLiving {
13+
}
14+
}
15+
16+
+ // Titanium start
17+
+ public boolean isNether() {
18+
+ return this.world.getBiome(new BlockPosition(this.locX, this.locY, this.locZ)) == BiomeBase.HELL;
19+
+ }
20+
+
21+
+ public boolean isEnd() {
22+
+ return this.world.getBiome(new BlockPosition(this.locX, this.locY, this.locZ)) == BiomeBase.SKY;
23+
+ }
24+
+ // Titanium end
25+
+
26+
static class SyntheticClass_1 {
27+
28+
static final int[] a = new int[EnumDirection.values().length];
29+
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
30+
index 137c84a58..02c90ea85 100644
31+
--- a/src/main/java/net/minecraft/server/WorldServer.java
32+
+++ b/src/main/java/net/minecraft/server/WorldServer.java
33+
@@ -357,7 +357,25 @@ public class WorldServer extends World implements IAsyncTaskHandler {
34+
}
35+
36+
public boolean everyoneDeeplySleeping() {
37+
- if (this.O && !this.isClientSide) {
38+
+ // PaperBin start - WorldServer#everyoneDeeplySleeping optimization
39+
+ if (this.players.isEmpty() || this.isClientSide || !this.O) {
40+
+ return false;
41+
+ }
42+
+
43+
+ for (EntityHuman human : this.players) {
44+
+ if (!human.isSpectator() && !human.isDeeplySleeping() && !human.fauxSleeping) {
45+
+ return false;
46+
+ }
47+
+
48+
+ // Titanium start - ignore players who are not in overworld
49+
+ if (!human.isNether() && !human.isEnd()) {
50+
+ return false;
51+
+ }
52+
+ // Titanium end
53+
+ }
54+
+
55+
+ return true;
56+
+ /*if (this.O && !this.isClientSide) {
57+
Iterator iterator = this.players.iterator();
58+
59+
// CraftBukkit - This allows us to assume that some people are in bed but not really, allowing time to pass in spite of AFKers
60+
@@ -382,7 +400,8 @@ public class WorldServer extends World implements IAsyncTaskHandler {
61+
return false;
62+
} else {
63+
return false;
64+
- }
65+
+ }*/
66+
+ // PaperBin end
67+
}
68+
69+
protected void h() {
70+
--
71+
2.36.0.windows.1
72+

0 commit comments

Comments
 (0)