Search in sources :

Example 1 with Advancement

use of net.minecraft.advancement.Advancement in project SpeedRunIGT by RedLime.

the class ClientAdvancementManagerMixin method getCompleteAdvancementsCount.

private int getCompleteAdvancementsCount() {
    int count = 0;
    for (Advancement advancement : this.getManager().getAdvancements()) {
        if (this.advancementProgresses.containsKey(advancement) && advancement.getDisplay() != null && !advancement.getId().getPath().startsWith("recipes")) {
            AdvancementProgress advancementProgress = this.advancementProgresses.get(advancement);
            advancementProgress.init(advancement.getCriteria(), advancement.getRequirements());
            if (advancementProgress.isDone())
                count++;
        }
    }
    return count;
}
Also used : AdvancementProgress(net.minecraft.advancement.AdvancementProgress) Advancement(net.minecraft.advancement.Advancement)

Example 2 with Advancement

use of net.minecraft.advancement.Advancement in project frame-fabric by moddingplayground.

the class RecipeProvider method createFileMapAdvancements.

public Map<Identifier, JsonElement> createFileMapAdvancements() {
    Map<Identifier, JsonElement> map = Maps.newHashMap();
    for (Supplier<AbstractRecipeGenerator> generator : this.getGenerators()) {
        AbstractRecipeGenerator gen = generator.get();
        gen.accept((id, factory) -> factory.offerTo(provider -> {
            JsonObject json = provider.toAdvancementJson();
            if (json != null && map.put(id, json) != null)
                throw new IllegalStateException("Duplicate recipe advancement " + id);
        }, id));
        Identifier rootId = gen.getId("root");
        if (!map.containsKey(rootId)) {
            map.put(rootId, Advancement.Builder.create().criterion("impossible", new ImpossibleCriterion.Conditions()).toJson());
        }
    }
    return map;
}
Also used : JsonObject(com.google.gson.JsonObject) DataType(net.moddingplayground.frame.impl.toymaker.DataType) DataCache(net.minecraft.data.DataCache) Maps(com.google.common.collect.Maps) Supplier(java.util.function.Supplier) ImpossibleCriterion(net.minecraft.advancement.criterion.ImpossibleCriterion) JsonElement(com.google.gson.JsonElement) AbstractRecipeGenerator(net.moddingplayground.frame.api.toymaker.v0.generator.recipe.AbstractRecipeGenerator) RecipeGeneratorStore(net.moddingplayground.frame.api.toymaker.v0.registry.generator.RecipeGeneratorStore) Map(java.util.Map) Identifier(net.minecraft.util.Identifier) Advancement(net.minecraft.advancement.Advancement) DataGenerator(net.minecraft.data.DataGenerator) ImpossibleCriterion(net.minecraft.advancement.criterion.ImpossibleCriterion) Identifier(net.minecraft.util.Identifier) JsonElement(com.google.gson.JsonElement) JsonObject(com.google.gson.JsonObject) AbstractRecipeGenerator(net.moddingplayground.frame.api.toymaker.v0.generator.recipe.AbstractRecipeGenerator)

Example 3 with Advancement

use of net.minecraft.advancement.Advancement in project SpeedRunIGT by RedLime.

the class ClientAdvancementManagerMixin method advancement.

