Yatopia/patches/server/0041-Optimize-advancement-loading.patch
Simon Gardling e01705826c
Upstream (#484)
* Updated Upstream and Sidestream(s) (Paper/Purpur/Empirecraft)

Upstream/An Sidestream has released updates that appears to apply and compile correctly
This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing.

Paper Changes:
2a67a9e51 Fix missing CraftMetaBook#toBuilder override
48aa06106 Add more Wandering Trader API (#5020)
8cec462a5 [CI-SKIP] Remove Astei from the MIT list (#5577)
21fbc3196 [CI-SKIP] Add Other textarea to issue templates (#5562)
453e983e4 fix isProxyOnlineMode coverage, don't lookup UUIDs in offline mode (Fixes #2011)
81cc4f928 Send empty commands if tab completion is disabled (Closes #5519)
9ed3e470d Keep moveToWorld with old method signature
99a66a583 [Auto] Updated Upstream (CraftBukkit)
976c6d425 [CI-SKIP] [Auto] Rebuild Patches
51deec726 Drop unneeded portal patch (#5566)
07a18c457 [Auto] Updated Upstream (CraftBukkit)
6733d7875 [Auto] Updated Upstream (Bukkit)
9958447cb [Auto] Updated Upstream (Bukkit)
840e72091 [CI-SKIP] [Auto] Rebuild Patches
a33232d4a Add beacon activation and deactivation events (#5121)

Purpur Changes:
ebc0765 Updated Upstream (Paper)
5bc5dfd Fix #318 - Stonecutter does not damage when sneaking
8366582 Resolve #286 - Add config and API for item immunity to lightning
a86555b Updated Upstream (Paper)
8b2607c Config for only sending advancements to affected players (#312)
7ee3393 Add config for the piston push limit (#311)
a30e5ac Add config for void damage dealt
786382b Updated Upstream (Paper)
60d8411 [ci-skip] fix patch name
b64f536 Config for changing the blocks that turn into paths (#303)
1d3f710 Updated Upstream (Paper)
3af86ad Oopsie
4b0342a Gamemode extra permissions
17c8573 [CI-SKIP] Don't pass ping to demo command output
c3481c0 Initialize the credits command output in config
a176fe6 Add credits command

Empirecraft Changes:
b2879a24 Updated Paper

* Updated Upstream and Sidestream(s) (Paper/Tuinity/Airplane/Purpur/Empirecraft)

Upstream/An Sidestream has released updates that appears to apply and compile correctly
This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing.

Paper Changes:
b3cc88799 Add the ability to clear entities from block storage (#5598)
f50171f3b Add missing rarity method on ItemStack (#5594)
aeb6e7dd2 Updated Upstream (Bukkit/CraftBukkit/Spigot) (#5601)
b0a4f353b fix cancelling block falling causing client desync (fixes #5386) (#5419)
8ed45920c Don't annotate type parameters using JetBrains annotations (#5600)
d7625d926 Add new methods from PlayerMoveEvent to EntityMoveEvent (#5591)
29785297b Allow for Component suggestion tooltips in AsyncTabCompleteEvent (#5504)
0aea6c2ff Use JsonSerializationContext#serialize instead of recursion for AdventureComponents - fixes #5580 and #5371
8fcef3c1f Return after sending empty commands (#5586)

Tuinity Changes:
3350246 Updated Upstream (Paper)
f773caf Fix rare ticket level recursion crash
0fa8a0e Starlight Handle concurrent chunk generation and lighting better

Airplane Changes:
fad74c2 Fix JB annotations for gradle (credit jpenilla)
d02f034 Updated Upstream (Tuinity)

Purpur Changes:
adfe5d3 Updated Upstream (Paper)
7a728f8 Fix #325 - Fix SPIGOT-6278
f5c3dae Updated Upstream (Paper)
a80e5b6 Dont create item meta when checking if meta properties exist
90339c5 Add missing netherite from Material#isArmor
bedac18 Updated Upstream (Paper, Tuinity, & Airplane)
3b1531a [ci-skip] Add wrapper validation step to actions
73ab4e6 Update the "changing the blocks that turn into paths" defaults to reflect the vanilla defaults. (#322)
a24b31b Updated Upstream (Paper)

Empirecraft Changes:
87ceb204 Updated Paper
a3497a7e Fix some patches
2ed9e7fa Updated Paper
d5a47a3d Updated Paper

* Updated Upstream and Sidestream(s) (Tuinity)

Upstream/An Sidestream has released updates that appears to apply and compile correctly
This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing.

Tuinity Changes:
1382473 Null check chunk in block changes for Starlight
2021-05-10 23:16:50 -04:00

108 lines
5.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Ivan Pekov <ivan@mrivanplays.com>
Date: Tue, 6 Oct 2020 15:10:12 +0300
Subject: [PATCH] Optimize advancement loading
Removed some object allocations and reduced loops
diff --git a/src/main/java/net/minecraft/advancements/Advancement.java b/src/main/java/net/minecraft/advancements/Advancement.java
index 97479cacc2a3f7850df8647f78d7dbb5710ae27b..59cbb085bad5ab4d98d2a196c9b15dc58ce6d9df 100644
--- a/src/main/java/net/minecraft/advancements/Advancement.java
+++ b/src/main/java/net/minecraft/advancements/Advancement.java
@@ -81,6 +81,7 @@ public class Advancement {
return this.display;
}
+ public final AdvancementRewards getRewards() { return d(); } // Yatopia - OBFHELPER
public AdvancementRewards d() {
return this.rewards;
}
diff --git a/src/main/java/net/minecraft/server/AdvancementDataPlayer.java b/src/main/java/net/minecraft/server/AdvancementDataPlayer.java
index b81a0e1c3ff3d749b6bbd9efdbc7823d1c631b8e..3185d89d97823e85d2c3eb5236eb85f4e40b6067 100644
--- a/src/main/java/net/minecraft/server/AdvancementDataPlayer.java
+++ b/src/main/java/net/minecraft/server/AdvancementDataPlayer.java
@@ -179,11 +179,16 @@ public class AdvancementDataPlayer {
throw new JsonParseException("Found null for advancements");
}
+ /* // Yatopia start - streams no good
Stream<Entry<MinecraftKey, AdvancementProgress>> stream = map.entrySet().stream().sorted(Comparator.comparing(Entry::getValue));
Iterator iterator = ((List) stream.collect(Collectors.toList())).iterator();
while (iterator.hasNext()) {
Entry<MinecraftKey, AdvancementProgress> entry = (Entry) iterator.next();
+ */
+ Entry<MinecraftKey, AdvancementProgress>[] entries = map.entrySet().toArray(new Entry[0]);
+ java.util.Arrays.sort(entries, Entry.comparingByValue());
+ for (Entry<MinecraftKey, AdvancementProgress> entry : entries) { // Yatopia end
Advancement advancement = advancementdataworld.a((MinecraftKey) entry.getKey());
if (advancement == null) {
@@ -221,11 +226,37 @@ public class AdvancementDataPlayer {
}
}
+ /* // Yatopia start
this.c(advancementdataworld);
this.c();
this.b(advancementdataworld);
+ */
+ loadAdvancements(advancementdataworld);
+ // Yatopia end
}
+ // Yatopia start - reduce overload by post io load of advancements
+ // this combines c(AdvancementDataWorld), c() and b(AdvancementDataWorld) into 1 method
+ // the changes done: loops thru all the advancements only once, does not create an additional list
+ // and does not loop thru the additional list, does not create an additional set when checking for progress and
+ // does not additionally loop thru it
+ private void loadAdvancements(AdvancementDataWorld serverAdvancementManager) {
+ for (Advancement advancement : serverAdvancementManager.getAdvancements()) {
+ if (advancement.getCriteria().isEmpty()) {
+ grantCriteria(advancement, "");
+ advancement.getRewards().a(player); // todo: too lazy to import AdvancementRewards for an obfhelper
+ }
+ AdvancementProgress progress = getProgress(advancement);
+ if (progress.isDone()) {
+ this.j.add(advancement);
+ updateVisibility(advancement);
+ continue; // Do not double check isDone
+ }
+ beginTrackingNoIsDone(advancement, progress);
+ }
+ }
+ // Yatopia end
+
public void b() {
if (org.spigotmc.SpigotConfig.disableAdvancementSaving) return; // Spigot
Map<MinecraftKey, AdvancementProgress> map = Maps.newHashMap();
@@ -357,6 +388,11 @@ public class AdvancementDataPlayer {
AdvancementProgress advancementprogress = this.getProgress(advancement);
if (!advancementprogress.isDone()) {
+ // Yatopia start - beginTrackig with no isDone check
+ beginTrackingNoIsDone(advancement, advancementprogress);
+ }
+ }
+ private void beginTrackingNoIsDone(Advancement advancement, AdvancementProgress advancementprogress) {
Iterator iterator = advancement.getCriteria().entrySet().iterator();
while (iterator.hasNext()) {
@@ -376,7 +412,7 @@ public class AdvancementDataPlayer {
}
}
- }
+ //} // Yatopia end
}
private void d(Advancement advancement) {
@@ -471,6 +507,7 @@ public class AdvancementDataPlayer {
this.data.put(advancement, advancementprogress);
}
+ private final void updateVisibility(Advancement advancement) { e(advancement); } // Yatopia
private void e(Advancement advancement) {
// Paper start
e(advancement, IterationEntryPoint.ROOT);