fix 1.21.5 item and entity hover
This commit is contained in:
parent
80e6da9ffb
commit
67f26cf9bd
@ -296,7 +296,8 @@ pub(crate) fn build() -> TokenStream {
|
|||||||
#constants
|
#constants
|
||||||
|
|
||||||
pub fn translated_name(&self) -> TextComponent {
|
pub fn translated_name(&self) -> TextComponent {
|
||||||
serde_json::from_str(self.components.item_name.unwrap()).expect("Could not parse item name.")
|
// TODO
|
||||||
|
TextComponent::text(self.components.item_name.unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "Try to parse an item from a resource location string."]
|
#[doc = "Try to parse an item from a resource location string."]
|
||||||
|
|||||||
@ -16,18 +16,16 @@ pub enum HoverEvent {
|
|||||||
/// Number of the items in the stack
|
/// Number of the items in the stack
|
||||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
count: Option<i32>,
|
count: Option<i32>,
|
||||||
/// NBT information about the item (sNBT format)
|
// #[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
// components: Option<Cow<'static, str>>,
|
||||||
tag: Option<Cow<'static, str>>,
|
|
||||||
},
|
},
|
||||||
/// Shows an entity.
|
/// Shows an entity.
|
||||||
ShowEntity {
|
ShowEntity {
|
||||||
|
/// The entity's ID Entity Type
|
||||||
|
id: Cow<'static, str>,
|
||||||
/// The entity's UUID
|
/// The entity's UUID
|
||||||
/// The UUID cannot use uuid::Uuid because its serialization parses it into bytes, so its double bytes serialized
|
/// The UUID cannot use uuid::Uuid because its serialization parses it into bytes, so its double bytes serialized
|
||||||
id: Cow<'static, str>,
|
uuid: Cow<'static, str>,
|
||||||
/// Resource identifier of the entity
|
|
||||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
||||||
r#type: Option<Cow<'static, str>>,
|
|
||||||
/// Optional custom name for the entity
|
/// Optional custom name for the entity
|
||||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
name: Option<Vec<TextComponentBase>>,
|
name: Option<Vec<TextComponentBase>>,
|
||||||
@ -40,13 +38,13 @@ impl HoverEvent {
|
|||||||
value: vec![text.0],
|
value: vec![text.0],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn show_entity<P>(id: P, kind: P, name: Option<TextComponent>) -> Self
|
pub fn show_entity<P>(uuid: P, kind: P, name: Option<TextComponent>) -> Self
|
||||||
where
|
where
|
||||||
P: Into<Cow<'static, str>>,
|
P: Into<Cow<'static, str>>,
|
||||||
{
|
{
|
||||||
Self::ShowEntity {
|
Self::ShowEntity {
|
||||||
id: id.into(),
|
id: kind.into(),
|
||||||
r#type: Some(kind.into()),
|
uuid: uuid.into(),
|
||||||
name: match name {
|
name: match name {
|
||||||
Some(name) => Some(vec![name.0]),
|
Some(name) => Some(vec![name.0]),
|
||||||
None => None,
|
None => None,
|
||||||
|
|||||||
@ -67,7 +67,6 @@ impl CommandExecutor for Executor {
|
|||||||
.hover_event(HoverEvent::ShowItem {
|
.hover_event(HoverEvent::ShowItem {
|
||||||
id: item_name.to_string().into(),
|
id: item_name.to_string().into(),
|
||||||
count: Some(item_count),
|
count: Some(item_count),
|
||||||
tag: None,
|
|
||||||
}),
|
}),
|
||||||
TextComponent::text(targets[0].gameprofile.name.to_string())
|
TextComponent::text(targets[0].gameprofile.name.to_string())
|
||||||
.hover_event(HoverEvent::show_entity(
|
.hover_event(HoverEvent::show_entity(
|
||||||
@ -97,7 +96,6 @@ impl CommandExecutor for Executor {
|
|||||||
.hover_event(HoverEvent::ShowItem {
|
.hover_event(HoverEvent::ShowItem {
|
||||||
id: item_name.to_string().into(),
|
id: item_name.to_string().into(),
|
||||||
count: Some(item_count),
|
count: Some(item_count),
|
||||||
tag: None,
|
|
||||||
}),
|
}),
|
||||||
TextComponent::text(targets.len().to_string()),
|
TextComponent::text(targets.len().to_string()),
|
||||||
],
|
],
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user