@Redirect(method = "onAdvancements", at = @At(value = "INVOKE", target = "Ljava/util/Map$Entry;getValue()Ljava/lang/Object;"))
public Object advancement(Map.Entry<Identifier, AdvancementProgress> entry) {
    InGameTimer timer = InGameTimer.getInstance();
    Advancement advancement = this.manager.get(entry.getKey());
    AdvancementProgress advancementProgress = entry.getValue();
    assert advancement != null;
    advancementProgress.init(advancement.getCriteria(), advancement.getRequirements());
    if (advancementProgress.isDone() && timer.getStatus() != TimerStatus.NONE) {
        // For Timelines
        if (timer.getCategory() == RunCategories.ANY) {
            if (Objects.equals(advancement.getId().getPath(), "story/follow_ender_eye")) {
                timer.tryInsertNewTimeline("enter_stronghold");
            } else if (Objects.equals(advancement.getId().getPath(), "nether/find_bastion")) {
                timer.tryInsertNewTimeline("enter_bastion");
            } else if (Objects.equals(advancement.getId().getPath(), "nether/find_fortress")) {
                timer.tryInsertNewTimeline("enter_fortress");
            }
        }
        timer.tryInsertNewAdvancement(advancement.getId().toString(), null);
        // How Did We Get Here
        if (timer.getCategory() == RunCategories.HOW_DID_WE_GET_HERE && Objects.equals(advancement.getId().toString(), new Identifier("nether/all_effects").toString())) {
            InGameTimer.complete();
        }
        // Hero of Village
        if (timer.getCategory() == RunCategories.HERO_OF_VILLAGE && Objects.equals(advancement.getId().toString(), new Identifier("adventure/hero_of_the_village").toString())) {
            InGameTimer.complete();
        }
        // Arbalistic
        if (timer.getCategory() == RunCategories.ARBALISTIC && Objects.equals(advancement.getId().toString(), new Identifier("adventure/arbalistic").toString())) {
            InGameTimer.complete();
        }
    }
    return entry.getValue();
}
Also used : AdvancementProgress(net.minecraft.advancement.AdvancementProgress) Identifier(net.minecraft.util.Identifier) InGameTimer(com.redlimerl.speedrunigt.timer.InGameTimer) Advancement(net.minecraft.advancement.Advancement) Redirect(org.spongepowered.asm.mixin.injection.Redirect)

Example 4 with Advancement

use of net.minecraft.advancement.Advancement in project SpeedRunIGT by RedLime.

the class PlayerAdvancementTrackerMixin method getCriteria.

@ModifyArgs(method = "endTrackingCompleted", at = @At(value = "INVOKE", target = "Lnet/minecraft/advancement/criterion/Criterion$ConditionsContainer;<init>(Lnet/minecraft/advancement/criterion/CriterionConditions;Lnet/minecraft/advancement/Advancement;Ljava/lang/String;)V"))
private void getCriteria(Args args) {
    Advancement advancement = args.get(1);
    String criteriaKey = args.get(2);
    if (InGameTimer.getInstance().getStatus() != TimerStatus.NONE) {
        InGameTimer.getInstance().tryInsertNewAdvancement(advancement.getId().toString(), criteriaKey);
    }
}
Also used : Advancement(net.minecraft.advancement.Advancement) ModifyArgs(org.spongepowered.asm.mixin.injection.ModifyArgs)

Aggregations

Advancement (net.minecraft.advancement.Advancement)4 AdvancementProgress (net.minecraft.advancement.AdvancementProgress)2 Identifier (net.minecraft.util.Identifier)2 Maps (com.google.common.collect.Maps)1 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 InGameTimer (com.redlimerl.speedrunigt.timer.InGameTimer)1 Map (java.util.Map)1 Supplier (java.util.function.Supplier)1 ImpossibleCriterion (net.minecraft.advancement.criterion.ImpossibleCriterion)1 DataCache (net.minecraft.data.DataCache)1 DataGenerator (net.minecraft.data.DataGenerator)1 AbstractRecipeGenerator (net.moddingplayground.frame.api.toymaker.v0.generator.recipe.AbstractRecipeGenerator)1 RecipeGeneratorStore (net.moddingplayground.frame.api.toymaker.v0.registry.generator.RecipeGeneratorStore)1 DataType (net.moddingplayground.frame.impl.toymaker.DataType)1 ModifyArgs (org.spongepowered.asm.mixin.injection.ModifyArgs)1 Redirect (org.spongepowered.asm.mixin.injection.Redirect)1