aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower/net/minecraft/server/ServerAdvancementManager.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/server/ServerAdvancementManager.java.patch')
-rw-r--r--patch-remap/mache-vineflower/net/minecraft/server/ServerAdvancementManager.java.patch122
1 files changed, 122 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/server/ServerAdvancementManager.java.patch b/patch-remap/mache-vineflower/net/minecraft/server/ServerAdvancementManager.java.patch
new file mode 100644
index 0000000000..785be48a0f
--- /dev/null
+++ b/patch-remap/mache-vineflower/net/minecraft/server/ServerAdvancementManager.java.patch
@@ -0,0 +1,122 @@
+--- a/net/minecraft/server/ServerAdvancementManager.java
++++ b/net/minecraft/server/ServerAdvancementManager.java
+@@ -1,8 +1,9 @@
++// mc-dev import
+ package net.minecraft.server;
+
+ import com.google.common.collect.ImmutableMap;
+-import com.google.common.collect.Multimap;
+ import com.google.common.collect.ImmutableMap.Builder;
++import com.google.common.collect.Multimap;
+ import com.google.gson.Gson;
+ import com.google.gson.GsonBuilder;
+ import com.google.gson.JsonElement;
+@@ -10,8 +11,8 @@
+ import com.mojang.logging.LogUtils;
+ import com.mojang.serialization.JsonOps;
+ import java.util.Collection;
++import java.util.Iterator;
+ import java.util.Map;
+-import java.util.Map.Entry;
+ import java.util.stream.Collectors;
+ import javax.annotation.Nullable;
+ import net.minecraft.Util;
+@@ -29,59 +30,70 @@
+ import org.slf4j.Logger;
+
+ public class ServerAdvancementManager extends SimpleJsonResourceReloadListener {
++
+ private static final Logger LOGGER = LogUtils.getLogger();
+- private static final Gson GSON = new GsonBuilder().create();
+- private Map<ResourceLocation, AdvancementHolder> advancements = Map.of();
++ public static final Gson GSON = (new GsonBuilder()).create();
++ public Map<ResourceLocation, AdvancementHolder> advancements = Map.of();
+ private AdvancementTree tree = new AdvancementTree();
+ private final LootDataManager lootData;
+
+ public ServerAdvancementManager(LootDataManager lootData) {
+- super(GSON, "advancements");
++ super(ServerAdvancementManager.GSON, "advancements");
+ this.lootData = lootData;
+ }
+
+- @Override
+ protected void apply(Map<ResourceLocation, JsonElement> object, ResourceManager resourceManager, ProfilerFiller profiler) {
+ Builder<ResourceLocation, AdvancementHolder> builder = ImmutableMap.builder();
+- object.forEach((resourceLocation, jsonElement) -> {
++
++ object.forEach((minecraftkey, jsonelement) -> {
+ try {
+- Advancement advancement = Util.getOrThrow(Advancement.CODEC.parse(JsonOps.INSTANCE, jsonElement), JsonParseException::new);
+- this.validate(resourceLocation, advancement);
+- builder.put(resourceLocation, new AdvancementHolder(resourceLocation, advancement));
+- } catch (Exception var5x) {
+- LOGGER.error("Parsing error loading custom advancement {}: {}", resourceLocation, var5x.getMessage());
++ Advancement advancement = (Advancement) Util.getOrThrow(Advancement.CODEC.parse(JsonOps.INSTANCE, jsonelement), JsonParseException::new);
++
++ this.validate(minecraftkey, advancement);
++ builder.put(minecraftkey, new AdvancementHolder(minecraftkey, advancement));
++ } catch (Exception exception) {
++ ServerAdvancementManager.LOGGER.error("Parsing error loading custom advancement {}: {}", minecraftkey, exception.getMessage());
+ }
++
+ });
+ this.advancements = builder.buildOrThrow();
+- AdvancementTree advancementTree = new AdvancementTree();
+- advancementTree.addAll(this.advancements.values());
++ AdvancementTree advancementtree = new AdvancementTree();
+
+- for (AdvancementNode advancementNode : advancementTree.roots()) {
+- if (advancementNode.holder().value().display().isPresent()) {
+- TreeNodePosition.run(advancementNode);
++ advancementtree.addAll(this.advancements.values());
++ Iterator iterator = advancementtree.roots().iterator();
++
++ while (iterator.hasNext()) {
++ AdvancementNode advancementnode = (AdvancementNode) iterator.next();
++
++ if (advancementnode.holder().value().display().isPresent()) {
++ TreeNodePosition.run(advancementnode);
+ }
+ }
+
+- this.tree = advancementTree;
++ this.tree = advancementtree;
+ }
+
+- private void validate(ResourceLocation resourceLocation, Advancement advancement) {
+- ProblemReporter.Collector collector = new ProblemReporter.Collector();
+- advancement.validate(collector, this.lootData);
+- Multimap<String, String> multimap = collector.get();
++ private void validate(ResourceLocation minecraftkey, Advancement advancement) {
++ ProblemReporter.a problemreporter_a = new ProblemReporter.a();
++
++ advancement.validate(problemreporter_a, this.lootData);
++ Multimap<String, String> multimap = problemreporter_a.get();
++
+ if (!multimap.isEmpty()) {
+- String string = multimap.asMap()
+- .entrySet()
+- .stream()
+- .map(entry -> " at " + entry.getKey() + ": " + String.join("; ", entry.getValue()))
+- .collect(Collectors.joining("\n"));
+- LOGGER.warn("Found validation problems in advancement {}: \n{}", resourceLocation, string);
++ String s = (String) multimap.asMap().entrySet().stream().map((entry) -> {
++ String s1 = (String) entry.getKey();
++
++ return " at " + s1 + ": " + String.join("; ", (Iterable) entry.getValue());
++ }).collect(Collectors.joining("\n"));
++
++ ServerAdvancementManager.LOGGER.warn("Found validation problems in advancement {}: \n{}", minecraftkey, s);
+ }
++
+ }
+
+ @Nullable
+- public AdvancementHolder get(ResourceLocation resourceLocation) {
+- return this.advancements.get(resourceLocation);
++ public AdvancementHolder get(ResourceLocation minecraftkey) {
++ return (AdvancementHolder) this.advancements.get(minecraftkey);
+ }
+
+ public AdvancementTree tree() {