Skip to content

Commit

Permalink
docs and what
Browse files Browse the repository at this point in the history
  • Loading branch information
0123456789-jpg committed Mar 7, 2024
1 parent 78ff10b commit 6737aac
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 18 deletions.
5 changes: 2 additions & 3 deletions crates/core/advancement/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ maintenance = { status = "passively-maintained" }

[dependencies]
rimecraft-text = { path = "../text" }
rimecraft-identifier = { path = "../../util/identifier", features = [
"vanilla",
] }
rimecraft-identifier = { path = "../../util/identifier" }
rimecraft-item = { path = "../item" }
rimecraft-fmt = { path = "../../util/fmt" }

[lints]
workspace = true
44 changes: 29 additions & 15 deletions crates/core/advancement/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,48 +1,55 @@
//! Advancement related types.

use rimecraft_item::{ItemStack, stack::InitAttachments};
use rimecraft_text::{Text, Texts};
use rimecraft_fmt::Formatting;
use rimecraft_item::{stack::InitAttachments, ItemStack};
use rimecraft_text::Texts;

pub struct Advancement<'r,T, Id,Cx>
/// All information about an advancement.\
/// `'r` is registry lifetime.\
/// Generic type `T` is text type, `Id` is identifier
/// type, `Cx` is content type.
///
/// # MCJE Reference
/// `net.minecraft.advancement.Advancement` in yarn.
pub struct Advancement<'r, T, Id, Cx>
where
T: Texts,
Cx:InitAttachments<Id>
Cx: InitAttachments<Id>,
{
pub parent: Option<Id>,
pub display: Option<DisplayInfo<'r,T, Id,Cx>>,
pub display: Option<DisplayInfo<'r, T, Id, Cx>>,
}

/// # MCJE Reference
///
/// `net.minecraft.advancement.AdvancementDisplay` in yarn.
pub struct DisplayInfo<'r, T, Id, Cx>
where
T: Texts,
Cx:InitAttachments<Id>,
Cx: InitAttachments<Id>,
{
title: T,
description: T,
/// @TODO: ItemStack
icon: ItemStack<'r, Id, Cx>,
background: Option<Id>,
frame: Frame<(), ()>,
frame: Frame<Id>,
show_toast: bool,
announce_to_chat: bool,
hidden: bool,
pos: (f32, f32),
}

impl<'r,T, Id,Cx> DisplayInfo<'r,T, Id,Cx>
impl<'r, T, Id, Cx> DisplayInfo<'r, T, Id, Cx>
where
T: Texts,
Cx:InitAttachments<Id>,
Cx: InitAttachments<Id>,
{
/// Create a new [`DisplayInfo`].
pub fn new(
title: T,
description: T,
icon: ItemStack<'r,Id,Cx>,
icon: ItemStack<'r, Id, Cx>,
background: Option<Id>,
frame: Frame<(), ()>,
frame: Frame<Id>,
show_toast: bool,
announce_to_chat: bool,
hidden: bool,
Expand All @@ -64,12 +71,19 @@ where
self.pos = (x, y);
}

/// Get the title of this advancement.
pub fn title(&self) -> &T {
&self.title
}
}

pub struct Frame<Id, F> {
/// Describes how an advancement will be announced in the chat.\
/// Generic type `Id` represents an identifier type.
///
/// # MCJE Reference
/// `net.minecraft.advancement.AdvancementFrame` in yarn.
#[derive(Debug)]
pub struct Frame<Id> {
id: Id,
format: F,
format: Formatting,
}

0 comments on commit 6737aac

Please sign in to comment.