mirror of
https://github.com/BX-Team/DivineMC.git
synced 2025-12-19 14:59:25 +00:00
46 lines
3.1 KiB
Diff
46 lines
3.1 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
|
Date: Mon, 4 Aug 2025 02:38:45 +0300
|
|
Subject: [PATCH] Configurable player spawn tracking range
|
|
|
|
|
|
diff --git a/ca/spottedleaf/moonrise/patches/chunk_tick_iteration/ChunkTickConstants.java b/ca/spottedleaf/moonrise/patches/chunk_tick_iteration/ChunkTickConstants.java
|
|
index 6d1fe8028739145b11fce98ad62b2f8044299548..9f086ded18d1fc8850877c6be113d88074427526 100644
|
|
--- a/ca/spottedleaf/moonrise/patches/chunk_tick_iteration/ChunkTickConstants.java
|
|
+++ b/ca/spottedleaf/moonrise/patches/chunk_tick_iteration/ChunkTickConstants.java
|
|
@@ -2,7 +2,7 @@ package ca.spottedleaf.moonrise.patches.chunk_tick_iteration;
|
|
|
|
public final class ChunkTickConstants {
|
|
|
|
- public static final int PLAYER_SPAWN_TRACK_RANGE = 8;
|
|
+ public static final int PLAYER_SPAWN_TRACK_RANGE = (int) Math.round(org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.playerNearChunkDetectionRange / 16.0); // DivineMC - Configurable player spawn tracking range
|
|
// the smallest distance on x/z is at 45 degrees, we need to subtract 0.5 since this is calculated from chunk center and not chunk perimeter
|
|
// note: vanilla does not subtract 0.5 but the result is (luckily!) the same
|
|
public static final int NARROW_SPAWN_TRACK_RANGE = (int)Math.floor(((double)PLAYER_SPAWN_TRACK_RANGE / Math.sqrt(2.0)) - 0.5);
|
|
diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java
|
|
index a6bf257ca93e4b3819b65b4ef4ba71d9e2b40933..de7800b46f7e8c68f24de8476032f2179edc4797 100644
|
|
--- a/net/minecraft/server/level/ChunkMap.java
|
|
+++ b/net/minecraft/server/level/ChunkMap.java
|
|
@@ -822,10 +822,10 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
|
final ServerPlayer[] raw = players.getRawDataUnchecked();
|
|
final int len = players.size();
|
|
|
|
- Objects.checkFromIndexSize(0, len, raw.length);
|
|
- for (int i = 0; i < len; ++i) {
|
|
+ for (int i = 0; i < raw.length; ++i) { // DivineMC - Configurable player spawn tracking range
|
|
final ServerPlayer player = raw[i];
|
|
- if (this.playerIsCloseEnoughForSpawning(player, chunkPos, 16384.0D)) { // Spigot
|
|
+ if (player == null) continue; // DivineMC - Configurable player spawn tracking range
|
|
+ if (this.playerIsCloseEnoughForSpawning(player, chunkPos, (org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.playerNearChunkDetectionRange^2))) { // Spigot // DivineMC - Configurable player spawn tracking range
|
|
if (ret == null) {
|
|
ret = new ArrayList<>(len - i);
|
|
ret.add(player);
|
|
@@ -1220,6 +1220,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
|
|
|
for (int i = 0; i < playersLength; ++i) { // DivineMC - Multithreaded tracker
|
|
final ServerPlayer player = playersRaw[i];
|
|
+ if (player == null) continue; // DivineMC - Configurable player spawn tracking range
|
|
this.updatePlayer(player);
|
|
}
|
|
|