Search in sources :

Example 1 with OperatorCriterion

use of org.spongepowered.api.advancement.criteria.OperatorCriterion 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);
    }
}
Also used : SpongeAndCriterion(org.spongepowered.common.advancement.SpongeAndCriterion) OrCriterion(org.spongepowered.api.advancement.criteria.OrCriterion) SpongeOrCriterion(org.spongepowered.common.advancement.SpongeOrCriterion) SpongeAndCriterionProgress(org.spongepowered.common.advancement.SpongeAndCriterionProgress) ScoreAdvancementCriterion(org.spongepowered.api.advancement.criteria.ScoreAdvancementCriterion) AdvancementCriterion(org.spongepowered.api.advancement.criteria.AdvancementCriterion) OperatorCriterion(org.spongepowered.api.advancement.criteria.OperatorCriterion) SpongeScoreCriterion(org.spongepowered.common.advancement.SpongeScoreCriterion) SpongeAndCriterion(org.spongepowered.common.advancement.SpongeAndCriterion) AndCriterion(org.spongepowered.api.advancement.criteria.AndCriterion) SpongeOrCriterionProgress(org.spongepowered.common.advancement.SpongeOrCriterionProgress) SpongeScoreCriterionProgress(org.spongepowered.common.advancement.SpongeScoreCriterionProgress) IMixinCriterionProgress(org.spongepowered.common.interfaces.advancement.IMixinCriterionProgress) ICriterionProgress(org.spongepowered.common.advancement.ICriterionProgress)

Example 2 with OperatorCriterion

use of org.spongepowered.api.advancement.criteria.OperatorCriterion in project SpongeCommon by SpongePowered.

the class AdvancementProgressMixin method impl$processProgressMap.

private void impl$processProgressMap(AdvancementCriterion criterion, Map<String, ImplementationBackedCriterionProgress> progressMap) {
    if (criterion instanceof OperatorCriterion) {
        ((OperatorCriterion) criterion).criteria().forEach(child -> this.impl$processProgressMap(child, progressMap));
        if (criterion instanceof AndCriterion) {
            progressMap.put(criterion.name(), new SpongeAndCriterionProgress((org.spongepowered.api.advancement.AdvancementProgress) this, (SpongeAndCriterion) criterion));
        } else if (criterion instanceof OrCriterion) {
            progressMap.put(criterion.name(), new SpongeOrCriterionProgress((org.spongepowered.api.advancement.AdvancementProgress) this, (SpongeOrCriterion) criterion));
        }
    } else if (criterion instanceof SpongeScoreCriterion) {
        final SpongeScoreCriterion scoreCriterion = (SpongeScoreCriterion) criterion;
        for (final AdvancementCriterion internalCriterion : scoreCriterion.internalCriteria) {
            final CriterionProgressBridge progress = (CriterionProgressBridge) this.criteria.get(internalCriterion.name());
            progress.bridge$setCriterion(internalCriterion);
            progress.bridge$setAdvancementProgress((org.spongepowered.api.advancement.AdvancementProgress) this);
            progressMap.put(internalCriterion.name(), (ImplementationBackedCriterionProgress) progress);
        }
        progressMap.put(scoreCriterion.name(), new SpongeScoreCriterionProgress((org.spongepowered.api.advancement.AdvancementProgress) this, scoreCriterion));
    } else if (!(criterion instanceof SpongeEmptyCriterion)) {
        final CriterionProgressBridge progress = (CriterionProgressBridge) this.criteria.get(criterion.name());
        progress.bridge$setCriterion(criterion);
        progress.bridge$setAdvancementProgress((org.spongepowered.api.advancement.AdvancementProgress) this);
        progressMap.put(criterion.name(), (ImplementationBackedCriterionProgress) progress);
    }
}
Also used : AdvancementProgress(net.minecraft.advancements.AdvancementProgress) SpongeOrCriterion(org.spongepowered.common.advancement.criterion.SpongeOrCriterion) OrCriterion(org.spongepowered.api.advancement.criteria.OrCriterion) SpongeAndCriterionProgress(org.spongepowered.common.advancement.criterion.SpongeAndCriterionProgress) AdvancementCriterion(org.spongepowered.api.advancement.criteria.AdvancementCriterion) SpongeScoreCriterion(org.spongepowered.common.advancement.criterion.SpongeScoreCriterion) ImplementationBackedCriterionProgress(org.spongepowered.common.advancement.criterion.ImplementationBackedCriterionProgress) AndCriterion(org.spongepowered.api.advancement.criteria.AndCriterion) SpongeAndCriterion(org.spongepowered.common.advancement.criterion.SpongeAndCriterion) SpongeScoreCriterionProgress(org.spongepowered.common.advancement.criterion.SpongeScoreCriterionProgress) SpongeAndCriterion(org.spongepowered.common.advancement.criterion.SpongeAndCriterion) SpongeEmptyCriterion(org.spongepowered.common.advancement.criterion.SpongeEmptyCriterion) CriterionProgressBridge(org.spongepowered.common.bridge.advancements.CriterionProgressBridge) OperatorCriterion(org.spongepowered.api.advancement.criteria.OperatorCriterion) SpongeOrCriterionProgress(org.spongepowered.common.advancement.criterion.SpongeOrCriterionProgress)

Aggregations

AdvancementCriterion (org.spongepowered.api.advancement.criteria.AdvancementCriterion)2 AndCriterion (org.spongepowered.api.advancement.criteria.AndCriterion)2 OperatorCriterion (org.spongepowered.api.advancement.criteria.OperatorCriterion)2 OrCriterion (org.spongepowered.api.advancement.criteria.OrCriterion)2 AdvancementProgress (net.minecraft.advancements.AdvancementProgress)1 ScoreAdvancementCriterion (org.spongepowered.api.advancement.criteria.ScoreAdvancementCriterion)1 ICriterionProgress (org.spongepowered.common.advancement.ICriterionProgress)1 SpongeAndCriterion (org.spongepowered.common.advancement.SpongeAndCriterion)1 SpongeAndCriterionProgress (org.spongepowered.common.advancement.SpongeAndCriterionProgress)1 SpongeOrCriterion (org.spongepowered.common.advancement.SpongeOrCriterion)1 SpongeOrCriterionProgress (org.spongepowered.common.advancement.SpongeOrCriterionProgress)1 SpongeScoreCriterion (org.spongepowered.common.advancement.SpongeScoreCriterion)1 SpongeScoreCriterionProgress (org.spongepowered.common.advancement.SpongeScoreCriterionProgress)1 ImplementationBackedCriterionProgress (org.spongepowered.common.advancement.criterion.ImplementationBackedCriterionProgress)1 SpongeAndCriterion (org.spongepowered.common.advancement.criterion.SpongeAndCriterion)1 SpongeAndCriterionProgress (org.spongepowered.common.advancement.criterion.SpongeAndCriterionProgress)1 SpongeEmptyCriterion (org.spongepowered.common.advancement.criterion.SpongeEmptyCriterion)1 SpongeOrCriterion (org.spongepowered.common.advancement.criterion.SpongeOrCriterion)1 SpongeOrCriterionProgress (org.spongepowered.common.advancement.criterion.SpongeOrCriterionProgress)1 SpongeScoreCriterion (org.spongepowered.common.advancement.criterion.SpongeScoreCriterion)1