diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/advancements/AdvancementTree.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/advancements/AdvancementTree.java.patch | 219 |
1 files changed, 219 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/advancements/AdvancementTree.java.patch b/patch-remap/mache-vineflower/net/minecraft/advancements/AdvancementTree.java.patch new file mode 100644 index 0000000000..7e52db7819 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/advancements/AdvancementTree.java.patch @@ -0,0 +1,219 @@ +--- a/net/minecraft/advancements/AdvancementTree.java ++++ b/net/minecraft/advancements/AdvancementTree.java +@@ -5,8 +5,10 @@ + import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet; + import java.util.ArrayList; + import java.util.Collection; ++import java.util.Iterator; + import java.util.List; + import java.util.Map; ++import java.util.Objects; + import java.util.Optional; + import java.util.Set; + import javax.annotation.Nullable; +@@ -14,78 +16,96 @@ + import org.slf4j.Logger; + + public class AdvancementTree { ++ + private static final Logger LOGGER = LogUtils.getLogger(); +- private final Map<ResourceLocation, AdvancementNode> nodes = new Object2ObjectOpenHashMap<>(); +- private final Set<AdvancementNode> roots = new ObjectLinkedOpenHashSet<>(); +- private final Set<AdvancementNode> tasks = new ObjectLinkedOpenHashSet<>(); ++ private final Map<ResourceLocation, AdvancementNode> nodes = new Object2ObjectOpenHashMap(); ++ private final Set<AdvancementNode> roots = new ObjectLinkedOpenHashSet(); ++ private final Set<AdvancementNode> tasks = new ObjectLinkedOpenHashSet(); + @Nullable +- private AdvancementTree.Listener listener; ++ private AdvancementTree.a listener; + +- private void remove(AdvancementNode advancementNode) { +- for (AdvancementNode advancementNode1 : advancementNode.children()) { +- this.remove(advancementNode1); ++ public AdvancementTree() {} ++ ++ private void remove(AdvancementNode advancementnode) { ++ Iterator iterator = advancementnode.children().iterator(); ++ ++ while (iterator.hasNext()) { ++ AdvancementNode advancementnode1 = (AdvancementNode) iterator.next(); ++ ++ this.remove(advancementnode1); + } + +- LOGGER.info("Forgot about advancement {}", advancementNode.holder()); +- this.nodes.remove(advancementNode.holder().id()); +- if (advancementNode.parent() == null) { +- this.roots.remove(advancementNode); ++ AdvancementTree.LOGGER.info("Forgot about advancement {}", advancementnode.holder()); ++ this.nodes.remove(advancementnode.holder().id()); ++ if (advancementnode.parent() == null) { ++ this.roots.remove(advancementnode); + if (this.listener != null) { +- this.listener.onRemoveAdvancementRoot(advancementNode); ++ this.listener.onRemoveAdvancementRoot(advancementnode); + } + } else { +- this.tasks.remove(advancementNode); ++ this.tasks.remove(advancementnode); + if (this.listener != null) { +- this.listener.onRemoveAdvancementTask(advancementNode); ++ this.listener.onRemoveAdvancementTask(advancementnode); + } + } ++ + } + + public void remove(Set<ResourceLocation> set) { +- for (ResourceLocation resourceLocation : set) { +- AdvancementNode advancementNode = this.nodes.get(resourceLocation); +- if (advancementNode == null) { +- LOGGER.warn("Told to remove advancement {} but I don't know what that is", resourceLocation); ++ Iterator iterator = set.iterator(); ++ ++ while (iterator.hasNext()) { ++ ResourceLocation minecraftkey = (ResourceLocation) iterator.next(); ++ AdvancementNode advancementnode = (AdvancementNode) this.nodes.get(minecraftkey); ++ ++ if (advancementnode == null) { ++ AdvancementTree.LOGGER.warn("Told to remove advancement {} but I don't know what that is", minecraftkey); + } else { +- this.remove(advancementNode); ++ this.remove(advancementnode); + } + } ++ + } + + public void addAll(Collection<AdvancementHolder> collection) { +- List<AdvancementHolder> list = new ArrayList<>(collection); ++ ArrayList<AdvancementHolder> arraylist = new ArrayList(collection); // CraftBukkit - decompile error + +- while (!list.isEmpty()) { +- if (!list.removeIf(this::tryInsert)) { +- LOGGER.error("Couldn't load advancements: {}", list); ++ while (!arraylist.isEmpty()) { ++ if (!arraylist.removeIf(this::tryInsert)) { ++ AdvancementTree.LOGGER.error("Couldn't load advancements: {}", arraylist); + break; + } + } + +- LOGGER.info("Loaded {} advancements", this.nodes.size()); ++ // AdvancementTree.LOGGER.info("Loaded {} advancements", this.nodes.size()); // CraftBukkit - moved to AdvancementDataWorld#reload + } + +- private boolean tryInsert(AdvancementHolder advancementHolder) { +- Optional<ResourceLocation> optional = advancementHolder.value().parent(); +- AdvancementNode advancementNode = optional.map(this.nodes::get).orElse(null); +- if (advancementNode == null && optional.isPresent()) { ++ private boolean tryInsert(AdvancementHolder advancementholder) { ++ Optional<ResourceLocation> optional = advancementholder.value().parent(); ++ Map map = this.nodes; ++ ++ Objects.requireNonNull(this.nodes); ++ AdvancementNode advancementnode = (AdvancementNode) optional.map(map::get).orElse((Object) null); ++ ++ if (advancementnode == null && optional.isPresent()) { + return false; + } else { +- AdvancementNode advancementNode1 = new AdvancementNode(advancementHolder, advancementNode); +- if (advancementNode != null) { +- advancementNode.addChild(advancementNode1); ++ AdvancementNode advancementnode1 = new AdvancementNode(advancementholder, advancementnode); ++ ++ if (advancementnode != null) { ++ advancementnode.addChild(advancementnode1); + } + +- this.nodes.put(advancementHolder.id(), advancementNode1); +- if (advancementNode == null) { +- this.roots.add(advancementNode1); ++ this.nodes.put(advancementholder.id(), advancementnode1); ++ if (advancementnode == null) { ++ this.roots.add(advancementnode1); + if (this.listener != null) { +- this.listener.onAddAdvancementRoot(advancementNode1); ++ this.listener.onAddAdvancementRoot(advancementnode1); + } + } else { +- this.tasks.add(advancementNode1); ++ this.tasks.add(advancementnode1); + if (this.listener != null) { +- this.listener.onAddAdvancementTask(advancementNode1); ++ this.listener.onAddAdvancementTask(advancementnode1); + } + } + +@@ -100,6 +120,7 @@ + if (this.listener != null) { + this.listener.onAdvancementsCleared(); + } ++ + } + + public Iterable<AdvancementNode> roots() { +@@ -111,37 +132,47 @@ + } + + @Nullable +- public AdvancementNode get(ResourceLocation resourceLocation) { +- return this.nodes.get(resourceLocation); ++ public AdvancementNode get(ResourceLocation minecraftkey) { ++ return (AdvancementNode) this.nodes.get(minecraftkey); + } + + @Nullable +- public AdvancementNode get(AdvancementHolder advancementHolder) { +- return this.nodes.get(advancementHolder.id()); ++ public AdvancementNode get(AdvancementHolder advancementholder) { ++ return (AdvancementNode) this.nodes.get(advancementholder.id()); + } + +- public void setListener(@Nullable AdvancementTree.Listener listener) { +- this.listener = listener; +- if (listener != null) { +- for (AdvancementNode advancementNode : this.roots) { +- listener.onAddAdvancementRoot(advancementNode); ++ public void setListener(@Nullable AdvancementTree.a advancementtree_a) { ++ this.listener = advancementtree_a; ++ if (advancementtree_a != null) { ++ Iterator iterator = this.roots.iterator(); ++ ++ AdvancementNode advancementnode; ++ ++ while (iterator.hasNext()) { ++ advancementnode = (AdvancementNode) iterator.next(); ++ advancementtree_a.onAddAdvancementRoot(advancementnode); + } + +- for (AdvancementNode advancementNode : this.tasks) { +- listener.onAddAdvancementTask(advancementNode); ++ iterator = this.tasks.iterator(); ++ ++ while (iterator.hasNext()) { ++ advancementnode = (AdvancementNode) iterator.next(); ++ advancementtree_a.onAddAdvancementTask(advancementnode); + } + } ++ + } + +- public interface Listener { +- void onAddAdvancementRoot(AdvancementNode advancementNode); ++ public interface a { + +- void onRemoveAdvancementRoot(AdvancementNode advancementNode); ++ void onAddAdvancementRoot(AdvancementNode advancementnode); + +- void onAddAdvancementTask(AdvancementNode advancementNode); ++ void onRemoveAdvancementRoot(AdvancementNode advancementnode); + +- void onRemoveAdvancementTask(AdvancementNode advancementNode); ++ void onAddAdvancementTask(AdvancementNode advancementnode); + ++ void onRemoveAdvancementTask(AdvancementNode advancementnode); ++ + void onAdvancementsCleared(); + } + } |