Search in sources :

Example 6 with InGameTimer

use of com.redlimerl.speedrunigt.timer.InGameTimer 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 7 with InGameTimer

use of com.redlimerl.speedrunigt.timer.InGameTimer in project SpeedRunIGT by RedLime.

the class LivingEntityMixin method onDeath.

@Inject(at = @At("HEAD"), method = "onDeath")
public void onDeath(DamageSource source, CallbackInfo ci) {
    @NotNull InGameTimer timer = InGameTimer.getInstance();
    if (this.removed || this.dead || timer.getStatus() == TimerStatus.NONE)
        return;
    // For Timelines
    if (timer.getCategory() == RunCategories.KILL_ALL_BOSSES) {
        if (this.getType() == EntityType.WITHER && this.attackingPlayer != null)
            timer.tryInsertNewTimeline("kill_wither");
        if (this.getType() == EntityType.ELDER_GUARDIAN && this.attackingPlayer != null)
            timer.tryInsertNewTimeline("kill_elder_guardian");
        if (this.getType() == EntityType.ENDER_DRAGON)
            timer.tryInsertNewTimeline("kill_ender_dragon");
    }
    // Kill All Bosses
    if (timer.getCategory() == RunCategories.KILL_ALL_BOSSES) {
        if (this.getType() == EntityType.ENDER_DRAGON) {
            timer.updateMoreData(0, 1);
        }
        if (this.getType() == EntityType.WITHER && this.attackingPlayer != null) {
            timer.updateMoreData(1, 1);
            RunCategories.checkAllBossesCompleted();
        }
        if (this.getType() == EntityType.ELDER_GUARDIAN && this.attackingPlayer != null) {
            timer.updateMoreData(2, 1);
            RunCategories.checkAllBossesCompleted();
        }
    }
    // Kill Wither
    if (timer.getCategory() == RunCategories.KILL_WITHER && this.getType() == EntityType.WITHER && this.attackingPlayer != null) {
        InGameTimer.complete();
    }
    // Kill Elder Guardian
    if (timer.getCategory() == RunCategories.KILL_ELDER_GUARDIAN && this.getType() == EntityType.ELDER_GUARDIAN && this.attackingPlayer != null) {
        InGameTimer.complete();
    }
}
Also used : InGameTimer(com.redlimerl.speedrunigt.timer.InGameTimer) NotNull(org.jetbrains.annotations.NotNull) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

InGameTimer (com.redlimerl.speedrunigt.timer.InGameTimer)7 Inject (org.spongepowered.asm.mixin.injection.Inject)5 TimerCustomizeScreen (com.redlimerl.speedrunigt.gui.screen.TimerCustomizeScreen)1 Advancement (net.minecraft.advancement.Advancement)1 AdvancementProgress (net.minecraft.advancement.AdvancementProgress)1 CreditsScreen (net.minecraft.client.gui.screen.CreditsScreen)1 GameMenuScreen (net.minecraft.client.gui.screen.GameMenuScreen)1 KeyBinding (net.minecraft.client.options.KeyBinding)1 ServerWorld (net.minecraft.server.world.ServerWorld)1 Identifier (net.minecraft.util.Identifier)1 World (net.minecraft.world.World)1 NotNull (org.jetbrains.annotations.NotNull)1 Redirect (org.spongepowered.asm.mixin.injection.Redirect)1