Search in sources :

Example 1 with InGameTimer

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

the class KeyBindingMixin method onPress.

@Inject(method = "setKeyPressed", at = @At("TAIL"))
private static void onPress(InputUtil.Key key, boolean pressed, CallbackInfo ci) {
    InGameTimer timer = InGameTimer.getInstance();
    KeyBinding keyBinding = keyToBindings.get(key);
    if (timer.getStatus() == TimerStatus.NONE || timer.getStatus() == TimerStatus.COMPLETED_LEGACY)
        return;
    if (keyBinding != null && pressed) {
        if (// Advancement
        keyBinding == MinecraftClient.getInstance().options.keyAdvancements || Objects.equals(keyBinding.getCategory(), "key.categories.inventory") || Objects.equals(keyBinding.getCategory(), "key.categories.gameplay")) {
            if (InGameTimerUtils.canUnpauseTimer(false)) {
                timer.setPause(false, "pressed key");
            }
            timer.updateFirstInput();
        }
        if (keyBinding == SpeedRunIGT.timerResetKeyBinding) {
            if (timer.getCategory() == RunCategories.CUSTOM && timer.isResettable()) {
                InGameTimer.reset();
            }
        }
        if (keyBinding == SpeedRunIGT.timerStopKeyBinding) {
            if (timer.getCategory() == RunCategories.CUSTOM && timer.isStarted()) {
                InGameTimer.complete();
            }
        }
    }
}
Also used : KeyBinding(net.minecraft.client.options.KeyBinding) InGameTimer(com.redlimerl.speedrunigt.timer.InGameTimer) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 2 with InGameTimer

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

the class MinecraftClientMixin method onJoin.

@Inject(at = @At("HEAD"), method = "joinWorld")
public void onJoin(ClientWorld targetWorld, CallbackInfo ci) {
    InGameTimer timer = InGameTimer.getInstance();
    if (timer.getStatus() == TimerStatus.NONE)
        return;
    InGameTimerUtils.IS_CHANGING_DIMENSION = false;
    if (timer.getStatus() != TimerStatus.NONE) {
        timer.setPause(true, TimerStatus.IDLE, "changed dimension");
    }
    // For Timelines
    if (timer.getCategory() == RunCategories.ANY) {
        if (targetWorld.getDimensionRegistryKey() == DimensionType.THE_NETHER_REGISTRY_KEY) {
            timer.tryInsertNewTimeline("enter_nether");
        } else if (targetWorld.getDimensionRegistryKey() == DimensionType.THE_END_REGISTRY_KEY) {
            timer.tryInsertNewTimeline("enter_end");
        }
    }
    // Enter Nether
    if (timer.getCategory() == RunCategories.ENTER_NETHER && targetWorld.getDimensionRegistryKey() == DimensionType.THE_NETHER_REGISTRY_KEY) {
        InGameTimer.complete();
        return;
    }
    // Enter End
    if (timer.getCategory() == RunCategories.ENTER_END && targetWorld.getDimensionRegistryKey() == DimensionType.THE_END_REGISTRY_KEY) {
        InGameTimer.complete();
    }
    RunCategories.checkAllBossesCompleted();
}
Also used : InGameTimer(com.redlimerl.speedrunigt.timer.InGameTimer) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 3 with InGameTimer

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

the class MinecraftClientMixin method drawTimer.

@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/toast/ToastManager;draw(Lnet/minecraft/client/util/math/MatrixStack;)V", shift = At.Shift.AFTER))
private void drawTimer(CallbackInfo ci) {
    this.profiler.swap("timer");
    InGameTimer timer = InGameTimer.getInstance();
    if (InGameTimerUtils.canUnpauseTimer(true)) {
        if (!(SpeedRunOption.getOption(SpeedRunOptions.WAITING_FIRST_INPUT) && !timer.isStarted())) {
            timer.setPause(false, "rendered");
        } else {
            timer.updateFirstRendered();
        }
    }
    SpeedRunIGT.DEBUG_DATA = timer.getStatus().name();
    if (!this.options.hudHidden && this.world != null && timer.getStatus() != TimerStatus.NONE && (!this.isPaused() || this.currentScreen instanceof CreditsScreen || this.currentScreen instanceof GameMenuScreen || !SpeedRunOption.getOption(SpeedRunOptions.HIDE_TIMER_IN_OPTIONS)) && !(!this.isPaused() && SpeedRunOption.getOption(SpeedRunOptions.HIDE_TIMER_IN_DEBUGS) && this.options.debugEnabled) && !(this.currentScreen instanceof TimerCustomizeScreen)) {
        SpeedRunIGT.TIMER_DRAWER.draw();
    }
}
Also used : CreditsScreen(net.minecraft.client.gui.screen.CreditsScreen) InGameTimer(com.redlimerl.speedrunigt.timer.InGameTimer) TimerCustomizeScreen(com.redlimerl.speedrunigt.gui.screen.TimerCustomizeScreen) GameMenuScreen(net.minecraft.client.gui.screen.GameMenuScreen) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 4 with InGameTimer

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

the class ServerPlayerEntityMixin method onChangedDimension.

@Inject(method = "changeDimension", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/world/ServerWorld;onPlayerChangeDimension(Lnet/minecraft/server/network/ServerPlayerEntity;)V", shift = At.Shift.AFTER))
public void onChangedDimension(ServerWorld destination, CallbackInfoReturnable<Entity> cir) {
    RegistryKey<World> oldRegistryKey = beforeWorld.getRegistryKey();
    RegistryKey<World> newRegistryKey = world.getRegistryKey();
    InGameTimer timer = InGameTimer.getInstance();
    if (timer.getStatus() != TimerStatus.NONE && !timer.isCoop() && InGameTimer.getInstance().getCategory() == RunCategories.ANY) {
        if (oldRegistryKey == World.OVERWORLD && newRegistryKey == World.NETHER) {
            InGameTimerUtils.IS_CAN_WAIT_WORLD_LOAD = InGameTimerUtils.isLoadableBlind(World.NETHER, this.getPos().add(0, 0, 0), lastPortalPos.add(0, 0, 0));
        }
        if (oldRegistryKey == World.NETHER && newRegistryKey == World.OVERWORLD) {
            if (InGameTimerUtils.isBlindTraveled(lastPortalPos)) {
                InGameTimer.getInstance().tryInsertNewTimeline("nether_travel");
            }
            InGameTimerUtils.IS_CAN_WAIT_WORLD_LOAD = InGameTimerUtils.isLoadableBlind(World.OVERWORLD, lastPortalPos.add(0, 0, 0), this.getPos().add(0, 0, 0));
        }
    }
}
Also used : InGameTimer(com.redlimerl.speedrunigt.timer.InGameTimer) World(net.minecraft.world.World) ServerWorld(net.minecraft.server.world.ServerWorld) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 5 with InGameTimer

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

the class DownloadingTerrainScreenMixin method init.

@Override
protected void init() {
    super.init();
    InGameTimer timer = InGameTimer.getInstance();
    if (client != null && client.isInSingleplayer() && !timer.isCoop() && timer.getStatus() != TimerStatus.IDLE) {
        timer.setPause(true, TimerStatus.IDLE, "dimension load?");
    }
}
Also used : InGameTimer(com.redlimerl.speedrunigt.timer.InGameTimer)

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