Improve recipe viewer
This commit is contained in:
+23
-1
@@ -2,7 +2,7 @@
|
||||
// see docs/modding/networking/index.md
|
||||
import { AIR } from "$/common/constants.ts";
|
||||
import { BlockRegistry, EverythingRegistry, type ItemRegistry } from "$/common/everything_registry.ts";
|
||||
import type { ClientContext, ClientMenu, InventoryOverlay, MenuScreen } from "$/common/mod_api/client.ts";
|
||||
import type { ClientContext, ClientMenu, InventoryOverlay, KeyMappings, MenuScreen } from "$/common/mod_api/client.ts";
|
||||
import { ModListing, ModLoadError, RecipeBook, register_mod_data } from "$/common/mod_loader.ts";
|
||||
import { type Bmod, read_bmod } from "$/common/bmod.ts";
|
||||
import { display_name } from "$/common/utils.ts";
|
||||
@@ -139,6 +139,7 @@ function client_context(listing: ModListing): ClientContext {
|
||||
},
|
||||
hud: not_yet("hud", "HUD elements") as ClientContext["hud"],
|
||||
input: not_yet("input", "keybinds") as ClientContext["input"],
|
||||
options: key_mappings(need_client),
|
||||
net: {
|
||||
on(channel, handler) {
|
||||
own(channel);
|
||||
@@ -189,3 +190,24 @@ function client_context(listing: ModListing): ClientContext {
|
||||
log: (...args) => console.log(`[${mod}]`, ...args),
|
||||
};
|
||||
}
|
||||
|
||||
// the client's key settings as they are when read, so changing them reaches mods
|
||||
function key_mappings(client: () => Client): KeyMappings {
|
||||
const keys = [
|
||||
"key_forward",
|
||||
"key_back",
|
||||
"key_left",
|
||||
"key_right",
|
||||
"key_jump",
|
||||
"key_sprint",
|
||||
"key_sneak",
|
||||
"key_inventory",
|
||||
"key_drop",
|
||||
"key_chat",
|
||||
] as const;
|
||||
const mappings = {} as KeyMappings;
|
||||
for (const key of keys) {
|
||||
Object.defineProperty(mappings, key, { get: () => client().options[key], enumerable: true });
|
||||
}
|
||||
return Object.freeze(mappings);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user