some entity additions

This commit is contained in:
Alexander Medvedev 2026-08-27 12:32:11 +02:00
parent 10f15637dc
commit a1ba8b3db2
9 changed files with 413 additions and 64 deletions

View File

@ -1,6 +1,7 @@
interface block-entity { interface block-entity {
use common.{block-pos, nbt-tree}; use common.{block-pos, nbt-tree};
use item-stack.{item-stack}; use item-stack.{item-stack};
use inventory.{inventory};
resource block-entity { resource block-entity {
resource-location: func() -> string; resource-location: func() -> string;
@ -21,6 +22,8 @@ interface block-entity {
resource container-block-entity { resource container-block-entity {
get-block-entity: func() -> block-entity; get-block-entity: func() -> block-entity;
/// Returns the generic inventory handle for this container.
get-inventory: func() -> inventory;
get-size: func() -> u32; get-size: func() -> u32;
is-empty: func() -> bool; is-empty: func() -> bool;
get-stack: func(slot: u32) -> option<item-stack>; get-stack: func(slot: u32) -> option<item-stack>;

54
v0.1/datapack.wit Normal file
View File

@ -0,0 +1,54 @@
package pumpkin:plugin@0.1.0;
interface datapack {
/// Information about a discovered or loaded datapack.
record datapack-info {
id: string,
name: string,
description: string,
pack-format: u32,
is-enabled: bool,
recipe-count: u32,
function-count: u32,
}
/// Position options for enabling a datapack relative to other packs.
variant enable-position {
first,
last,
before(string),
after(string),
}
/// Global manager for inspecting and controlling server datapacks.
resource datapack-manager {
/// Returns all known datapacks (both enabled and available/disabled).
list-all-packs: func() -> list<datapack-info>;
/// Returns only currently enabled datapacks.
list-enabled-packs: func() -> list<datapack-info>;
/// Returns available (disabled) datapacks.
list-available-packs: func() -> list<datapack-info>;
/// Retrieves details about a specific datapack by name or ID.
get-pack: func(name: string) -> option<datapack-info>;
/// Checks if a datapack is currently enabled.
is-enabled: func(name: string) -> bool;
/// Enables a datapack with a specific priority position.
enable-pack: func(name: string, position: enable-position) -> result<_, string>;
/// Disables an enabled datapack.
disable-pack: func(name: string) -> result<_, string>;
/// Reloads all enabled datapacks, recipes, and function tags,
/// synchronizes recipes with online players, and triggers `#minecraft:load`.
reload: func() -> result<_, string>;
/// Executes a datapack function or function tag (e.g. "namespace:fn" or "#namespace:tag").
/// Returns the number of commands executed.
execute-function: func(name: string) -> result<u32, string>;
}
}

View File

@ -1 +1 @@
interface entity { use %world.{entity, raycast-result, ray-trace-block-result, ray-trace-entity-result, block-direction}; } interface entity { use %world.{entity, living-entity, mob, path-node-type, dye-color, villager-profession, mob-data, sheep-data, wolf-data, cat-data, villager-data, creeper-data, slime-data, enderman-data, iron-golem-data, fox-data, ageable-data, zombie-data, shulker-data, raycast-result, ray-trace-block-result, ray-trace-entity-result, block-direction}; }

View File

@ -3,9 +3,12 @@ interface gui {
use common.{click-type}; use common.{click-type};
use item-stack.{item-stack}; use item-stack.{item-stack};
use screens.{screen}; use screens.{screen};
use inventory.{inventory};
resource gui { resource gui {
constructor(%type: screen, title: text-component); constructor(%type: screen, title: text-component);
/// Returns the underlying inventory handle for this GUI.
get-inventory: func() -> inventory;
set-item: func(slot: u32, item: item-stack); set-item: func(slot: u32, item: item-stack);
get-item: func(slot: u32) -> option<item-stack>; get-item: func(slot: u32) -> option<item-stack>;

78
v0.1/inventory.wit Normal file
View File

@ -0,0 +1,78 @@
package pumpkin:plugin@0.1.0;
interface inventory {
use item-stack.{item-stack};
use common.{hand};
/// Common inventory resource used across GUIs, player inventories, and containers.
resource inventory {
/// Returns the number of slots in this inventory.
get-size: func() -> u32;
/// Returns true if all slots in this inventory are empty.
is-empty: func() -> bool;
/// Returns the item in the specified slot index, or none if empty.
get-item: func(slot: u32) -> option<item-stack>;
/// Sets the item in the specified slot index.
set-item: func(slot: u32, item: option<item-stack>);
/// Removes and returns the item in the specified slot index.
remove-item: func(slot: u32) -> option<item-stack>;
/// Clears all items from this inventory.
clear: func();
/// Returns all items in this inventory as a list of slots.
get-all-items: func() -> list<option<item-stack>>;
/// Sets all items in this inventory from a list.
set-all-items: func(items: list<option<item-stack>>);
/// Counts the total number of items with the given ID in this inventory.
count-item: func(item-id: string) -> u32;
/// Checks if the inventory contains at least one item with the given ID.
contains-item: func(item-id: string) -> bool;
}
/// Specialized player inventory handle providing access to main inventory, armor, offhand, and hotbar.
resource player-inventory {
/// Returns the generic 36-slot inventory handle (hotbar + main storage).
as-inventory: func() -> inventory;
/// Returns the item currently held in the specified hand.
get-item-in-hand: func(hand: hand) -> option<item-stack>;
/// Sets the item in the specified hand.
set-item-in-hand: func(hand: hand, item: option<item-stack>);
/// Returns the currently selected hotbar slot index (0-8).
get-selected-slot: func() -> u8;
/// Sets the currently selected hotbar slot index (0-8).
set-selected-slot: func(slot: u8);
/// Armor slot accessors
get-helmet: func() -> option<item-stack>;
set-helmet: func(item: option<item-stack>);
get-chestplate: func() -> option<item-stack>;
set-chestplate: func(item: option<item-stack>);
get-leggings: func() -> option<item-stack>;
set-leggings: func(item: option<item-stack>);
get-boots: func() -> option<item-stack>;
set-boots: func(item: option<item-stack>);
get-off-hand: func() -> option<item-stack>;
set-off-hand: func(item: option<item-stack>);
/// Clears all armor slots.
clear-armor: func();
/// Clears the 36 main inventory slots.
clear-main: func();
/// Clears all slots (main inventory, armor, offhand).
clear-all: func();
}
}

View File

@ -16,6 +16,7 @@ interface player {
use advancement.{advancement-progress}; use advancement.{advancement-progress};
use damage-types.{damage-type}; use damage-types.{damage-type};
use statistics.{statistic-category, custom-statistic}; use statistics.{statistic-category, custom-statistic};
use inventory.{inventory, player-inventory};
/// Represents per-player weather condition overrides. /// Represents per-player weather condition overrides.
enum player-weather { enum player-weather {
@ -947,6 +948,11 @@ interface player {
// Inventory // Inventory
/// Returns the player's inventory handle for managing main storage, armor, and equipment.
get-inventory: func () -> player-inventory;
/// Returns the player's ender chest inventory handle.
get-ender-chest: func () -> inventory;
/// Returns the index of the currently selected hotbar slot (0-8). /// Returns the index of the currently selected hotbar slot (0-8).
get-selected-slot: func () -> u8; get-selected-slot: func () -> u8;
/// Returns the item currently in the specified hand. /// Returns the item currently in the specified hand.

View File

@ -55,6 +55,10 @@ world plugin {
import advancement; import advancement;
/// Provides custom recipe registration and management. /// Provides custom recipe registration and management.
import recipe; import recipe;
/// Provides inventory manipulation and management.
import inventory;
/// Provides datapack inspection and management.
import datapack;
/// Provides custom enchantment registration and management. /// Provides custom enchantment registration and management.
import enchantments; import enchantments;
/// Provides damage types. /// Provides damage types.

View File

@ -8,6 +8,7 @@ interface server {
use enchantments.{enchantment-manager, custom-enchantment}; use enchantments.{enchantment-manager, custom-enchantment};
use permission.{permission-level}; use permission.{permission-level};
use advancement.{advancement-info}; use advancement.{advancement-info};
use datapack.{datapack-manager, datapack-info};
/// Represents an operator entry in the ops configuration. /// Represents an operator entry in the ops configuration.
record op-entry { record op-entry {
@ -269,5 +270,8 @@ interface server {
/// Returns a list of all registered enchantment IDs (custom and vanilla) on the server. /// Returns a list of all registered enchantment IDs (custom and vanilla) on the server.
get-all-enchantment-ids: func() -> list<string>; get-all-enchantment-ids: func() -> list<string>;
/// Returns the global datapack manager for inspecting, enabling, disabling, and reloading datapacks.
get-datapack-manager: func() -> datapack-manager;
} }
} }

View File

@ -53,7 +53,175 @@ interface %world {
creeper-ignite, creeper-ignite,
eat-grass, eat-grass,
zombie-attack(f32), zombie-attack(f32),
}
/// Node and terrain classification types evaluated during mob pathfinding.
enum path-node-type {
blocked,
open,
walkable,
walkable-door,
trapdoor,
powder-snow,
danger-powder-snow,
fence,
lava,
water,
water-border,
rail,
unpassable-rail,
danger-fire,
damage-fire,
danger-other,
damage-other,
door-open,
door-wood-closed,
door-iron-closed,
breach,
leaves,
sticky-honey,
cocoa,
damage-cautious,
danger-trapdoor,
}
/// Minecraft 16 dye colors.
enum dye-color {
white,
orange,
magenta,
light-blue,
yellow,
lime,
pink,
gray,
light-gray,
cyan,
purple,
blue,
brown,
green,
red,
black,
}
/// Villager profession identifiers.
enum villager-profession {
none,
armorer,
butcher,
cartographer,
cleric,
farmer,
fisherman,
fletcher,
leatherworker,
librarian,
mason,
nitwit,
shepherd,
toolsmith,
weaponsmith,
}
/// Specialized data for sheep entities.
record sheep-data {
color: dye-color,
is-sheared: bool,
}
/// Specialized data for wolf entities.
record wolf-data {
is-tamed: bool,
owner: option<uuid>,
is-sitting: bool,
collar-color: dye-color,
is-angry: bool,
is-begging: bool,
}
/// Specialized data for cat entities.
record cat-data {
is-tamed: bool,
owner: option<uuid>,
is-sitting: bool,
collar-color: dye-color,
}
/// Specialized data for villager entities.
record villager-data {
profession: villager-profession,
level: u8,
experience: u32,
}
/// Specialized data for creeper entities.
record creeper-data {
is-powered: bool,
fuse: s32,
is-ignited: bool,
explosion-radius: u8,
}
/// Specialized data for slime and magma cube entities.
record slime-data {
size: s32,
}
/// Specialized data for enderman entities.
record enderman-data {
carried-block-state: option<u16>,
is-screaming: bool,
is-staring: bool,
}
/// Specialized data for iron golem entities.
record iron-golem-data {
is-player-created: bool,
}
/// Specialized data for fox entities.
record fox-data {
is-sitting: bool,
is-sleeping: bool,
is-crouching: bool,
}
/// Specialized data for ageable animal mobs.
record ageable-data {
is-baby: bool,
age: s32,
in-love-ticks: s32,
}
/// Specialized data for zombie entities.
record zombie-data {
is-baby: bool,
can-break-doors: bool,
}
/// Specialized data for shulker entities.
record shulker-data {
attached-face: block-direction,
peek-amount: u8,
color: option<dye-color>,
}
/// Tagged variant holding specialized data for specific mob types.
variant mob-data {
sheep(sheep-data),
wolf(wolf-data),
cat(cat-data),
villager(villager-data),
creeper(creeper-data),
slime(slime-data),
enderman(enderman-data),
iron-golem(iron-golem-data),
fox(fox-data),
ageable(ageable-data),
zombie(zombie-data),
shulker(shulker-data),
generic,
} }
/// Categories for sounds to control their volume independently. /// Categories for sounds to control their volume independently.
@ -277,46 +445,6 @@ interface %world {
get-fire-ticks: func() -> s32; get-fire-ticks: func() -> s32;
set-fire-ticks: func(ticks: s32); set-fire-ticks: func(ticks: s32);
get-health: func() -> f32;
set-health: func(health: f32);
get-max-health: func() -> f32;
damage: func(amount: f32, damage-type: damage-type);
is-dead: func() -> bool;
get-absorption: func() -> f32;
set-absorption: func(amount: f32);
// Attributes
/// Returns the computed value of the specified attribute for this entity.
get-attribute-value: func(attr: attribute) -> f64;
/// Returns the base value of the specified attribute for this entity.
get-attribute-base: func(attr: attribute) -> f64;
/// Sets the base value of the specified attribute for this entity.
set-attribute-base: func(attr: attribute, value: f64);
/// Adds or replaces an attribute modifier for the specified attribute.
add-attribute-modifier: func(attr: attribute, modifier: attribute-modifier);
/// Removes an attribute modifier by its identifier.
remove-attribute-modifier: func(attr: attribute, id: string);
/// Returns all attribute modifiers currently attached to the specified attribute.
get-attribute-modifiers: func(attr: attribute) -> list<attribute-modifier>;
/// Resets the specified attribute to its default base value with no modifiers.
reset-attribute: func(attr: attribute);
/// Resets all attributes on this entity to their default base values and removes all modifiers.
reset-all-attributes: func();
// Equipment
/// Gets the item currently equipped in the specified slot, if any.
get-equipment: func(slot: equipment-slot) -> option<item-stack>;
/// Sets the item equipped in the specified slot and broadcasts the change to tracking clients.
set-equipment: func(slot: equipment-slot, stack: option<item-stack>);
/// Clears all equipment on this entity and broadcasts the removal.
clear-equipment: func();
get-age: func() -> s32;
set-age: func(age: s32);
get-fall-distance: func() -> f32; get-fall-distance: func() -> f32;
set-fall-distance: func(distance: f32); set-fall-distance: func(distance: f32);
@ -359,8 +487,6 @@ interface %world {
set-remaining-air: func(air: s32); set-remaining-air: func(air: s32);
get-max-air: func() -> s32; get-max-air: func() -> s32;
send-system-message: func(message: text-component);
get-eye-height: func() -> f32; get-eye-height: func() -> f32;
get-eye-position: func() -> position; get-eye-position: func() -> position;
@ -380,27 +506,6 @@ interface %world {
remove: func(); remove: func();
/// Adds a built-in AI goal to this mob entity at the specified priority level.
add-ai-goal: func(priority: u8, goal: builtin-ai-goal);
/// Adds a custom AI goal to this mob entity at the specified priority level.
add-custom-ai-goal: func(priority: u8, goal-id: u32);
/// Removes all AI goals from this mob entity.
clear-ai-goals: func();
/// Sets whether AI execution is disabled for this entity.
set-ai-disabled: func(disabled: bool);
/// Checks if AI execution is disabled for this entity.
is-ai-disabled: func() -> bool;
/// Sets the target entity for this mob.
set-target: func(target: option<entity>);
/// Gets the current target entity of this mob, if any.
get-target: func() -> option<entity>;
/// 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>;
@ -421,6 +526,98 @@ interface %world {
remove-custom-data: func(namespace: string, key: string); remove-custom-data: func(namespace: string, key: string);
/// Returns whether this entity has a namespaced custom data value. /// Returns whether this entity has a namespaced custom data value.
has-custom-data: func(namespace: string, key: string) -> bool; has-custom-data: func(namespace: string, key: string) -> bool;
/// Returns this entity as a living-entity if it has health and attributes, or none otherwise.
as-living: func() -> option<living-entity>;
/// Returns this entity as a mob if it is an AI-driven mob entity, or none otherwise.
as-mob: func() -> option<mob>;
/// Returns whether this entity is a living entity.
is-living: func() -> bool;
/// Returns whether this entity is an AI-driven mob.
is-mob: func() -> bool;
}
/// Represents a living entity with health, combat stats, attributes, and equipment (mobs, players, armor stands).
resource living-entity {
/// Converts back to the base entity handle.
as-entity: func() -> entity;
/// Returns this living entity as a mob if it has AI/navigation, or none otherwise.
as-mob: func() -> option<mob>;
/// Returns whether this living entity is an AI-driven mob.
is-mob: func() -> bool;
// Health & Combat
get-health: func() -> f32;
set-health: func(health: f32);
get-max-health: func() -> f32;
set-max-health: func(max-health: f32);
damage: func(amount: f32, damage-type: damage-type);
is-dead: func() -> bool;
get-absorption: func() -> f32;
set-absorption: func(amount: f32);
// Attributes
get-attribute-value: func(attr: attribute) -> f64;
get-attribute-base: func(attr: attribute) -> f64;
set-attribute-base: func(attr: attribute, value: f64);
add-attribute-modifier: func(attr: attribute, modifier: attribute-modifier);
remove-attribute-modifier: func(attr: attribute, id: string);
get-attribute-modifiers: func(attr: attribute) -> list<attribute-modifier>;
reset-attribute: func(attr: attribute);
reset-all-attributes: func();
// Equipment
get-equipment: func(slot: equipment-slot) -> option<item-stack>;
set-equipment: func(slot: equipment-slot, stack: option<item-stack>);
clear-equipment: func();
get-age: func() -> s32;
set-age: func(age: s32);
send-system-message: func(message: text-component);
}
/// Represents an AI-driven mob entity with goals, targeting, and pathfinding navigation (e.g. zombies, villagers).
resource mob {
/// Converts back to the base entity handle.
as-entity: func() -> entity;
/// Converts to the living-entity handle.
as-living: func() -> living-entity;
// Goals & Targeting
add-ai-goal: func(priority: u8, goal: builtin-ai-goal);
add-custom-ai-goal: func(priority: u8, goal-id: u32);
clear-ai-goals: func();
set-ai-disabled: func(disabled: bool);
is-ai-disabled: func() -> bool;
set-target: func(target: option<entity>);
get-target: func() -> option<entity>;
// Pathfinding & Navigation
navigate-to-pos: func(pos: position, speed: f64) -> bool;
navigate-to-entity: func(target: entity, speed: f64) -> bool;
stop-navigation: func();
is-navigating: func() -> bool;
has-reached-destination: func() -> bool;
set-navigation-speed: func(speed: f64);
can-reach: func(pos: position, max-distance: f32) -> bool;
set-pathfinding-malus: func(node-type: path-node-type, malus: f32);
get-pathfinding-malus: func(node-type: path-node-type) -> f32;
look-at: func(pos: position);
look-at-entity: func(target: entity);
/// Returns the specialized mob-specific data for this mob.
get-mob-data: func() -> mob-data;
/// Sets the specialized mob-specific data for this mob.
/// Returns false if the provided data variant is incompatible with this mob.
set-mob-data: func(data: mob-data) -> bool;
} }
/// Result of a raycast operation. /// Result of a raycast operation.