Improve recipe viewer
This commit is contained in:
@@ -28,7 +28,7 @@ name.
|
||||
> [!TIP]
|
||||
> The mods already in the repository are the best reference. `mods/bworld` is the base game itself, written against the
|
||||
> same API as any other mod. `mods/farmersdelight` adds crops, a stove, a cooking pot and a cutting board, and
|
||||
> `mods/recipe_viewer` is a client-only mod that draws over inventory screens.
|
||||
> `mods/recipe_viewer` is a client-only mod with an inventory overlay and a screen of its own.
|
||||
|
||||
## Checking Your Mod
|
||||
|
||||
|
||||
@@ -86,12 +86,12 @@ Overlays get the mouse before the slots:
|
||||
- While a `g.text_input` has the keyboard, keybinds like the inventory key don't fire. Text inputs edit like chat:
|
||||
selecting with shift or the mouse, ctrl+a, and copy, cut and paste.
|
||||
|
||||
`hides_screen()`, if the overlay has one, is asked every frame before `on_render`. While it returns `true` the screen
|
||||
underneath isn't drawn and its slots don't react to the mouse, including the panels mods add outside its box, like the
|
||||
curios slots. The recipe viewer does this while it shows a recipe in the screen's place.
|
||||
|
||||
`on_close()`, if the overlay has one, runs when the screen closes for any reason, like the player closing their
|
||||
inventory. The recipe viewer goes back to its item list then.
|
||||
inventory.
|
||||
|
||||
To show something bigger than fits around the screen, open a [screen](#plain-screens) over it with `ctx.ui.open`, like
|
||||
the recipe viewer's recipes screen does, the way Just Enough Items opens its recipes GUI. Escape goes back to the screen
|
||||
underneath.
|
||||
|
||||
An overlay that throws is removed, with the error in the console.
|
||||
|
||||
@@ -148,9 +148,14 @@ ctx.items.exists(id);
|
||||
ctx.items.name(id); // "Cooked Rice"
|
||||
ctx.items.mod(id); // the name of the mod that added it
|
||||
ctx.recipes.list(type?); // every recipe as its JSON, including mods' own types
|
||||
ctx.options.key_inventory; // the key the player has bound, like Minecraft's Options key mappings
|
||||
```
|
||||
|
||||
`ctx.player` and `ctx.world` only work once the player is in the world, not during `setup`.
|
||||
`ctx.player`, `ctx.world` and `ctx.options` only work once the player is in the world, not during `setup`.
|
||||
|
||||
The key mappings are `key_forward`, `key_back`, `key_left`, `key_right`, `key_jump`, `key_sprint`, `key_sneak`,
|
||||
`key_inventory`, `key_drop` and `key_chat`. A screen that should close on the inventory key, like the recipe viewer's,
|
||||
checks `g.key_pressed(ctx.options.key_inventory)` and calls `ctx.ui.close()`, the way JEI checks `keyInventory`.
|
||||
|
||||
## Not Built Yet
|
||||
|
||||
|
||||
Reference in New Issue
Block a user