mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-26 02:19:19 +00:00
Sparkly and Polpot optimize
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: lilingfengdev <145678359+lilingfengdev@users.noreply.github.com>
|
||||
Date: Thu, 18 Jan 2024 13:14:57 +0800
|
||||
Subject: [PATCH] Polpot Cache-coordinate-key-used-for-nearby-players
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/util/player/NearbyPlayers.java b/src/main/java/io/papermc/paper/util/player/NearbyPlayers.java
|
||||
index 17ba07cbd4792f63d88ce29d00da280f30c4abff..98ae712c78d500e8c463aa671909a931a001407e 100644
|
||||
--- a/src/main/java/io/papermc/paper/util/player/NearbyPlayers.java
|
||||
+++ b/src/main/java/io/papermc/paper/util/player/NearbyPlayers.java
|
||||
@@ -106,6 +106,13 @@ public final class NearbyPlayers {
|
||||
return chunk == null ? null : chunk.players[type.ordinal()];
|
||||
}
|
||||
|
||||
+ // Polpot start - cache coordinate key used for nearby players
|
||||
+ public ReferenceList<ServerPlayer> getPlayers(final long nearbyPlayersCoordinateKey, final NearbyMapType type) {
|
||||
+ final TrackedChunk chunk = this.byChunk.get(nearbyPlayersCoordinateKey);
|
||||
+ return chunk == null ? null : chunk.players[type.ordinal()];
|
||||
+ }
|
||||
+ // Polpot end
|
||||
+
|
||||
public ReferenceList<ServerPlayer> getPlayersByChunk(final int chunkX, final int chunkZ, final NearbyMapType type) {
|
||||
final TrackedChunk chunk = this.byChunk.get(CoordinateUtils.getChunkKey(chunkX, chunkZ));
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Eula.java b/src/main/java/net/minecraft/server/Eula.java
|
||||
index b9403a3eafc1b30b33ac654f253d0849cacadd03..a6190f14cb9463ee75e8890f191a7ec88e59b37f 100644
|
||||
--- a/src/main/java/net/minecraft/server/Eula.java
|
||||
+++ b/src/main/java/net/minecraft/server/Eula.java
|
||||
@@ -47,7 +47,7 @@ public class Eula {
|
||||
return var3;
|
||||
} catch (Exception var6) {
|
||||
if (file == this.file) { // Gale - YAPFA - global EULA file
|
||||
- LOGGER.warn("Failed to load {}", (Object)this.file);
|
||||
+ LOGGER.warn("Failed to load {}", this.file); // Leaf - remove convert
|
||||
this.saveDefaults();
|
||||
} // Gale - YAPFA - global EULA file
|
||||
return false;
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
index 02b517288ef0794ccfd46802bf76fa56af21c524..e7fe8e2a7f5cb0c36679142f3743467efbed9c31 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
@@ -602,7 +602,7 @@ public class ServerChunkCache extends ChunkSource {
|
||||
|
||||
// Paper start - optimise chunk tick iteration
|
||||
com.destroystokyo.paper.util.maplist.ReferenceList<ServerPlayer> playersNearby
|
||||
- = nearbyPlayers.getPlayers(chunkcoordintpair, io.papermc.paper.util.player.NearbyPlayers.NearbyMapType.SPAWN_RANGE);
|
||||
+ = nearbyPlayers.getPlayers(chunk1.nearbyPlayersCoordinateKey, io.papermc.paper.util.player.NearbyPlayers.NearbyMapType.SPAWN_RANGE); // nearbyPlayers.getPlayers(chunkcoordintpair, io.papermc.paper.util.player.NearbyPlayers.NearbyMapType.SPAWN_RANGE); // Polpot - cache coordinate key used for nearby players
|
||||
if (playersNearby == null) {
|
||||
continue;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
|
||||
index f7e5e016a7028a9196e689e950805b0d5b31fe38..29d5848dec547245a1bafc5674b62b54ff7cd287 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
|
||||
@@ -62,7 +62,7 @@ public abstract class ChunkAccess implements BlockGetter, BiomeManager.NoiseBiom
|
||||
protected final ShortList[] postProcessing;
|
||||
protected volatile boolean unsaved;
|
||||
private volatile boolean isLightCorrect;
|
||||
- protected final ChunkPos chunkPos; public final long coordinateKey; public final int locX; public final int locZ; // Paper - cache coordinate key
|
||||
+ protected final ChunkPos chunkPos; public final long coordinateKey; public final long nearbyPlayersCoordinateKey; public final int locX; public final int locZ; // Paper - cache coordinate key // Polpot - cache coordinate key used for nearby players
|
||||
private long inhabitedTime;
|
||||
/** @deprecated */
|
||||
@Nullable
|
||||
@@ -136,7 +136,7 @@ public abstract class ChunkAccess implements BlockGetter, BiomeManager.NoiseBiom
|
||||
}
|
||||
// Paper end - rewrite light engine
|
||||
this.locX = pos.x; this.locZ = pos.z; // Paper - reduce need for field lookups
|
||||
- this.chunkPos = pos; this.coordinateKey = ChunkPos.asLong(locX, locZ); // Paper - cache long key
|
||||
+ this.chunkPos = pos; this.coordinateKey = ChunkPos.asLong(locX, locZ); this.nearbyPlayersCoordinateKey = io.papermc.paper.util.CoordinateUtils.getChunkKey(locX, locZ); // Paper - cache long key // Polpot - cache coordinate key used for nearby players
|
||||
this.upgradeData = upgradeData;
|
||||
this.levelHeightAccessor = heightLimitView;
|
||||
this.sections = new LevelChunkSection[heightLimitView.getSectionsCount()];
|
||||
Reference in New Issue
Block a user