mirror of
https://github.com/horizon-rust/horizon.git
synced 2026-11-12 18:35:16 -10:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2ebb6ae09d | ||
|
|
d6369c19f8 |
No files matched your search
@@ -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>,
|
||||
}
|
||||
Reference in new issue
Block a user