From 060c913c3097ae730fb2c04b7835733dcc85a1a4 Mon Sep 17 00:00:00 2001 From: Alexander Medvedev Date: Mon, 24 Aug 2026 16:06:22 +0200 Subject: [PATCH] some more stuff --- v0.1/entity.wit | 2 +- v0.1/event.wit | 23 +++++- v0.1/player.wit | 14 +++- v0.1/text.wit | 27 +++++++ v0.1/world.wit | 192 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 253 insertions(+), 5 deletions(-) diff --git a/v0.1/entity.wit b/v0.1/entity.wit index 7cc21c5..1873f84 100644 --- a/v0.1/entity.wit +++ b/v0.1/entity.wit @@ -1 +1 @@ -interface entity { use %world.{entity, raycast-result, block-direction}; } +interface entity { use %world.{entity, raycast-result, ray-trace-block-result, ray-trace-entity-result, block-direction}; } diff --git a/v0.1/event.wit b/v0.1/event.wit index 3dd3e3c..c97280e 100644 --- a/v0.1/event.wit +++ b/v0.1/event.wit @@ -10,6 +10,7 @@ interface event { use java-packets.{serverbound-packet as java-serverbound-packet, clientbound-packet as java-clientbound-packet}; use bedrock-packets.{serverbound-packet as bedrock-serverbound-packet, clientbound-packet as bedrock-clientbound-packet}; use uuid.{uuid}; + use java-dialogs.{dialog}; variant serverbound-packet { java(java-serverbound-packet), @@ -282,10 +283,22 @@ interface event { response-data: option, } - record custom-click-action-event-data { + record dialog-click-action-event-data { player: player, id: string, payload: option>, + cancelled: bool, + } + + record dialog-show-event-data { + player: player, + dialog: dialog, + cancelled: bool, + } + + record dialog-clear-event-data { + player: player, + cancelled: bool, } record server-command-event-data { @@ -1900,7 +1913,9 @@ interface event { block-grow-event, block-place-event, bedrock-form-response-event, - custom-click-action-event, + dialog-click-action-event, + dialog-show-event, + dialog-clear-event, server-command-event, server-list-ping-event, server-load-event, @@ -2173,8 +2188,10 @@ interface event { block-can-build-event(block-can-build-event-data), block-grow-event(block-grow-event-data), block-place-event(block-place-event-data), + dialog-click-action-event(dialog-click-action-event-data), + dialog-show-event(dialog-show-event-data), + dialog-clear-event(dialog-clear-event-data), bedrock-form-response-event(bedrock-form-response-event-data), - custom-click-action-event(custom-click-action-event-data), server-command-event(server-command-event-data), server-list-ping-event(server-list-ping-event-data), server-load-event(server-load-event-data), diff --git a/v0.1/player.wit b/v0.1/player.wit index 238ee00..b44a9bf 100644 --- a/v0.1/player.wit +++ b/v0.1/player.wit @@ -2,7 +2,7 @@ interface player { use common.{hand, position, game-mode}; use item-stack.{item-stack}; - use %world.{%world, entity}; + use %world.{%world, entity, ray-trace-block-result, ray-trace-entity-result}; use permission.{permission-level}; use text.{text-component}; use gui.{gui}; @@ -1086,8 +1086,20 @@ interface player { /// Checks if an item is currently on cooldown. has-item-cooldown: func(item-id: string) -> bool; + /// Performs a ray-trace from the player's eye position in looking direction to find the targeted block. + ray-trace-block: func(max-distance: f64, include-fluids: bool) -> option; + + /// Performs a ray-trace from the player's eye position in looking direction to find the targeted entity. + ray-trace-entity: func(max-distance: f64) -> option; + + /// Returns the entity currently targeted in the looking direction within the specified distance. + get-target-entity: func(max-distance: f64) -> option; + /// Raycasts from the player's eyes to find the block being targeted. get-target-block: func(max-distance: u32) -> option; + + /// Performs a raycast from the player's eyes to find the exact block and face being targeted. + get-target-block-exact: func(max-distance: f64, include-fluids: bool) -> option; /// Launches a projectile from the player's eyes in their line of sight. launch-projectile: func(%type: projectile-type) -> option; diff --git a/v0.1/text.wit b/v0.1/text.wit index cad5d6f..82f626a 100644 --- a/v0.1/text.wit +++ b/v0.1/text.wit @@ -2,18 +2,42 @@ interface text { use common.{named-color, rgb-color, argb-color}; resource text-component { + /// Creates a plain text component. text: static func(plain: string) -> text-component; + /// Creates a translation component. translate: static func(key: string, %with: list) -> text-component; + /// Creates a translation component with a Bedrock-specific fallback key. + translate-cross: static func(java-key: string, bedrock-key: string, %with: list) -> text-component; + /// Creates an entity names / selector text component. + entity-names: static func(selector: string, separator: option) -> text-component; + /// Creates a keybind text component (e.g., "key.jump"). + keybind: static func(keybind: string) -> text-component; + /// Creates a custom translation component. + custom: static func(namespace: string, key: string, locale: string, %with: list) -> text-component; + + /// Parses a legacy Minecraft formatted string (using section signs '§' by default) into a text component. + from-legacy-string: static func(input: string) -> text-component; + /// Parses a legacy formatted string using a custom color code symbol (e.g. '&' or '§'). + from-legacy-string-with-code: static func(input: string, code-symbol: char) -> text-component; + + /// Parses a standard Minecraft JSON text component. + from-json: static func(json: string) -> result; + /// Serializes the text component to JSON format. + to-json: func() -> string; add-child: func(child: text-component); add-text: func(text: string); get-text: func() -> string; encode: func() -> list; + to-pretty-console: func() -> string; // Style color-named: func(color: named-color); color-rgb: func(color: rgb-color); + gradient-named: func(colors: list); + gradient: func(colors: list); + rainbow: func(); bold: func(value: bool); italic: func(value: bool); underlined: func(value: bool); @@ -27,8 +51,10 @@ interface text { // Click events click-open-url: func(url: string); + click-open-file: func(path: string); click-run-command: func(command: string); click-suggest-command: func(command: string); + click-change-page: func(page: u32); click-copy-to-clipboard: func(text: string); // Hover events @@ -39,3 +65,4 @@ interface text { hover-show-entity: func(entity-type: string, id: string, name: option); } } + diff --git a/v0.1/world.wit b/v0.1/world.wit index 8d4d36e..5242bf5 100644 --- a/v0.1/world.wit +++ b/v0.1/world.wit @@ -104,10 +104,20 @@ interface %world { skip-block-added-callback, } + /// Flammability properties of a block. + record flammable { + spread-chance: u8, + burn-chance: u8, + } + /// Detailed information about a block's state. record block-state { /// The internal numerical ID of the block state. id: u16, + /// The numerical ID of the parent block type. + block-id: u16, + /// The namespaced identifier of the parent block type. + block-name: string, /// The light level emitted by this block (0-15). luminance: u8, /// How much light this block blocks. @@ -164,6 +174,8 @@ interface %world { up-center-solid: bool, /// The color of this block when displayed on a map. map-color: u8, + /// The block state's property key-value pairs (e.g. facing=north). + properties: list>, } /// Musical instruments used by note blocks. @@ -197,6 +209,40 @@ interface %world { custom-head, } + /// Static definition of a Minecraft block type. + record block { + /// The internal numerical ID of the block type. + id: u16, + /// The unique namespaced ID (e.g., "minecraft:stone"). + name: string, + /// How hard the block is to break (-1.0 for unbreakable blocks). + hardness: f32, + /// Resistance to explosions. + blast-resistance: f32, + /// The color of this block when displayed on a map. + map-color: u8, + /// The friction coefficient (0.6 default, 0.98 for ice). + slipperiness: f32, + /// How much this block affects entity walk speed. + velocity-multiplier: f32, + /// How much this block affects entity jump height. + jump-velocity-multiplier: f32, + /// The item ID associated with this block in inventory/drops. + item-id: u16, + /// The default block state ID when placed without extra properties. + default-state-id: u16, + /// All valid state IDs belonging to this block type. + state-ids: list, + /// Whether this block is solid by default. + is-solid: bool, + /// Whether this block is considered air. + is-air: bool, + /// Whether this block is flammable. + is-flammable: bool, + /// Flammability details if flammable. + flammable: option, + } + /// A simple wrapper for a block state ID. record block-state-id { id: u16, @@ -358,6 +404,15 @@ interface %world { /// Performs a raycast from the entity's eye position in its looking direction. raycast: func(max-distance: f64, fluid-handling: bool) -> option; + /// Performs a ray-trace from the entity's eye position in its looking direction to find the targeted block. + ray-trace-block: func(max-distance: f64, include-fluids: bool) -> option; + + /// Performs a ray-trace from the entity's eye position in its looking direction to find the targeted entity. + ray-trace-entity: func(max-distance: f64) -> option; + + /// Returns the entity currently targeted in the looking direction within the specified distance. + get-target-entity: func(max-distance: f64) -> option; + /// Sets a namespaced custom data value on this entity. set-custom-data: func(namespace: string, key: string, value: nbt-tree); /// Returns a namespaced custom data value from this entity, if set. @@ -376,6 +431,26 @@ interface %world { face: block-direction, } + /// Detailed result of a block ray-trace operation. + record ray-trace-block-result { + /// The block position that was hit. + pos: block-pos, + /// The face of the block that was hit. + face: block-direction, + /// The exact hit coordinates in world space. + hit-pos: position, + } + + /// Result of an entity ray-trace operation. + record ray-trace-entity-result { + /// The entity that was hit. + entity: entity, + /// The exact hit coordinates in world space. + hit-pos: position, + /// The distance from the ray start to the hit position. + distance: f64, + } + resource chunk { /// Gets the chunk's X coordinate. get-x: func() -> s32; @@ -395,6 +470,18 @@ interface %world { /// X and Z must be in the range [0, 15]. set-block-state: func(pos: block-pos, state: u16); + /// Gets the block at the specified position relative to the chunk. + /// X and Z must be in the range [0, 15]. + get-block: func(pos: block-pos) -> block; + + /// Sets the block at the specified position relative to the chunk using its default state. + /// X and Z must be in the range [0, 15]. + set-block: func(pos: block-pos, block: block); + + /// Sets the block by block ID at the specified position relative to the chunk using its default state. + /// X and Z must be in the range [0, 15]. + set-block-by-id: func(pos: block-pos, block-id: u16); + /// Gets the biome at the specified position relative to the chunk. /// X and Z must be in the range [0, 15]. get-biome: func(pos: block-pos) -> biome; @@ -431,13 +518,26 @@ interface %world { get-center-x: func() -> f64; /// Gets the center Z coordinate of the border. get-center-z: func() -> f64; + /// Gets the center position of the border. + get-center: func() -> position; /// Sets the center coordinates of the border. set-center: func(x: f64, z: f64); /// Gets the current diameter of the border. get-diameter: func() -> f64; + /// Gets the current diameter of the border (alias for get-diameter). + get-size: func() -> f64; /// Sets the diameter of the border, optionally with a speed (in ticks) for lerping. set-diameter: func(diameter: f64, speed: option); + /// Sets the size of the border instantly. + set-size: func(size: f64); + /// Sets the size of the border with a transition duration in seconds. + set-size-transition: func(new-size: f64, time-seconds: u64); + + /// Gets the target diameter when lerping/transitioning. + get-target-diameter: func() -> f64; + /// Gets the target transition duration/speed in ticks. + get-target-speed: func() -> s64; /// Gets the distance from the border where warning effects start (in blocks). get-warning-distance: func() -> s32; @@ -448,9 +548,28 @@ interface %world { get-warning-delay: func() -> s32; /// Sets the warning delay (in seconds). set-warning-delay: func(delay: s32); + /// Gets the warning time (alias for get-warning-delay). + get-warning-time: func() -> s32; + /// Sets the warning time (alias for set-warning-delay). + set-warning-time: func(time: s32); + + /// Gets the safe damage buffer distance outside the border (in blocks). + get-damage-buffer: func() -> f64; + /// Sets the safe damage buffer distance outside the border (in blocks). + set-damage-buffer: func(buffer: f64); + + /// Gets the damage amount inflicted per block per second when outside the buffer. + get-damage-amount: func() -> f64; + /// Sets the damage amount inflicted per block per second when outside the buffer. + set-damage-amount: func(damage: f64); /// Returns whether the specified coordinates are within the border. contains: func(x: f64, z: f64) -> bool; + /// Returns whether the specified position is within the border. + contains-pos: func(pos: position) -> bool; + + /// Resets the world border to vanilla default settings. + reset: func(); } /// Represents an axis-aligned bounding box. @@ -484,6 +603,9 @@ interface %world { /// Returns the unique identifier of this world. get-id: func() -> string; + /// Gets the world border associated with this world (alias for get-world-border). + get-border: func() -> world-border; + /// Gets the world border associated with this world. get-world-border: func() -> world-border; @@ -499,6 +621,22 @@ interface %world { /// Sets the block state at the specified position. set-block-state: func(pos: block-pos, state: u16, update-flags: block-flags); + /// Gets the block type at the specified position. + get-block: func(pos: block-pos) -> block; + + /// Gets the numerical block ID at the specified position. + get-block-id: func(pos: block-pos) -> u16; + + /// Sets the block at the specified position using its default state. + set-block: func(pos: block-pos, block: block, update-flags: block-flags); + + /// Sets the block at the specified position by numerical block ID using its default state. + set-block-by-id: func(pos: block-pos, block-id: u16, update-flags: block-flags); + + /// Sets the block at the specified position by namespaced name using its default state. + /// Returns true if the block was recognized and set. + set-block-by-name: func(pos: block-pos, name: string, update-flags: block-flags) -> bool; + /// Returns the current time of day in ticks. get-time-of-day: func() -> u64; @@ -580,6 +718,15 @@ interface %world { /// Performs a raycast from start position to end position to hit blocks. ray-trace-blocks: func(start: position, end: position) -> option; + /// Performs a raycast from start position to end position to hit blocks, with optional fluid handling. + ray-trace-block: func(start: position, end: position, include-fluids: bool) -> option; + + /// Performs a raycast from start position to end position to find the closest entity hit. + ray-trace-entity: func(start: position, end: position) -> option; + + /// Performs a raycast from start position to end position to find all entities hit along the ray. + ray-trace-entities: func(start: position, end: position) -> list; + /// Returns the block entity at the specified position, if any. get-block-entity: func(pos: block-pos) -> option; @@ -664,4 +811,49 @@ interface %world { /// Resolves a block state ID back to its block name and properties. /// Returns none if the state ID is unknown. block-state-to-info: func(state-id: u16) -> option; + + /// Gets a block type by its numerical block ID. + get-block-by-id: func(id: u16) -> option; + + /// Gets a block type by its namespaced name (e.g., "minecraft:stone" or "stone"). + get-block-by-name: func(name: string) -> option; + + /// Gets all registered blocks. + get-all-blocks: func() -> list; + + /// Gets the names of all registered blocks. + get-all-block-names: func() -> list; + + /// Gets the total number of registered block types. + get-block-count: func() -> u32; + + /// Gets the total number of registered block states. + get-block-state-count: func() -> u32; + + /// Gets all valid block states for a block type. + get-states-for-block: func(block: block) -> list; + + /// Gets all valid block states for a numerical block ID. + get-states-for-block-id: func(block-id: u16) -> list; + + /// Gets all valid state IDs for a numerical block ID. + get-state-ids-for-block-id: func(block-id: u16) -> list; + + /// Gets property key-value pairs for a numerical block state ID. + get-block-properties: func(state-id: u16) -> list>; + + /// Gets the block type associated with a block state ID. + get-block-from-state-id: func(state-id: u16) -> option; + + /// Gets the block type associated with a block state. + get-block-from-state: func(state: block-state) -> block; + + /// Gets the default block state for a block type. + get-default-state-from-block: func(block: block) -> block-state; + + /// Gets the default block state for a numerical block ID. + get-default-state-from-block-id: func(block-id: u16) -> option; + + /// Gets the detailed block state for a numerical block state ID. + get-block-state-by-id: func(state-id: u16) -> option; }