some more stuff

This commit is contained in:
Alexander Medvedev 2026-08-24 16:06:22 +02:00
parent 66306e150f
commit 060c913c30
5 changed files with 253 additions and 5 deletions

View File

@ -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}; }

View File

@ -10,6 +10,7 @@ interface event {
use java-packets.{serverbound-packet as java-serverbound-packet, clientbound-packet as java-clientbound-packet}; 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 bedrock-packets.{serverbound-packet as bedrock-serverbound-packet, clientbound-packet as bedrock-clientbound-packet};
use uuid.{uuid}; use uuid.{uuid};
use java-dialogs.{dialog};
variant serverbound-packet { variant serverbound-packet {
java(java-serverbound-packet), java(java-serverbound-packet),
@ -282,10 +283,22 @@ interface event {
response-data: option<string>, response-data: option<string>,
} }
record custom-click-action-event-data { record dialog-click-action-event-data {
player: player, player: player,
id: string, id: string,
payload: option<list<u8>>, payload: option<list<u8>>,
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 { record server-command-event-data {
@ -1900,7 +1913,9 @@ interface event {
block-grow-event, block-grow-event,
block-place-event, block-place-event,
bedrock-form-response-event, bedrock-form-response-event,
custom-click-action-event, dialog-click-action-event,
dialog-show-event,
dialog-clear-event,
server-command-event, server-command-event,
server-list-ping-event, server-list-ping-event,
server-load-event, server-load-event,
@ -2173,8 +2188,10 @@ interface event {
block-can-build-event(block-can-build-event-data), block-can-build-event(block-can-build-event-data),
block-grow-event(block-grow-event-data), block-grow-event(block-grow-event-data),
block-place-event(block-place-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), 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-command-event(server-command-event-data),
server-list-ping-event(server-list-ping-event-data), server-list-ping-event(server-list-ping-event-data),
server-load-event(server-load-event-data), server-load-event(server-load-event-data),

View File

@ -2,7 +2,7 @@
interface player { interface player {
use common.{hand, position, game-mode}; use common.{hand, position, game-mode};
use item-stack.{item-stack}; 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 permission.{permission-level};
use text.{text-component}; use text.{text-component};
use gui.{gui}; use gui.{gui};
@ -1086,8 +1086,20 @@ interface player {
/// Checks if an item is currently on cooldown. /// Checks if an item is currently on cooldown.
has-item-cooldown: func(item-id: string) -> bool; 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<ray-trace-block-result>;
/// 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<ray-trace-entity-result>;
/// Returns the entity currently targeted in the looking direction within the specified distance.
get-target-entity: func(max-distance: f64) -> option<entity>;
/// Raycasts from the player's eyes to find the block being targeted. /// Raycasts from the player's eyes to find the block being targeted.
get-target-block: func(max-distance: u32) -> option<position>; get-target-block: func(max-distance: u32) -> option<position>;
/// 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<ray-trace-block-result>;
/// Launches a projectile from the player's eyes in their line of sight. /// Launches a projectile from the player's eyes in their line of sight.
launch-projectile: func(%type: projectile-type) -> option<entity>; launch-projectile: func(%type: projectile-type) -> option<entity>;

View File

@ -2,18 +2,42 @@ interface text {
use common.{named-color, rgb-color, argb-color}; use common.{named-color, rgb-color, argb-color};
resource text-component { resource text-component {
/// Creates a plain text component.
text: static func(plain: string) -> text-component; text: static func(plain: string) -> text-component;
/// Creates a translation component.
translate: static func(key: string, %with: list<text-component>) -> text-component; translate: static func(key: string, %with: list<text-component>) -> 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>) -> text-component;
/// Creates an entity names / selector text component.
entity-names: static func(selector: string, separator: option<string>) -> 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>) -> 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<text-component, string>;
/// Serializes the text component to JSON format.
to-json: func() -> string;
add-child: func(child: text-component); add-child: func(child: text-component);
add-text: func(text: string); add-text: func(text: string);
get-text: func() -> string; get-text: func() -> string;
encode: func() -> list<u8>; encode: func() -> list<u8>;
to-pretty-console: func() -> string;
// Style // Style
color-named: func(color: named-color); color-named: func(color: named-color);
color-rgb: func(color: rgb-color); color-rgb: func(color: rgb-color);
gradient-named: func(colors: list<named-color>);
gradient: func(colors: list<rgb-color>);
rainbow: func();
bold: func(value: bool); bold: func(value: bool);
italic: func(value: bool); italic: func(value: bool);
underlined: func(value: bool); underlined: func(value: bool);
@ -27,8 +51,10 @@ interface text {
// Click events // Click events
click-open-url: func(url: string); click-open-url: func(url: string);
click-open-file: func(path: string);
click-run-command: func(command: string); click-run-command: func(command: string);
click-suggest-command: func(command: string); click-suggest-command: func(command: string);
click-change-page: func(page: u32);
click-copy-to-clipboard: func(text: string); click-copy-to-clipboard: func(text: string);
// Hover events // Hover events
@ -39,3 +65,4 @@ interface text {
hover-show-entity: func(entity-type: string, id: string, name: option<text-component>); hover-show-entity: func(entity-type: string, id: string, name: option<text-component>);
} }
} }

View File

@ -104,10 +104,20 @@ interface %world {
skip-block-added-callback, skip-block-added-callback,
} }
/// Flammability properties of a block.
record flammable {
spread-chance: u8,
burn-chance: u8,
}
/// Detailed information about a block's state. /// Detailed information about a block's state.
record block-state { record block-state {
/// The internal numerical ID of the block state. /// The internal numerical ID of the block state.
id: u16, 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). /// The light level emitted by this block (0-15).
luminance: u8, luminance: u8,
/// How much light this block blocks. /// How much light this block blocks.
@ -164,6 +174,8 @@ interface %world {
up-center-solid: bool, up-center-solid: bool,
/// The color of this block when displayed on a map. /// The color of this block when displayed on a map.
map-color: u8, map-color: u8,
/// The block state's property key-value pairs (e.g. facing=north).
properties: list<tuple<string, string>>,
} }
/// Musical instruments used by note blocks. /// Musical instruments used by note blocks.
@ -197,6 +209,40 @@ interface %world {
custom-head, 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<u16>,
/// 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<flammable>,
}
/// A simple wrapper for a block state ID. /// A simple wrapper for a block state ID.
record block-state-id { record block-state-id {
id: u16, id: u16,
@ -358,6 +404,15 @@ interface %world {
/// Performs a raycast from the entity's eye position in its looking direction. /// Performs a raycast from the entity's eye position in its looking direction.
raycast: func(max-distance: f64, fluid-handling: bool) -> option<raycast-result>; raycast: func(max-distance: f64, fluid-handling: bool) -> option<raycast-result>;
/// 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<ray-trace-block-result>;
/// 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<ray-trace-entity-result>;
/// Returns the entity currently targeted in the looking direction within the specified distance.
get-target-entity: func(max-distance: f64) -> option<entity>;
/// Sets a namespaced custom data value on this entity. /// Sets a namespaced custom data value on this entity.
set-custom-data: func(namespace: string, key: string, value: nbt-tree); set-custom-data: func(namespace: string, key: string, value: nbt-tree);
/// Returns a namespaced custom data value from this entity, if set. /// Returns a namespaced custom data value from this entity, if set.
@ -376,6 +431,26 @@ interface %world {
face: block-direction, 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 { resource chunk {
/// Gets the chunk's X coordinate. /// Gets the chunk's X coordinate.
get-x: func() -> s32; get-x: func() -> s32;
@ -395,6 +470,18 @@ interface %world {
/// X and Z must be in the range [0, 15]. /// X and Z must be in the range [0, 15].
set-block-state: func(pos: block-pos, state: u16); 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. /// Gets the biome at the specified position relative to the chunk.
/// X and Z must be in the range [0, 15]. /// X and Z must be in the range [0, 15].
get-biome: func(pos: block-pos) -> biome; get-biome: func(pos: block-pos) -> biome;
@ -431,13 +518,26 @@ interface %world {
get-center-x: func() -> f64; get-center-x: func() -> f64;
/// Gets the center Z coordinate of the border. /// Gets the center Z coordinate of the border.
get-center-z: func() -> f64; get-center-z: func() -> f64;
/// Gets the center position of the border.
get-center: func() -> position;
/// Sets the center coordinates of the border. /// Sets the center coordinates of the border.
set-center: func(x: f64, z: f64); set-center: func(x: f64, z: f64);
/// Gets the current diameter of the border. /// Gets the current diameter of the border.
get-diameter: func() -> f64; 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. /// Sets the diameter of the border, optionally with a speed (in ticks) for lerping.
set-diameter: func(diameter: f64, speed: option<u64>); set-diameter: func(diameter: f64, speed: option<u64>);
/// 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). /// Gets the distance from the border where warning effects start (in blocks).
get-warning-distance: func() -> s32; get-warning-distance: func() -> s32;
@ -448,9 +548,28 @@ interface %world {
get-warning-delay: func() -> s32; get-warning-delay: func() -> s32;
/// Sets the warning delay (in seconds). /// Sets the warning delay (in seconds).
set-warning-delay: func(delay: s32); 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. /// Returns whether the specified coordinates are within the border.
contains: func(x: f64, z: f64) -> bool; 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. /// Represents an axis-aligned bounding box.
@ -484,6 +603,9 @@ interface %world {
/// Returns the unique identifier of this world. /// Returns the unique identifier of this world.
get-id: func() -> string; 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. /// Gets the world border associated with this world.
get-world-border: func() -> world-border; get-world-border: func() -> world-border;
@ -499,6 +621,22 @@ interface %world {
/// Sets the block state at the specified position. /// Sets the block state at the specified position.
set-block-state: func(pos: block-pos, state: u16, update-flags: block-flags); 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. /// Returns the current time of day in ticks.
get-time-of-day: func() -> u64; get-time-of-day: func() -> u64;
@ -580,6 +718,15 @@ interface %world {
/// Performs a raycast from start position to end position to hit blocks. /// Performs a raycast from start position to end position to hit blocks.
ray-trace-blocks: func(start: position, end: position) -> option<position>; ray-trace-blocks: func(start: position, end: position) -> option<position>;
/// 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<ray-trace-block-result>;
/// Performs a raycast from start position to end position to find the closest entity hit.
ray-trace-entity: func(start: position, end: position) -> option<ray-trace-entity-result>;
/// 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<ray-trace-entity-result>;
/// Returns the block entity at the specified position, if any. /// Returns the block entity at the specified position, if any.
get-block-entity: func(pos: block-pos) -> option<block-entity-type>; get-block-entity: func(pos: block-pos) -> option<block-entity-type>;
@ -664,4 +811,49 @@ interface %world {
/// Resolves a block state ID back to its block name and properties. /// Resolves a block state ID back to its block name and properties.
/// Returns none if the state ID is unknown. /// Returns none if the state ID is unknown.
block-state-to-info: func(state-id: u16) -> option<block-state-info>; block-state-to-info: func(state-id: u16) -> option<block-state-info>;
/// Gets a block type by its numerical block ID.
get-block-by-id: func(id: u16) -> option<block>;
/// Gets a block type by its namespaced name (e.g., "minecraft:stone" or "stone").
get-block-by-name: func(name: string) -> option<block>;
/// Gets all registered blocks.
get-all-blocks: func() -> list<block>;
/// Gets the names of all registered blocks.
get-all-block-names: func() -> list<string>;
/// 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<block-state>;
/// Gets all valid block states for a numerical block ID.
get-states-for-block-id: func(block-id: u16) -> list<block-state>;
/// Gets all valid state IDs for a numerical block ID.
get-state-ids-for-block-id: func(block-id: u16) -> list<u16>;
/// Gets property key-value pairs for a numerical block state ID.
get-block-properties: func(state-id: u16) -> list<tuple<string, string>>;
/// Gets the block type associated with a block state ID.
get-block-from-state-id: func(state-id: u16) -> option<block>;
/// 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<block-state>;
/// Gets the detailed block state for a numerical block state ID.
get-block-state-by-id: func(state-id: u16) -> option<block-state>;
} }