Skip to content

Commit

Permalink
✨ Remaining text component changes
Browse files Browse the repository at this point in the history
  • Loading branch information
misode committed Jan 8, 2025
1 parent 3714720 commit 7c0a948
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 37 deletions.
84 changes: 62 additions & 22 deletions java/server/util/text.mcdoc
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,14 @@ struct TextStyle {
strikethrough?: boolean,
obfuscated?: boolean,
insertion?: string,
#[until="1.21.5"]
clickEvent?: ClickEvent,
#[since="1.21.5"]
click_event?: ClickEvent,
#[until="1.21.5"]
hoverEvent?: HoverEvent,
#[since="1.21.5"]
hover_event?: HoverEvent,
}

enum(string) TextColor {
Expand Down Expand Up @@ -140,7 +146,7 @@ enum(string) TextFormat {

struct ClickEvent {
action: ClickEventAction,
value: minecraft:click_event[[action]],
...minecraft:click_event[[action]],
}

enum(string) ClickEventAction {
Expand All @@ -149,22 +155,46 @@ enum(string) ClickEventAction {
RunCommand = "run_command",
SuggestCommand = "suggest_command",
ChangePage = "change_page",
CopyToClipBoard = "copy_to_clipboard",
CopyToClipboard = "copy_to_clipboard",
}

dispatch minecraft:click_event[open_url] to #[url] string
dispatch minecraft:click_event[open_url] to struct OpenUrl {
#[until="1.21.5"]
value: #[url] string,
#[since="1.21.5"]
url: #[url] string,
}

// TODO: In 1.19.1+ commands that send signed messages are disallowed
dispatch minecraft:click_event[run_command] to (
#[until="1.19.1"] #[command(slash="chat")] string |
#[since="1.19.1"] #[command(slash="required")] string |
)
// TODO: In 1.19.1+ commands that send signed messages are disallowed
dispatch minecraft:click_event[run_command] to struct RunCommand {
#[until="1.21.5"]
value: (
#[until="1.19.1"] #[command(slash="chat")] string |
#[since="1.19.1"] #[command(slash="required")] string |
),
#[since="1.21.5"]
command: #[command(slash="allowed")] string,
}

dispatch minecraft:click_event[suggest_command] to #[command(slash="chat")] string
dispatch minecraft:click_event[suggest_command] to struct SuggestCommand {
#[until="1.21.5"]
value: #[command(slash="chat")] string,
#[since="1.21.5"]
command: #[command(slash="chat")] string,
}

dispatch minecraft:click_event[change_page] to #[integer(min=1)] string
dispatch minecraft:click_event[change_page] to struct ChangePage {
/// The page number to go to.
value: (
#[until="1.21.5"] #[integer(min=1)] string |
#[since="1.21.5"] int @ 1.. |
),
}

dispatch minecraft:click_event[copy_to_clipboard] to string
dispatch minecraft:click_event[copy_to_clipboard] to struct CopyToClipboard {
/// The text value to copy to the clipboard.
value: string,
}

struct HoverEvent {
action: HoverEventAction,
Expand All @@ -177,17 +207,19 @@ enum(string) HoverEventAction {
ShowEntity = "show_entity",
}

dispatch minecraft:hover_event[show_text] to struct ShowTextHoverEvent {
#[deprecated="1.16"]
dispatch minecraft:hover_event[show_text] to struct ShowText {
#[deprecated="1.16"] #[until="1.21.5"]
value?: Text,
#[since="1.16"]
#[since="1.16"] #[until="1.21.5"]
contents?: Text,
#[since="1.21.5"]
text: Text,
}

dispatch minecraft:hover_event[show_item] to struct ShowItemHoverEvent {
#[deprecated="1.16"]
dispatch minecraft:hover_event[show_item] to struct ShowItem {
#[deprecated="1.16"] #[until="1.21.5"]
value?: #[nbt=ItemStack] string,
#[since="1.16"]
#[since="1.16"] #[until="1.21.5"]
contents?: struct ItemHoverContent {
id: #[id="item"] string,
count?: int,
Expand All @@ -196,21 +228,29 @@ dispatch minecraft:hover_event[show_item] to struct ShowItemHoverEvent {
#[since="1.20.5"]
components?: DataComponentPatch<minecraft:item_component[[id]]>,
},
#[since="1.21.5"]
...ItemStack,
}

dispatch minecraft:hover_event[show_entity] to struct ShowEntityHoverEvent {
#[deprecated="1.16"]
value?: struct OldEntityHover {
dispatch minecraft:hover_event[show_entity] to struct ShowEntity {
#[deprecated="1.16"] #[until="1.21.5"]
value?: struct EntityHoverValue {
name?: string,
type?: string,
id?: string,
},
#[since="1.16"]
contents?: struct EntityHoverContent {
type: #[id="entity_type"] string,
id: #[uuid] (#[canonical] [int] @ 4 | string),
name?: Text,
type?: #[id="entity_type"] string,
id?: #[uuid] string,
},
#[since="1.21.5"]
...struct EntityTooltipInfo {
id: #[id="entity_type"] string,
uuid: #[uuid] (#[canonical] [int] @ 4 | string),
name?: Text,
}
}

enum(string) Keybind {
Expand Down
24 changes: 17 additions & 7 deletions java/server/world/block/command_block.mcdoc
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
use ::java::server::util::text::Text

dispatch minecraft:block_entity[command_block] to struct CommandBlock {
...super::BlockEntity,
...super::Nameable,
Command?: #[command(slash="allowed",empty="allowed",max_length=32500)] string,
/// Success count of the last command.
SuccessCount?: int,
/// Output of the last command.
LastOutput?: string,
/// Whether to record command output.
TrackOutput?: boolean,
...BaseCommandBlock,
/// Whether it is powered by redstone.
powered?: boolean,
/// Whether it is automatically powered.
auto?: boolean,
/// Whether the previous command block was successful when the command block was executed.
/// This is always true for non-conditional command blocks.
conditionMet?: boolean,
}

struct BaseCommandBlock {
/// The command to run.
Command?: #[command(slash="allowed",empty="allowed",max_length=32500)] string,
/// Success count of the last command.
SuccessCount?: int,
/// Output of the last command.
LastOutput?: (
#[until="1.21.5"] #[text_component] string |
#[since="1.21.5"] Text |
),
/// Whether to record command output.
TrackOutput?: boolean,
/// Whether to record the tick of the latest command execution.
UpdateLastExecution?: boolean,
/// Tick of the latest command execution.
Expand Down
9 changes: 2 additions & 7 deletions java/server/world/entity/minecart.mcdoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use super::super::block::spawner::SpawnPotential
use super::super::block::spawner::SpawnerEntry
use super::super::block::command_block::BaseCommandBlock
use super::super::entity::AnyEntity
use ::java::server::util::BlockState
use ::java::server::util::SlottedItem
Expand Down Expand Up @@ -31,13 +32,7 @@ dispatch minecraft:entity[chest_minecart] to struct ChestMinecart {

dispatch minecraft:entity[command_block_minecart] to struct CommandBlockMinecart {
...Minecart,
Command?: #[command(slash="allowed",empty="allowed",max_length=32500)] string,
/// Success count of the last command.
SuccessCount?: int,
/// Output of the last command.
LastOutput?: string,
/// Whether to record command output.
TrackOutput?: boolean,
...BaseCommandBlock,
}

dispatch minecraft:entity[furnace_minecart] to struct FurnaceMinecart {
Expand Down
8 changes: 7 additions & 1 deletion java/server/world/entity/mob/breedable/saddled.mcdoc
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
dispatch minecraft:entity[pig] to struct Saddled {
struct Saddled {
...super::Breedable,
/// Whether there is a saddle on it.
Saddle?: boolean,
}

dispatch minecraft:entity[pig] to struct Pig {
...Saddled,
#[since="1.21.5"]
variant?: #[id="pig_variant"] string,
}

#[since="1.16"]
dispatch minecraft:entity[strider] to Saddled

0 comments on commit 7c0a948

Please sign in to comment.