Search in sources :

Example 6 with IMixinCriterion

use of org.spongepowered.common.interfaces.advancement.IMixinCriterion in project SpongeCommon by SpongePowered.

the class MixinPlayerAdvancements method onUnregisterListenersGetProgress.

@Nullable
@Redirect(method = "unregisterListeners", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/advancements/AdvancementProgress;getCriterionProgress(Ljava/lang/String;)Lnet/minecraft/advancements/CriterionProgress;"))
private CriterionProgress onUnregisterListenersGetProgress(AdvancementProgress advancementProgress, String criterion) {
    final org.spongepowered.api.advancement.Advancement advancement = ((org.spongepowered.api.advancement.AdvancementProgress) advancementProgress).getAdvancement();
    final AdvancementCriterion advancementCriterion = (AdvancementCriterion) ((Advancement) advancement).getCriteria().get(criterion);
    final IMixinCriterion mixinCriterion = (IMixinCriterion) advancementCriterion;
    // Only remove the trigger once the goal is reached
    if (mixinCriterion.getScoreCriterion() != null && !((org.spongepowered.api.advancement.AdvancementProgress) advancementProgress).get(mixinCriterion.getScoreCriterion()).get().achieved()) {
        return null;
    }
    return advancementProgress.getCriterionProgress(criterion);
}
Also used : AdvancementProgress(net.minecraft.advancements.AdvancementProgress) IMixinAdvancementProgress(org.spongepowered.common.interfaces.advancement.IMixinAdvancementProgress) IMixinCriterion(org.spongepowered.common.interfaces.advancement.IMixinCriterion) AdvancementCriterion(org.spongepowered.api.advancement.criteria.AdvancementCriterion) Advancement(net.minecraft.advancements.Advancement) Redirect(org.spongepowered.asm.mixin.injection.Redirect) Nullable(javax.annotation.Nullable)

Example 7 with IMixinCriterion

use of org.spongepowered.common.interfaces.advancement.IMixinCriterion in project SpongeCommon by SpongePowered.

the class SpongeCriterionBuilder method build0.

@Override
AdvancementCriterion build0() {
    final Criterion criterion = new Criterion((ICriterionInstance) this.trigger);
    ((IMixinCriterion) criterion).setName(this.name);
    return (AdvancementCriterion) criterion;
}
Also used : IMixinCriterion(org.spongepowered.common.interfaces.advancement.IMixinCriterion) IMixinCriterion(org.spongepowered.common.interfaces.advancement.IMixinCriterion) Criterion(net.minecraft.advancements.Criterion) AdvancementCriterion(org.spongepowered.api.advancement.criteria.AdvancementCriterion) AdvancementCriterion(org.spongepowered.api.advancement.criteria.AdvancementCriterion)

Aggregations

AdvancementCriterion (org.spongepowered.api.advancement.criteria.AdvancementCriterion)7 IMixinCriterion (org.spongepowered.common.interfaces.advancement.IMixinCriterion)7 Advancement (net.minecraft.advancements.Advancement)3 ScoreAdvancementCriterion (org.spongepowered.api.advancement.criteria.ScoreAdvancementCriterion)3 Player (org.spongepowered.api.entity.living.player.Player)3 CriterionEvent (org.spongepowered.api.event.advancement.CriterionEvent)3 Cause (org.spongepowered.api.event.cause.Cause)3 SpongeScoreCriterion (org.spongepowered.common.advancement.SpongeScoreCriterion)3 IMixinCriterionProgress (org.spongepowered.common.interfaces.advancement.IMixinCriterionProgress)3 IMixinPlayerAdvancements (org.spongepowered.common.interfaces.advancement.IMixinPlayerAdvancements)3 Criterion (net.minecraft.advancements.Criterion)2 CriterionProgress (org.spongepowered.api.advancement.criteria.CriterionProgress)2 ScoreCriterionProgress (org.spongepowered.api.advancement.criteria.ScoreCriterionProgress)2 Overwrite (org.spongepowered.asm.mixin.Overwrite)2 Inject (org.spongepowered.asm.mixin.injection.Inject)2 Redirect (org.spongepowered.asm.mixin.injection.Redirect)2 ICriterionProgress (org.spongepowered.common.advancement.ICriterionProgress)2 SpongeAndCriterionProgress (org.spongepowered.common.advancement.SpongeAndCriterionProgress)2 SpongeOrCriterionProgress (org.spongepowered.common.advancement.SpongeOrCriterionProgress)2 SpongeScoreCriterionProgress (org.spongepowered.common.advancement.SpongeScoreCriterionProgress)2