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();
}
}
}
}
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();
}
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();
}
}
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));
}
}
}
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?");
}
}
Aggregations