Tooltips
This commit is contained in:
+27
-15
@@ -106,8 +106,10 @@ export class Client {
|
||||
if (this.#stopped) {
|
||||
return;
|
||||
}
|
||||
const screen = this.screen;
|
||||
this.screen?.on_tick(delta);
|
||||
this.#handle_keybinds();
|
||||
// a screen that closed itself just now, like chat on enter, had this frame's keys
|
||||
this.#handle_keybinds(screen !== undefined && this.screen === undefined);
|
||||
|
||||
this.#pending_time += delta;
|
||||
let ticks = 0;
|
||||
@@ -143,7 +145,30 @@ export class Client {
|
||||
this.level.tick();
|
||||
}
|
||||
|
||||
#handle_keybinds() {
|
||||
// closed_screen: a screen closed this frame and took its keys, so they don't also open the inventory or pick a
|
||||
// hotbar slot. typing "/give pickaxe" and enter in the same slow frame would otherwise open the inventory
|
||||
#handle_keybinds(closed_screen: boolean) {
|
||||
const player = this.player;
|
||||
|
||||
if (!closed_screen) {
|
||||
this.#handle_keys();
|
||||
}
|
||||
|
||||
if (InputManager.is_mouse_grabbed()) {
|
||||
const mouse = InputManager.get_mouse_delta();
|
||||
player.turn(mouse.x, mouse.y);
|
||||
}
|
||||
InputManager.set_mouse_grabbed(!this.screen);
|
||||
|
||||
this.hit_result = this.level.pick(player.x, player.y + player.eye_height, player.z, player.yaw, player.pitch);
|
||||
this.#handle_block_interaction();
|
||||
|
||||
if (!this.screen && !closed_screen) {
|
||||
this.#handle_hotbar();
|
||||
}
|
||||
}
|
||||
|
||||
#handle_keys() {
|
||||
const options = this.options;
|
||||
const player = this.player;
|
||||
|
||||
@@ -177,19 +202,6 @@ export class Client {
|
||||
if (InputManager.is_key_pressed(options.key_fullscreen)) {
|
||||
InputManager.toggle_fullscreen();
|
||||
}
|
||||
|
||||
if (InputManager.is_mouse_grabbed()) {
|
||||
const mouse = InputManager.get_mouse_delta();
|
||||
player.turn(mouse.x, mouse.y);
|
||||
}
|
||||
InputManager.set_mouse_grabbed(!this.screen);
|
||||
|
||||
this.hit_result = this.level.pick(player.x, player.y + player.eye_height, player.z, player.yaw, player.pitch);
|
||||
this.#handle_block_interaction();
|
||||
|
||||
if (!this.screen) {
|
||||
this.#handle_hotbar();
|
||||
}
|
||||
}
|
||||
|
||||
// the held item while playing, the slot under the mouse in an inventory (only with nothing on the cursor)
|
||||
|
||||
Reference in New Issue
Block a user