Compare commits

...
Author SHA1 Message Date
Horizon agentandClaude Opus 5.5 2ebb6ae09d NativeRecipeLayout stays in native_hooks.rs
The move now starts one type later, so it no longer touches the lines
#12279 changes right above it (NativePlayer and NativeClock move out there):
the two PRs merge without a conflict in either order.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-09 18:17:04 +01:00
Horizon agentandClaude Opus 5.5 d6369c19f8 Move the native recipe data types out of native_hooks.rs
A pure move: NativeRecipeLayout, NativeRecipeView, NativeRecipeStack,
NativeRecipeKind, NativeRecipe, NativeItem and NativeRecipes go as they are
into native_recipe_types.rs, re-exported under their old path. native_hooks.rs
(12781 lines) may not grow, and the mod API generator only accepts hooks
defined in it, so new hooks (#12268's menu_slot_display) need the room.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-09 18:00:18 +01:00
2 changed files with 102 additions and 92 deletions

No files matched your search

+5 -92
View File
@@ -1949,98 +1949,11 @@ pub(crate) enum NativeRecipeLayout {
Brewing,
}
/// A recipe the panel shows (`native_panel_recipes`). Each slot, and the
/// result, cycles through its stacks, one a second; an empty slot shows
/// nothing.
#[derive(Clone, Debug, PartialEq)]
pub(crate) struct NativeRecipeView {
pub(crate) layout: NativeRecipeLayout,
/// The grid's size (`Grid` only), at most 3 x 3.
pub(crate) width: u32,
pub(crate) height: u32,
pub(crate) slots: Vec<Vec<NativeStack>>,
pub(crate) results: Vec<NativeStack>,
/// A short line under the recipe (a cooking time), or "".
pub(crate) note: String,
/// The action button beside it: none, enabled, or shown greyed.
pub(crate) action: Option<bool>,
}
/// An item of [`NativeRecipes::items`], by its index there, with a count
/// and the components it has beyond the item's own, in vanilla's item
/// syntax (`[minecraft:potion_contents={potion:"minecraft:swiftness"}]`),
/// or "".
#[derive(Clone, Debug, Default, PartialEq)]
pub(crate) struct NativeRecipeStack {
pub(crate) item: u32,
pub(crate) count: u32,
pub(crate) components: String,
}
/// The station a recipe is made at.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(crate) enum NativeRecipeKind {
CraftingShaped,
CraftingShapeless,
Smelting,
Blasting,
Smoking,
Campfire,
Stonecutting,
Smithing,
Brewing,
}
/// A recipe of [`NativeRecipes`].
#[derive(Clone, Debug, PartialEq)]
pub(crate) struct NativeRecipe {
/// `minecraft:oak_planks`.
pub(crate) id: String,
pub(crate) kind: NativeRecipeKind,
/// The recipe book's tab (`crafting_building_blocks`, `furnace_food`),
/// or "".
pub(crate) category: String,
/// Recipes the book shows on one button share a group, or "".
pub(crate) group: String,
/// A shaped recipe's grid: `slots` holds its cells row by row. 0 for
/// the other kinds.
pub(crate) width: u32,
pub(crate) height: u32,
/// Each slot's stacks, any one of which fits; an empty list is an empty
/// cell. Cooking and stonecutting: the input. Smithing: the template,
/// the base, the addition. Brewing: the bottle, the reagent.
pub(crate) slots: Vec<Vec<NativeRecipeStack>>,
/// What it makes; several when that varies (a trim on any armour).
pub(crate) results: Vec<NativeRecipeStack>,
/// Cooking: game ticks and experience; 0 for the other kinds.
pub(crate) cooking_time: u32,
pub(crate) experience: f32,
/// The recipe book's id for it (one per way the book shows it), as
/// `native_known_recipes` lists them; -1 for the kinds the book doesn't
/// show (campfire, stonecutting, smithing, brewing).
pub(crate) book_id: i32,
}
/// An item of [`NativeRecipes::items`].
#[derive(Clone, Debug, Default, PartialEq)]
pub(crate) struct NativeItem {
/// `minecraft:diamond`, `<mod>:<path>`.
pub(crate) id: String,
/// In the player's language.
pub(crate) name: String,
/// Its item tags, without the `#`.
pub(crate) tags: Vec<String>,
}
/// Every item and recipe the game knows (`native_recipes`): `items` in the
/// registry's order, which each [`NativeRecipeStack::item`] indexes; the
/// recipes are the book's in its order, then campfire, stonecutting,
/// smithing and brewing.
#[derive(Clone, Debug, Default, PartialEq)]
pub(crate) struct NativeRecipes {
pub(crate) items: Vec<NativeItem>,
pub(crate) recipes: Vec<NativeRecipe>,
}
#[path = "native_recipe_types.rs"]
mod recipe_types;
pub(crate) use recipe_types::{
NativeItem, NativeRecipe, NativeRecipeKind, NativeRecipeStack, NativeRecipeView, NativeRecipes,
};
/// The mappings `native_mapping` answers for, with the key their default
/// binding is (none: a mouse button, attack or use).
@@ -0,0 +1,97 @@
//! The recipe data a native mod reads (`native_recipes`, `native_panel_recipes`): moved
//! as is out of native_hooks.rs, which is over the file-size limit (docs/layers.md#file-size).
use super::NativeRecipeLayout;
use horizon_client::mod_api::NativeStack;
/// A recipe the panel shows (`native_panel_recipes`). Each slot, and the
/// result, cycles through its stacks, one a second; an empty slot shows
/// nothing.
#[derive(Clone, Debug, PartialEq)]
pub(crate) struct NativeRecipeView {
pub(crate) layout: NativeRecipeLayout,
/// The grid's size (`Grid` only), at most 3 x 3.
pub(crate) width: u32,
pub(crate) height: u32,
pub(crate) slots: Vec<Vec<NativeStack>>,
pub(crate) results: Vec<NativeStack>,
/// A short line under the recipe (a cooking time), or "".
pub(crate) note: String,
/// The action button beside it: none, enabled, or shown greyed.
pub(crate) action: Option<bool>,
}
/// An item of [`NativeRecipes::items`], by its index there, with a count
/// and the components it has beyond the item's own, in vanilla's item
/// syntax (`[minecraft:potion_contents={potion:"minecraft:swiftness"}]`),
/// or "".
#[derive(Clone, Debug, Default, PartialEq)]
pub(crate) struct NativeRecipeStack {
pub(crate) item: u32,
pub(crate) count: u32,
pub(crate) components: String,
}
/// The station a recipe is made at.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(crate) enum NativeRecipeKind {
CraftingShaped,
CraftingShapeless,
Smelting,
Blasting,
Smoking,
Campfire,
Stonecutting,
Smithing,
Brewing,
}
/// A recipe of [`NativeRecipes`].
#[derive(Clone, Debug, PartialEq)]
pub(crate) struct NativeRecipe {
/// `minecraft:oak_planks`.
pub(crate) id: String,
pub(crate) kind: NativeRecipeKind,
/// The recipe book's tab (`crafting_building_blocks`, `furnace_food`),
/// or "".
pub(crate) category: String,
/// Recipes the book shows on one button share a group, or "".
pub(crate) group: String,
/// A shaped recipe's grid: `slots` holds its cells row by row. 0 for
/// the other kinds.
pub(crate) width: u32,
pub(crate) height: u32,
/// Each slot's stacks, any one of which fits; an empty list is an empty
/// cell. Cooking and stonecutting: the input. Smithing: the template,
/// the base, the addition. Brewing: the bottle, the reagent.
pub(crate) slots: Vec<Vec<NativeRecipeStack>>,
/// What it makes; several when that varies (a trim on any armour).
pub(crate) results: Vec<NativeRecipeStack>,
/// Cooking: game ticks and experience; 0 for the other kinds.
pub(crate) cooking_time: u32,
pub(crate) experience: f32,
/// The recipe book's id for it (one per way the book shows it), as
/// `native_known_recipes` lists them; -1 for the kinds the book doesn't
/// show (campfire, stonecutting, smithing, brewing).
pub(crate) book_id: i32,
}
/// An item of [`NativeRecipes::items`].
#[derive(Clone, Debug, Default, PartialEq)]
pub(crate) struct NativeItem {
/// `minecraft:diamond`, `<mod>:<path>`.
pub(crate) id: String,
/// In the player's language.
pub(crate) name: String,
/// Its item tags, without the `#`.
pub(crate) tags: Vec<String>,
}
/// Every item and recipe the game knows (`native_recipes`): `items` in the
/// registry's order, which each [`NativeRecipeStack::item`] indexes; the
/// recipes are the book's in its order, then campfire, stonecutting,
/// smithing and brewing.
#[derive(Clone, Debug, Default, PartialEq)]
pub(crate) struct NativeRecipes {
pub(crate) items: Vec<NativeItem>,
pub(crate) recipes: Vec<NativeRecipe>,
}