Search in sources :

Example 1 with CriterionProgress

use of net.minecraft.advancements.CriterionProgress 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();
}
Also used : IMixinCriterion(org.spongepowered.common.interfaces.advancement.IMixinCriterion) AdvancementCriterion(org.spongepowered.api.advancement.criteria.AdvancementCriterion) CriterionProgress(net.minecraft.advancements.CriterionProgress) IMixinCriterionProgress(org.spongepowered.common.interfaces.advancement.IMixinCriterionProgress) Redirect(org.spongepowered.asm.mixin.injection.Redirect)

Aggregations

CriterionProgress (net.minecraft.advancements.CriterionProgress)1 AdvancementCriterion (org.spongepowered.api.advancement.criteria.AdvancementCriterion)1 Redirect (org.spongepowered.asm.mixin.injection.Redirect)1 IMixinCriterion (org.spongepowered.common.interfaces.advancement.IMixinCriterion)1 IMixinCriterionProgress (org.spongepowered.common.interfaces.advancement.IMixinCriterionProgress)1