Skip to content

Commit

Permalink
Added additional debugging to solve a but regarding this.d is null (#103
Browse files Browse the repository at this point in the history
)
  • Loading branch information
rowan-vr authored Jan 11, 2023
1 parent 6f9f33a commit 778a5c1
Show file tree
Hide file tree
Showing 5 changed files with 495 additions and 441 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.logging.Level;

public class v1_17_R1 implements InternalsProvider<Advancement, ResourceLocation, AdvancementProgress> {
private static final HashSet<AdvancementTree> loadedTrees = new HashSet<>();
Expand Down Expand Up @@ -136,23 +137,26 @@ public CompletableFuture<Void> loadAdvancements(List<AdvancementTree> trees) {
AdvancementRequirement requirement = cAdvancement.getRequirements().stream()
.filter(req -> req.getType() instanceof me.tippie.customadvancements.advancement.requirement.types.Advancement)
.findFirst().orElse(null);

if (requirement != null) {

try {
CAdvancement advancementRequirement = CustomAdvancements.getAdvancementManager().getAdvancement(requirement.getValue());
Advancement parent = advancements.get(ResourceLocation.tryParse("customadvancements:" + advancementRequirement.getTree() + "/" + advancementRequirement.getLabel()));
if (parent != null) {
advancements.put(location, setParent(advancement, parent));
} else {
try {
if (requirement != null) {

try {
CAdvancement advancementRequirement = CustomAdvancements.getAdvancementManager().getAdvancement(requirement.getValue());
Advancement parent = advancements.get(ResourceLocation.tryParse("customadvancements:" + advancementRequirement.getTree() + "/" + advancementRequirement.getLabel()));
if (parent != null) {
advancements.put(location, setParent(advancement, parent));
} else {
advancements.put(location, setParent(advancement, root));
}
} catch (InvalidAdvancementException e) {
advancements.put(location, setParent(advancement, root));

}
} catch (InvalidAdvancementException e) {
} else {
advancements.put(location, setParent(advancement, root));

}
} else {
advancements.put(location, setParent(advancement, root));
} catch (RuntimeException e) {
CustomAdvancements.getInstance().getLogger().log(Level.SEVERE, "Failed to set put back advancement when setting the parent of " + location + " of tree " + tree.getLabel() + " and advancement " + cAdvancement.getLabel(), e);
}
}
loadedTrees.add(tree);
Expand Down Expand Up @@ -391,11 +395,16 @@ private Advancement setParent(Advancement advancement, Advancement parent) {
for (Advancement child : advancement.getChildren())
children.add(child);

Advancement newAdvancement = advancement.deconstruct().parent(parent).build(advancement.getId());
for (Advancement child : children)
newAdvancement.addChild(child);
try {
Advancement newAdvancement = advancement.deconstruct().parent(parent).build(advancement.getId());

for (Advancement child : children)
newAdvancement.addChild(child);

parent.addChild(newAdvancement);
return newAdvancement;
parent.addChild(newAdvancement);
return newAdvancement;
} catch (Exception e) {
throw new RuntimeException("Failed to set parent of advancement.", e);
}
}
}
Loading

0 comments on commit 778a5c1

Please sign in to comment.