aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower/net/minecraft/server/PlayerAdvancements.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/server/PlayerAdvancements.java.patch')
-rw-r--r--patch-remap/mache-vineflower/net/minecraft/server/PlayerAdvancements.java.patch508
1 files changed, 508 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/server/PlayerAdvancements.java.patch b/patch-remap/mache-vineflower/net/minecraft/server/PlayerAdvancements.java.patch
new file mode 100644
index 0000000000..9bd25106d5
--- /dev/null
+++ b/patch-remap/mache-vineflower/net/minecraft/server/PlayerAdvancements.java.patch
@@ -0,0 +1,508 @@
+--- a/net/minecraft/server/PlayerAdvancements.java
++++ b/net/minecraft/server/PlayerAdvancements.java
+@@ -10,17 +10,19 @@
+ import com.mojang.logging.LogUtils;
+ import com.mojang.serialization.Codec;
+ import com.mojang.serialization.JsonOps;
++import java.io.BufferedWriter;
+ import java.io.IOException;
+-import java.io.Writer;
+ import java.nio.charset.StandardCharsets;
+ import java.nio.file.Files;
++import java.nio.file.LinkOption;
+ import java.nio.file.Path;
+ import java.util.HashMap;
+ import java.util.HashSet;
++import java.util.Iterator;
+ import java.util.LinkedHashMap;
+ import java.util.Map;
+-import java.util.Set;
+ import java.util.Map.Entry;
++import java.util.Set;
+ import java.util.function.BiConsumer;
+ import javax.annotation.Nullable;
+ import net.minecraft.FileUtil;
+@@ -34,7 +36,6 @@
+ import net.minecraft.advancements.CriterionProgress;
+ import net.minecraft.advancements.CriterionTrigger;
+ import net.minecraft.advancements.CriterionTriggerInstance;
+-import net.minecraft.advancements.DisplayInfo;
+ import net.minecraft.core.registries.BuiltInRegistries;
+ import net.minecraft.network.protocol.game.ClientboundSelectAdvancementsTabPacket;
+ import net.minecraft.network.protocol.game.ClientboundUpdateAdvancementsPacket;
+@@ -47,28 +48,30 @@
+ import org.slf4j.Logger;
+
+ public class PlayerAdvancements {
++
+ private static final Logger LOGGER = LogUtils.getLogger();
+- private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
++ private static final Gson GSON = (new GsonBuilder()).setPrettyPrinting().create();
+ private final PlayerList playerList;
+ private final Path playerSavePath;
+ private AdvancementTree tree;
+- private final Map<AdvancementHolder, AdvancementProgress> progress = new LinkedHashMap<>();
+- private final Set<AdvancementHolder> visible = new HashSet<>();
+- private final Set<AdvancementHolder> progressChanged = new HashSet<>();
+- private final Set<AdvancementNode> rootsToUpdate = new HashSet<>();
++ private final Map<AdvancementHolder, AdvancementProgress> progress = new LinkedHashMap();
++ private final Set<AdvancementHolder> visible = new HashSet();
++ private final Set<AdvancementHolder> progressChanged = new HashSet();
++ private final Set<AdvancementNode> rootsToUpdate = new HashSet();
+ private ServerPlayer player;
+ @Nullable
+ private AdvancementHolder lastSelectedTab;
+ private boolean isFirstPacket = true;
+- private final Codec<PlayerAdvancements.Data> codec;
++ private final Codec<PlayerAdvancements.a> codec;
+
+ public PlayerAdvancements(DataFixer dataFixer, PlayerList playerList, ServerAdvancementManager manager, Path playerSavePath, ServerPlayer player) {
+ this.playerList = playerList;
+ this.playerSavePath = playerSavePath;
+ this.player = player;
+ this.tree = manager.tree();
+- int i = 1343;
+- this.codec = DataFixTypes.ADVANCEMENTS.wrapCodec(PlayerAdvancements.Data.CODEC, dataFixer, 1343);
++ boolean flag = true;
++
++ this.codec = DataFixTypes.ADVANCEMENTS.wrapCodec(PlayerAdvancements.a.CODEC, dataFixer, 1343);
+ this.load(manager);
+ }
+
+@@ -77,9 +80,14 @@
+ }
+
+ public void stopListening() {
+- for (CriterionTrigger<?> criterionTrigger : BuiltInRegistries.TRIGGER_TYPES) {
+- criterionTrigger.removePlayerListeners(this);
++ Iterator iterator = BuiltInRegistries.TRIGGER_TYPES.iterator();
++
++ while (iterator.hasNext()) {
++ CriterionTrigger<?> criteriontrigger = (CriterionTrigger) iterator.next();
++
++ criteriontrigger.removePlayerListeners(this);
+ }
++
+ }
+
+ public void reload(ServerAdvancementManager manager) {
+@@ -95,32 +103,57 @@
+ }
+
+ private void registerListeners(ServerAdvancementManager manager) {
+- for (AdvancementHolder advancementHolder : manager.getAllAdvancements()) {
+- this.registerListeners(advancementHolder);
++ Iterator iterator = manager.getAllAdvancements().iterator();
++
++ while (iterator.hasNext()) {
++ AdvancementHolder advancementholder = (AdvancementHolder) iterator.next();
++
++ this.registerListeners(advancementholder);
+ }
++
+ }
+
+ private void checkForAutomaticTriggers(ServerAdvancementManager manager) {
+- for (AdvancementHolder advancementHolder : manager.getAllAdvancements()) {
+- Advancement advancement = advancementHolder.value();
++ Iterator iterator = manager.getAllAdvancements().iterator();
++
++ while (iterator.hasNext()) {
++ AdvancementHolder advancementholder = (AdvancementHolder) iterator.next();
++ Advancement advancement = advancementholder.value();
++
+ if (advancement.criteria().isEmpty()) {
+- this.award(advancementHolder, "");
++ this.award(advancementholder, "");
+ advancement.rewards().grant(this.player);
+ }
+ }
++
+ }
+
+ private void load(ServerAdvancementManager manager) {
+- if (Files.isRegularFile(this.playerSavePath)) {
+- try (JsonReader jsonReader = new JsonReader(Files.newBufferedReader(this.playerSavePath, StandardCharsets.UTF_8))) {
+- jsonReader.setLenient(false);
+- JsonElement jsonElement = Streams.parse(jsonReader);
+- PlayerAdvancements.Data data = Util.getOrThrow(this.codec.parse(JsonOps.INSTANCE, jsonElement), JsonParseException::new);
+- this.applyFrom(manager, data);
+- } catch (JsonParseException var7) {
+- LOGGER.error("Couldn't parse player advancements in {}", this.playerSavePath, var7);
+- } catch (IOException var8) {
+- LOGGER.error("Couldn't access player advancements in {}", this.playerSavePath, var8);
++ if (Files.isRegularFile(this.playerSavePath, new LinkOption[0])) {
++ try {
++ JsonReader jsonreader = new JsonReader(Files.newBufferedReader(this.playerSavePath, StandardCharsets.UTF_8));
++
++ try {
++ jsonreader.setLenient(false);
++ JsonElement jsonelement = Streams.parse(jsonreader);
++ PlayerAdvancements.a advancementdataplayer_a = (PlayerAdvancements.a) Util.getOrThrow(this.codec.parse(JsonOps.INSTANCE, jsonelement), JsonParseException::new);
++
++ this.applyFrom(manager, advancementdataplayer_a);
++ } catch (Throwable throwable) {
++ try {
++ jsonreader.close();
++ } catch (Throwable throwable1) {
++ throwable.addSuppressed(throwable1);
++ }
++
++ throw throwable;
++ }
++
++ jsonreader.close();
++ } catch (JsonParseException jsonparseexception) {
++ PlayerAdvancements.LOGGER.error("Couldn't parse player advancements in {}", this.playerSavePath, jsonparseexception);
++ } catch (IOException ioexception) {
++ PlayerAdvancements.LOGGER.error("Couldn't access player advancements in {}", this.playerSavePath, ioexception);
+ }
+ }
+
+@@ -129,137 +162,179 @@
+ }
+
+ public void save() {
+- JsonElement jsonElement = Util.getOrThrow(this.codec.encodeStart(JsonOps.INSTANCE, this.asData()), IllegalStateException::new);
++ JsonElement jsonelement = (JsonElement) Util.getOrThrow(this.codec.encodeStart(JsonOps.INSTANCE, this.asData()), IllegalStateException::new);
+
+ try {
+ FileUtil.createDirectoriesSafe(this.playerSavePath.getParent());
++ BufferedWriter bufferedwriter = Files.newBufferedWriter(this.playerSavePath, StandardCharsets.UTF_8);
+
+- try (Writer bufferedWriter = Files.newBufferedWriter(this.playerSavePath, StandardCharsets.UTF_8)) {
+- GSON.toJson(jsonElement, bufferedWriter);
++ try {
++ PlayerAdvancements.GSON.toJson(jsonelement, bufferedwriter);
++ } catch (Throwable throwable) {
++ if (bufferedwriter != null) {
++ try {
++ bufferedwriter.close();
++ } catch (Throwable throwable1) {
++ throwable.addSuppressed(throwable1);
++ }
++ }
++
++ throw throwable;
+ }
+- } catch (IOException var7) {
+- LOGGER.error("Couldn't save player advancements to {}", this.playerSavePath, var7);
++
++ if (bufferedwriter != null) {
++ bufferedwriter.close();
++ }
++ } catch (IOException ioexception) {
++ PlayerAdvancements.LOGGER.error("Couldn't save player advancements to {}", this.playerSavePath, ioexception);
+ }
++
+ }
+
+- private void applyFrom(ServerAdvancementManager serverAdvancementManager, PlayerAdvancements.Data data) {
+- data.forEach((resourceLocation, advancementProgress) -> {
+- AdvancementHolder advancementHolder = serverAdvancementManager.get(resourceLocation);
+- if (advancementHolder == null) {
+- LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", resourceLocation, this.playerSavePath);
++ private void applyFrom(ServerAdvancementManager advancementdataworld, PlayerAdvancements.a advancementdataplayer_a) {
++ advancementdataplayer_a.forEach((minecraftkey, advancementprogress) -> {
++ AdvancementHolder advancementholder = advancementdataworld.get(minecraftkey);
++
++ if (advancementholder == null) {
++ if (!minecraftkey.getNamespace().equals("minecraft")) return; // CraftBukkit
++ PlayerAdvancements.LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", minecraftkey, this.playerSavePath);
+ } else {
+- this.startProgress(advancementHolder, advancementProgress);
+- this.progressChanged.add(advancementHolder);
+- this.markForVisibilityUpdate(advancementHolder);
++ this.startProgress(advancementholder, advancementprogress);
++ this.progressChanged.add(advancementholder);
++ this.markForVisibilityUpdate(advancementholder);
+ }
+ });
+ }
+
+- private PlayerAdvancements.Data asData() {
+- Map<ResourceLocation, AdvancementProgress> map = new LinkedHashMap<>();
+- this.progress.forEach((advancementHolder, advancementProgress) -> {
+- if (advancementProgress.hasProgress()) {
+- map.put(advancementHolder.id(), advancementProgress);
++ private PlayerAdvancements.a asData() {
++ Map<ResourceLocation, AdvancementProgress> map = new LinkedHashMap();
++
++ this.progress.forEach((advancementholder, advancementprogress) -> {
++ if (advancementprogress.hasProgress()) {
++ map.put(advancementholder.id(), advancementprogress);
+ }
++
+ });
+- return new PlayerAdvancements.Data(map);
++ return new PlayerAdvancements.a(map);
+ }
+
+- public boolean award(AdvancementHolder advancementHolder, String string) {
++ public boolean award(AdvancementHolder advancementholder, String s) {
+ boolean flag = false;
+- AdvancementProgress orStartProgress = this.getOrStartProgress(advancementHolder);
+- boolean isDone = orStartProgress.isDone();
+- if (orStartProgress.grantProgress(string)) {
+- this.unregisterListeners(advancementHolder);
+- this.progressChanged.add(advancementHolder);
++ AdvancementProgress advancementprogress = this.getOrStartProgress(advancementholder);
++ boolean flag1 = advancementprogress.isDone();
++
++ if (advancementprogress.grantProgress(s)) {
++ this.unregisterListeners(advancementholder);
++ this.progressChanged.add(advancementholder);
+ flag = true;
+- if (!isDone && orStartProgress.isDone()) {
+- advancementHolder.value().rewards().grant(this.player);
+- advancementHolder.value().display().ifPresent(displayInfo -> {
+- if (displayInfo.shouldAnnounceChat() && this.player.level().getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) {
+- this.playerList.broadcastSystemMessage(displayInfo.getType().createAnnouncement(advancementHolder, this.player), false);
++ if (!flag1 && advancementprogress.isDone()) {
++ this.player.level().getCraftServer().getPluginManager().callEvent(new org.bukkit.event.player.PlayerAdvancementDoneEvent(this.player.getBukkitEntity(), advancementholder.toBukkit())); // CraftBukkit
++ advancementholder.value().rewards().grant(this.player);
++ advancementholder.value().display().ifPresent((advancementdisplay) -> {
++ if (advancementdisplay.shouldAnnounceChat() && this.player.level().getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) {
++ this.playerList.broadcastSystemMessage(advancementdisplay.getType().createAnnouncement(advancementholder, this.player), false);
+ }
++
+ });
+ }
+ }
+
+- if (!isDone && orStartProgress.isDone()) {
+- this.markForVisibilityUpdate(advancementHolder);
++ if (!flag1 && advancementprogress.isDone()) {
++ this.markForVisibilityUpdate(advancementholder);
+ }
+
+ return flag;
+ }
+
+- public boolean revoke(AdvancementHolder advancementHolder, String string) {
++ public boolean revoke(AdvancementHolder advancementholder, String s) {
+ boolean flag = false;
+- AdvancementProgress orStartProgress = this.getOrStartProgress(advancementHolder);
+- boolean isDone = orStartProgress.isDone();
+- if (orStartProgress.revokeProgress(string)) {
+- this.registerListeners(advancementHolder);
+- this.progressChanged.add(advancementHolder);
++ AdvancementProgress advancementprogress = this.getOrStartProgress(advancementholder);
++ boolean flag1 = advancementprogress.isDone();
++
++ if (advancementprogress.revokeProgress(s)) {
++ this.registerListeners(advancementholder);
++ this.progressChanged.add(advancementholder);
+ flag = true;
+ }
+
+- if (isDone && !orStartProgress.isDone()) {
+- this.markForVisibilityUpdate(advancementHolder);
++ if (flag1 && !advancementprogress.isDone()) {
++ this.markForVisibilityUpdate(advancementholder);
+ }
+
+ return flag;
+ }
+
+- private void markForVisibilityUpdate(AdvancementHolder advancementHolder) {
+- AdvancementNode advancementNode = this.tree.get(advancementHolder);
+- if (advancementNode != null) {
+- this.rootsToUpdate.add(advancementNode.root());
++ private void markForVisibilityUpdate(AdvancementHolder advancementholder) {
++ AdvancementNode advancementnode = this.tree.get(advancementholder);
++
++ if (advancementnode != null) {
++ this.rootsToUpdate.add(advancementnode.root());
+ }
++
+ }
+
+- private void registerListeners(AdvancementHolder advancementHolder) {
+- AdvancementProgress orStartProgress = this.getOrStartProgress(advancementHolder);
+- if (!orStartProgress.isDone()) {
+- for (Entry<String, Criterion<?>> entry : advancementHolder.value().criteria().entrySet()) {
+- CriterionProgress criterion = orStartProgress.getCriterion(entry.getKey());
+- if (criterion != null && !criterion.isDone()) {
+- this.registerListener(advancementHolder, entry.getKey(), entry.getValue());
++ private void registerListeners(AdvancementHolder advancementholder) {
++ AdvancementProgress advancementprogress = this.getOrStartProgress(advancementholder);
++
++ if (!advancementprogress.isDone()) {
++ Iterator iterator = advancementholder.value().criteria().entrySet().iterator();
++
++ while (iterator.hasNext()) {
++ Entry<String, Criterion<?>> entry = (Entry) iterator.next();
++ CriterionProgress criterionprogress = advancementprogress.getCriterion((String) entry.getKey());
++
++ if (criterionprogress != null && !criterionprogress.isDone()) {
++ this.registerListener(advancementholder, (String) entry.getKey(), (Criterion) entry.getValue());
+ }
+ }
++
+ }
+ }
+
+- private <T extends CriterionTriggerInstance> void registerListener(AdvancementHolder advancementHolder, String string, Criterion<T> criterion) {
+- criterion.trigger().addPlayerListener(this, new CriterionTrigger.Listener<>(criterion.triggerInstance(), advancementHolder, string));
++ private <T extends CriterionTriggerInstance> void registerListener(AdvancementHolder advancementholder, String s, Criterion<T> criterion) {
++ criterion.trigger().addPlayerListener(this, new CriterionTrigger.Listener<>(criterion.triggerInstance(), advancementholder, s));
+ }
+
+- private void unregisterListeners(AdvancementHolder advancementHolder) {
+- AdvancementProgress orStartProgress = this.getOrStartProgress(advancementHolder);
++ private void unregisterListeners(AdvancementHolder advancementholder) {
++ AdvancementProgress advancementprogress = this.getOrStartProgress(advancementholder);
++ Iterator iterator = advancementholder.value().criteria().entrySet().iterator();
+
+- for (Entry<String, Criterion<?>> entry : advancementHolder.value().criteria().entrySet()) {
+- CriterionProgress criterion = orStartProgress.getCriterion(entry.getKey());
+- if (criterion != null && (criterion.isDone() || orStartProgress.isDone())) {
+- this.removeListener(advancementHolder, entry.getKey(), entry.getValue());
++ while (iterator.hasNext()) {
++ Entry<String, Criterion<?>> entry = (Entry) iterator.next();
++ CriterionProgress criterionprogress = advancementprogress.getCriterion((String) entry.getKey());
++
++ if (criterionprogress != null && (criterionprogress.isDone() || advancementprogress.isDone())) {
++ this.removeListener(advancementholder, (String) entry.getKey(), (Criterion) entry.getValue());
+ }
+ }
++
+ }
+
+- private <T extends CriterionTriggerInstance> void removeListener(AdvancementHolder advancementHolder, String string, Criterion<T> criterion) {
+- criterion.trigger().removePlayerListener(this, new CriterionTrigger.Listener<>(criterion.triggerInstance(), advancementHolder, string));
++ private <T extends CriterionTriggerInstance> void removeListener(AdvancementHolder advancementholder, String s, Criterion<T> criterion) {
++ criterion.trigger().removePlayerListener(this, new CriterionTrigger.Listener<>(criterion.triggerInstance(), advancementholder, s));
+ }
+
+ public void flushDirty(ServerPlayer serverPlayer) {
+ if (this.isFirstPacket || !this.rootsToUpdate.isEmpty() || !this.progressChanged.isEmpty()) {
+- Map<ResourceLocation, AdvancementProgress> map = new HashMap<>();
+- Set<AdvancementHolder> set = new HashSet<>();
+- Set<ResourceLocation> set1 = new HashSet<>();
++ Map<ResourceLocation, AdvancementProgress> map = new HashMap();
++ Set<AdvancementHolder> set = new HashSet();
++ Set<ResourceLocation> set1 = new HashSet();
++ Iterator iterator = this.rootsToUpdate.iterator();
+
+- for (AdvancementNode advancementNode : this.rootsToUpdate) {
+- this.updateTreeVisibility(advancementNode, set, set1);
++ while (iterator.hasNext()) {
++ AdvancementNode advancementnode = (AdvancementNode) iterator.next();
++
++ this.updateTreeVisibility(advancementnode, set, set1);
+ }
+
+ this.rootsToUpdate.clear();
++ iterator = this.progressChanged.iterator();
+
+- for (AdvancementHolder advancementHolder : this.progressChanged) {
+- if (this.visible.contains(advancementHolder)) {
+- map.put(advancementHolder.id(), this.progress.get(advancementHolder));
++ while (iterator.hasNext()) {
++ AdvancementHolder advancementholder = (AdvancementHolder) iterator.next();
++
++ if (this.visible.contains(advancementholder)) {
++ map.put(advancementholder.id(), (AdvancementProgress) this.progress.get(advancementholder));
+ }
+ }
+
+@@ -272,58 +347,65 @@
+ this.isFirstPacket = false;
+ }
+
+- public void setSelectedTab(@Nullable AdvancementHolder advancementHolder) {
+- AdvancementHolder advancementHolder1 = this.lastSelectedTab;
+- if (advancementHolder != null && advancementHolder.value().isRoot() && advancementHolder.value().display().isPresent()) {
+- this.lastSelectedTab = advancementHolder;
++ public void setSelectedTab(@Nullable AdvancementHolder advancementholder) {
++ AdvancementHolder advancementholder1 = this.lastSelectedTab;
++
++ if (advancementholder != null && advancementholder.value().isRoot() && advancementholder.value().display().isPresent()) {
++ this.lastSelectedTab = advancementholder;
+ } else {
+ this.lastSelectedTab = null;
+ }
+
+- if (advancementHolder1 != this.lastSelectedTab) {
++ if (advancementholder1 != this.lastSelectedTab) {
+ this.player.connection.send(new ClientboundSelectAdvancementsTabPacket(this.lastSelectedTab == null ? null : this.lastSelectedTab.id()));
+ }
++
+ }
+
+- public AdvancementProgress getOrStartProgress(AdvancementHolder advancementHolder) {
+- AdvancementProgress advancementProgress = this.progress.get(advancementHolder);
+- if (advancementProgress == null) {
+- advancementProgress = new AdvancementProgress();
+- this.startProgress(advancementHolder, advancementProgress);
++ public AdvancementProgress getOrStartProgress(AdvancementHolder advancementholder) {
++ AdvancementProgress advancementprogress = (AdvancementProgress) this.progress.get(advancementholder);
++
++ if (advancementprogress == null) {
++ advancementprogress = new AdvancementProgress();
++ this.startProgress(advancementholder, advancementprogress);
+ }
+
+- return advancementProgress;
++ return advancementprogress;
+ }
+
+- private void startProgress(AdvancementHolder advancementHolder, AdvancementProgress advancementProgress) {
+- advancementProgress.update(advancementHolder.value().requirements());
+- this.progress.put(advancementHolder, advancementProgress);
++ private void startProgress(AdvancementHolder advancementholder, AdvancementProgress advancementprogress) {
++ advancementprogress.update(advancementholder.value().requirements());
++ this.progress.put(advancementholder, advancementprogress);
+ }
+
+- private void updateTreeVisibility(AdvancementNode advancementNode, Set<AdvancementHolder> set, Set<ResourceLocation> set1) {
+- AdvancementVisibilityEvaluator.evaluateVisibility(
+- advancementNode, advancementNode1 -> this.getOrStartProgress(advancementNode1.holder()).isDone(), (advancementNode1, flag) -> {
+- AdvancementHolder advancementHolder = advancementNode1.holder();
+- if (flag) {
+- if (this.visible.add(advancementHolder)) {
+- set.add(advancementHolder);
+- if (this.progress.containsKey(advancementHolder)) {
+- this.progressChanged.add(advancementHolder);
+- }
++ private void updateTreeVisibility(AdvancementNode advancementnode, Set<AdvancementHolder> set, Set<ResourceLocation> set1) {
++ AdvancementVisibilityEvaluator.evaluateVisibility(advancementnode, (advancementnode1) -> {
++ return this.getOrStartProgress(advancementnode1.holder()).isDone();
++ }, (advancementnode1, flag) -> {
++ AdvancementHolder advancementholder = advancementnode1.holder();
++
++ if (flag) {
++ if (this.visible.add(advancementholder)) {
++ set.add(advancementholder);
++ if (this.progress.containsKey(advancementholder)) {
++ this.progressChanged.add(advancementholder);
+ }
+- } else if (this.visible.remove(advancementHolder)) {
+- set1.add(advancementHolder.id());
+ }
++ } else if (this.visible.remove(advancementholder)) {
++ set1.add(advancementholder.id());
+ }
+- );
++
++ });
+ }
+
+- static record Data(Map<ResourceLocation, AdvancementProgress> map) {
+- public static final Codec<PlayerAdvancements.Data> CODEC = Codec.unboundedMap(ResourceLocation.CODEC, AdvancementProgress.CODEC)
+- .xmap(PlayerAdvancements.Data::new, PlayerAdvancements.Data::map);
++ private static record a(Map<ResourceLocation, AdvancementProgress> map) {
+
+- public void forEach(BiConsumer<ResourceLocation, AdvancementProgress> biConsumer) {
+- this.map.entrySet().stream().sorted(Entry.comparingByValue()).forEach(entry -> biConsumer.accept(entry.getKey(), entry.getValue()));
++ public static final Codec<PlayerAdvancements.a> CODEC = Codec.unboundedMap(ResourceLocation.CODEC, AdvancementProgress.CODEC).xmap(PlayerAdvancements.a::new, PlayerAdvancements.a::map);
++
++ public void forEach(BiConsumer<ResourceLocation, AdvancementProgress> biconsumer) {
++ this.map.entrySet().stream().sorted(Entry.comparingByValue()).forEach((entry) -> {
++ biconsumer.accept((ResourceLocation) entry.getKey(), (AdvancementProgress) entry.getValue());
++ });
+ }
+ }
+ }