DustKit
DustKit is the bridge between apps and the native DUST browser client.
Getting started
Setup
- Add
dustkitas a dependency topackage.json. The tag at the end corresponds to the github commit on main.
"dustkit": "https://pkg.pr.new/dustproject/dust/dustkit@27f724c"- Connect the dustkit client:
import { connectDustClient } from "dustkit/internal";
const { appContext, provider } = await connectDustClient();- You can now access the methods on the
providerobject. For example, to get the player's position:
const position = await provider.request({
method: "getPlayerPosition",
params: {
entity: "0x",
},
});Reference
setWaypoint
Sets a waypoint for a specific entity with a label.
Parameters:entity(EntityId): The entity to set the waypoint forlabel(string): The label for the waypoint
Returns: void
getSlots
Retrieves slot information for inventory operations.
Parameters:entity(EntityId): The entity to get slots forobjectType(number): The type of objectamount(number): The amount of objectsoperationType("withdraw" | "deposit"): "withdraw" means you want the slots where this object & amount exists and "deposit" means you want the slots where this object & amount will fit
{
slots: {
slot: number;
amount: number;
}
[];
}systemCall
Executes a system call in the world
Parameters:params(SystemCalls): The system call parameters
Returns: Either a user operation receipt or transaction receipt:
{
userOperationHash: Hex;
receipt: UserOperationReceipt;
} | {
transactionHash: Hex;
receipt: TransactionReceipt;
}getPlayerPosition
Gets the 3D position of a player entity.
Parameters: None
Returns:{
x: number;
y: number;
z: number;
}getPlayerOrientation
Gets the 3D orientation of a player entity.
Parameters: None
Returns:{
pitch: number;
yaw: number;
}setBlueprint
Sets a blueprint with block positions and options.
Parameters:blocks: Array of block definitions:{ objectTypeId: number; x: number; y: number; z: number; orientation: number; } [];options(optional, defaults to true for both): Blueprint display options:{ showBlocksToMine: boolean; showBlocksToBuild: boolean; }
Returns: void
getSelectedObjectType
Gets the currently selected object type in the players hotbar.
Parameters: None
Returns: number - The selected object type ID
getForceFieldAt
Gets force field information at a specific coordinate.
Parameters:x(number): X coordinatey(number): Y coordinatez(number): Z coordinate
Returns: Force field data or undefined:
{
forceFieldId: Hex;
fragmentId: Hex;
fragmentPos: {
x: number;
y: number;
z: number;
};
forceFieldCreatedAt: bigint;
extraDrainRate: bigint;
} | undefinedgetCursorPosition
Gets the current cursor position in the world, if available.
Parameters: None
Returns: Cursor position or undefined:
{
x: number;
y: number;
z: number;
} | undefinedgetObjectTypeAt
Gets the current object type at the given position. If the client doesn't know it, returns undefined.
Parameters:x(number): X coordinatey(number): Y coordinatez(number): Z coordinate
Returns: number | undefined - The object type ID at the position, or undefined if client hasn't loaded it
