9
0
mirror of https://github.com/Samsuik/Sakura.git synced 2025-12-22 00:09:20 +00:00
Files
SakuraMC/patches/server/0046-Reduce-entity-tracker-player-updates.patch
Samsuik 264bf21712 Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@b4f04ff Add Plugin#getDataPath (#11080)
PaperMC/Paper@05e5865 Add ItemType#getItemRarity (#11049)
PaperMC/Paper@aa929d6 Call PlayerLaunchProjectileEvent for wind charge (#10911)
PaperMC/Paper@8b23018 Avoid collision shapes outside world border in findFreePosition
PaperMC/Paper@3b45454 Port random ticking optimisation from Moonrise
PaperMC/Paper@77fcb29 Apply incremental player/level saving patch
PaperMC/Paper@9fd7710 Apply automatic regionfile header recalculation patch
PaperMC/Paper@b57b24d Do not try to stop main thread during watchdog shutdown
PaperMC/Paper@2cd8c46 Add OMINOUS_ITEM_SPAWNER SpawnReason (#10897)
PaperMC/Paper@ef96a69 Fire EntityChangeBlockEvent for weaving potion effect (#11087)
PaperMC/Paper@a6ceda1 distinguish between null and empty map in API (#10829)
PaperMC/Paper@506f165 Don't store removed components in multiple places (#11091)
PaperMC/Paper@ceeb8c1 Disable timings by default (#11095)
PaperMC/Paper@05ed6a6 Fix priority scheduling logic
PaperMC/Paper@967f98a Optimise chunk tick checking during chunk tick
PaperMC/Paper@00b949f Remove Moonrise utils to MCUtils, remove duplicated/unused utils
PaperMC/Paper@4efd24b Remove unused chunk system hooks in MCUtils
PaperMC/Paper@b653276 Finish chunk tick iteration optimisation port from Moonrise
PaperMC/Paper@2df5bba Log throwable when failing to save chunk/poi/entity data
PaperMC/Paper@44c3dd0 fix exact choice shapeless recipes (#10973)
PaperMC/Paper@dd11ef8 Updated Upstream (Bukkit/CraftBukkit/Spigot) (#11102)
PaperMC/Paper@3c8a7fe Re-add missing chunk event calls (#11104)
PaperMC/Paper@a8db527 Even more cleanup of mcutil patch
PaperMC/Paper@d08e8d1 Add total time to done message (#11109)
PaperMC/Paper@2a39276 Add CrafterCraftEvent (#11082)
PaperMC/Paper@75af62b Split rewriting flag into `paper.disableOldApiSupport` and `paper.disablePluginRemapping` (#11108)
PaperMC/Paper@7ea4039 Fixup startup time log message
PaperMC/Paper@e71c1df Call PlayerChunkUnloadEvent
PaperMC/Paper@968bdeb Make CraftComplexRecipe extend CraftingRecipe (#11114)
PaperMC/Paper@f1f01a1 Adjust done message again (#11118)
2024-07-20 00:57:24 +01:00

54 lines
2.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <40902469+Samsuik@users.noreply.github.com>
Date: Thu, 30 Nov 2023 15:54:49 +0000
Subject: [PATCH] Reduce entity tracker player updates
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 7daf9f7ea047cdd7afe031baca77fe00f2324692..475af481cb0e14693f129b36e9abe49d43ae4e43 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -928,7 +928,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
if (tracker == null) {
continue;
}
+ // Sakura start - reduce entity tracker player updates
+ if (tracker.shouldUpdatePlayers()) {
((ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerTrackedEntity)tracker).moonrise$tick(nearbyPlayers.getChunk(entity.chunkPosition()));
+ }
+ // Sakura end - reduce entity tracker player updates
tracker.serverEntity.sendChanges();
}
@@ -1180,12 +1184,30 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}
}
// Paper end - optimise entity tracker
+ // Sakura start - reduce entity tracker player updates
+ private final int playerUpdateInterval;
+ private Vec3 entityPosition;
+
+ public final boolean shouldUpdatePlayers() {
+ // We have to always update players otherwise they can turn invisible on teleports (why?)
+ if (this.entity instanceof net.minecraft.world.entity.player.Player || this.entity.tickCount % this.playerUpdateInterval == 0) {
+ return true;
+ }
+
+ Vec3 lastPosition = this.entityPosition;
+ this.entityPosition = this.entity.position();
+
+ return this.entity.position().distanceToSqr(lastPosition) >= (double) this.range / 2.0;
+ }
+ // Sakura start - reduce entity tracker player updates
public TrackedEntity(final Entity entity, final int i, final int j, final boolean flag) {
this.serverEntity = new ServerEntity(ChunkMap.this.level, entity, j, flag, this::broadcast, this.seenBy); // CraftBukkit
this.entity = entity;
this.range = i;
this.lastSectionPos = SectionPos.of((EntityAccess) entity);
+ this.playerUpdateInterval = Math.min(j, 20); // Sakura - reduce entity tracker player updates
+ this.entityPosition = entity.position(); // Sakura - reduce entity tracker player updates
}
public boolean equals(Object object) {