use of org.spongepowered.common.interfaces.advancement.IMixinCriterionProgress in project SpongeCommon by SpongePowered.
the class MixinAdvancementProgress method processProgressMap.
private void processProgressMap(AdvancementCriterion criterion, Map<AdvancementCriterion, ICriterionProgress> progressMap) {
if (criterion instanceof OperatorCriterion) {
((OperatorCriterion) criterion).getCriteria().forEach(child -> processProgressMap(child, progressMap));
if (criterion instanceof AndCriterion) {
progressMap.put(criterion, new SpongeAndCriterionProgress(this, (SpongeAndCriterion) criterion));
} else if (criterion instanceof OrCriterion) {
progressMap.put(criterion, new SpongeOrCriterionProgress(this, (SpongeOrCriterion) criterion));
}
} else if (criterion instanceof SpongeScoreCriterion) {
final SpongeScoreCriterion scoreCriterion = (SpongeScoreCriterion) criterion;
for (AdvancementCriterion internalCriterion : scoreCriterion.internalCriteria) {
final IMixinCriterionProgress progress = (IMixinCriterionProgress) this.criteria.get(internalCriterion.getName());
progress.setCriterion(internalCriterion);
progressMap.put(internalCriterion, (ICriterionProgress) progress);
}
progressMap.put(scoreCriterion, new SpongeScoreCriterionProgress(this, scoreCriterion));
} else if (criterion != SpongeEmptyCriterion.INSTANCE) {
final IMixinCriterionProgress progress = (IMixinCriterionProgress) this.criteria.get(criterion.getName());
progress.setCriterion(criterion);
progressMap.put(criterion, (ICriterionProgress) progress);
}
}
use of org.spongepowered.common.interfaces.advancement.IMixinCriterionProgress in project SpongeCommon by SpongePowered.
the class MixinPlayerAdvancements method onUnregisterListenersGetProgress.
@Redirect(method = "registerListeners(Lnet/minecraft/advancements/Advancement;)V", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/advancements/CriterionProgress;isObtained()Z"))
private boolean onUnregisterListenersGetProgress(CriterionProgress progress) {
final AdvancementCriterion criterion = ((org.spongepowered.api.advancement.criteria.CriterionProgress) progress).getCriterion();
final IMixinCriterion mixinCriterion = (IMixinCriterion) criterion;
// Only remove the trigger once the goal is reached
if (mixinCriterion.getScoreCriterion() != null) {
return ((IMixinCriterionProgress) progress).getAdvancementProgress().get(mixinCriterion.getScoreCriterion()).get().achieved();
}
return progress.isObtained();
}
Aggregations