@bkm016/calcite 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +113 -11
- package/dist/accounts.d.ts +23 -4
- package/dist/accounts.js +120 -40
- package/dist/accounts.js.map +1 -1
- package/dist/cli.js +95 -5
- package/dist/cli.js.map +1 -1
- package/dist/client-core.d.ts +66 -0
- package/dist/client-core.js +530 -0
- package/dist/client-core.js.map +1 -0
- package/dist/client.d.ts +86 -210
- package/dist/client.js +90 -576
- package/dist/client.js.map +1 -1
- package/dist/display.js +42 -13
- package/dist/display.js.map +1 -1
- package/dist/hmc.d.ts +31 -11
- package/dist/hmc.js +68 -30
- package/dist/hmc.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/install.d.ts +48 -0
- package/dist/install.js +119 -0
- package/dist/install.js.map +1 -0
- package/dist/java.d.ts +8 -2
- package/dist/java.js +14 -10
- package/dist/java.js.map +1 -1
- package/dist/loaders.d.ts +41 -0
- package/dist/loaders.js +86 -0
- package/dist/loaders.js.map +1 -0
- package/dist/mcp.js +128 -3
- package/dist/mcp.js.map +1 -1
- package/dist/mods.d.ts +21 -0
- package/dist/mods.js +135 -0
- package/dist/mods.js.map +1 -0
- package/dist/mojang.d.ts +0 -16
- package/dist/mojang.js +1 -37
- package/dist/mojang.js.map +1 -1
- package/dist/names.d.ts +53 -0
- package/dist/names.js +267 -0
- package/dist/names.js.map +1 -0
- package/dist/net.d.ts +5 -0
- package/dist/net.js +41 -1
- package/dist/net.js.map +1 -1
- package/dist/paths.d.ts +5 -3
- package/dist/paths.js +1 -0
- package/dist/paths.js.map +1 -1
- package/dist/types.d.ts +235 -0
- package/dist/types.js +25 -0
- package/dist/types.js.map +1 -0
- package/dist/zip.d.ts +5 -0
- package/dist/zip.js +65 -0
- package/dist/zip.js.map +1 -0
- package/package.json +1 -1
- package/vendor/calcite-probe.jar +0 -0
package/dist/client.d.ts
CHANGED
|
@@ -1,223 +1,99 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type
|
|
3
|
-
export
|
|
4
|
-
export type
|
|
5
|
-
type: 'offline';
|
|
6
|
-
username: string;
|
|
7
|
-
} | {
|
|
8
|
-
type: 'microsoft';
|
|
9
|
-
name?: string;
|
|
10
|
-
};
|
|
11
|
-
export type Phase = 'idle' | 'preparing' | 'waiting_for_server' | 'starting' | 'connecting' | 'in_game' | 'disconnected' | 'reconnecting' | 'stopping' | 'stopped' | 'crashed';
|
|
12
|
-
export interface ServerAddress {
|
|
13
|
-
host: string;
|
|
14
|
-
port: number;
|
|
15
|
-
}
|
|
16
|
-
export interface ClientOptions {
|
|
17
|
-
/** Instance name; also the game directory name. Letters, digits, '-', '_' and '.' only. */
|
|
18
|
-
name: string;
|
|
19
|
-
/** Minecraft version id, "latest" or "snapshot". */
|
|
20
|
-
version: string;
|
|
21
|
-
/** Server to join ("host[:port]"). Without a server the client stays on the title screen. */
|
|
22
|
-
server?: string | ServerAddress;
|
|
23
|
-
/** Account: offline (any username, for online-mode=false servers) or a stored Microsoft account. */
|
|
24
|
-
account?: Account;
|
|
25
|
-
/**
|
|
26
|
-
* World rendering: 'off' (no renderer, cheapest, no screenshots), 'on-demand' (renders only for screenshots,
|
|
27
|
-
* default), 'always'. Rendering needs a display (Linux: DISPLAY or Xvfb) and, with an offline account, Linux.
|
|
28
|
-
*/
|
|
29
|
-
render?: RenderMode;
|
|
30
|
-
/** Explicit java executable for the game. */
|
|
31
|
-
javaPath?: string;
|
|
32
|
-
/** Download a Temurin runtime when the required Java is missing (default true). */
|
|
33
|
-
allowJavaDownload?: boolean;
|
|
34
|
-
/** Max heap, e.g. "2G" (default "2G"). */
|
|
35
|
-
memory?: string;
|
|
36
|
-
/** Extra JVM / game arguments (must not contain spaces). */
|
|
37
|
-
jvmArgs?: string[];
|
|
38
|
-
gameArgs?: string[];
|
|
39
|
-
renderDistance?: number;
|
|
40
|
-
maxFps?: number;
|
|
41
|
-
/** Reconnect (relaunch) after a disconnect or crash. Default: enabled, 10 attempts. */
|
|
42
|
-
reconnect?: boolean | {
|
|
43
|
-
maxAttempts?: number;
|
|
44
|
-
};
|
|
45
|
-
/** How long to wait for the server port before launching (default 120 s). */
|
|
46
|
-
waitForServerMs?: number;
|
|
47
|
-
/** Overall start timeout including downloads (default 15 min). */
|
|
48
|
-
startTimeoutMs?: number;
|
|
49
|
-
paths?: CalcitePaths;
|
|
50
|
-
}
|
|
51
|
-
export interface LogLine {
|
|
52
|
-
seq: number;
|
|
53
|
-
time: number;
|
|
54
|
-
source: 'game' | 'calcite';
|
|
55
|
-
line: string;
|
|
56
|
-
}
|
|
57
|
-
export interface ChatLine {
|
|
58
|
-
seq: number;
|
|
59
|
-
time: number;
|
|
60
|
-
message: string;
|
|
61
|
-
}
|
|
62
|
-
export interface PlayerState {
|
|
63
|
-
id?: number;
|
|
64
|
-
uuid?: string;
|
|
65
|
-
name?: string;
|
|
66
|
-
x?: number;
|
|
67
|
-
y?: number;
|
|
68
|
-
z?: number;
|
|
69
|
-
yaw?: number;
|
|
70
|
-
pitch?: number;
|
|
71
|
-
health?: number;
|
|
72
|
-
dimension?: string;
|
|
73
|
-
}
|
|
74
|
-
export interface GameState {
|
|
75
|
-
ready: boolean;
|
|
76
|
-
headless: boolean;
|
|
77
|
-
inGame: boolean;
|
|
78
|
-
screen?: string | null;
|
|
79
|
-
/** A resource (re)load overlay is showing. */
|
|
80
|
-
loading?: boolean;
|
|
81
|
-
disconnectReason?: string | null;
|
|
82
|
-
fps?: number;
|
|
83
|
-
noRender?: boolean;
|
|
84
|
-
player?: PlayerState;
|
|
85
|
-
}
|
|
86
|
-
export interface EntityInfo {
|
|
87
|
-
id: number;
|
|
88
|
-
uuid: string;
|
|
89
|
-
type: string;
|
|
90
|
-
x?: number;
|
|
91
|
-
y?: number;
|
|
92
|
-
z?: number;
|
|
93
|
-
yaw?: number;
|
|
94
|
-
pitch?: number;
|
|
95
|
-
name?: string;
|
|
96
|
-
customName?: string;
|
|
97
|
-
vehicleId?: number | null;
|
|
98
|
-
invisible?: boolean;
|
|
99
|
-
removed?: boolean;
|
|
100
|
-
}
|
|
101
|
-
export interface EntityQuery {
|
|
102
|
-
/** Only entities within this distance of the player (blocks). */
|
|
103
|
-
radius?: number;
|
|
104
|
-
/** Entity type id, e.g. "minecraft:villager" (the "minecraft:" prefix is optional). */
|
|
105
|
-
type?: string;
|
|
106
|
-
uuid?: string;
|
|
107
|
-
/** Substring match on name or custom name (case-insensitive). */
|
|
108
|
-
name?: string;
|
|
109
|
-
limit?: number;
|
|
110
|
-
includeSelf?: boolean;
|
|
111
|
-
}
|
|
112
|
-
export interface ClientStatus {
|
|
113
|
-
name: string;
|
|
114
|
-
version: string;
|
|
115
|
-
phase: Phase;
|
|
116
|
-
render: RenderMode;
|
|
117
|
-
headless: boolean;
|
|
118
|
-
account: Account;
|
|
119
|
-
server?: ServerAddress;
|
|
120
|
-
gameDir: string;
|
|
121
|
-
pid?: number;
|
|
122
|
-
java?: string;
|
|
123
|
-
startedAt?: number;
|
|
124
|
-
reconnects: number;
|
|
125
|
-
lastError?: string;
|
|
126
|
-
probeConnected: boolean;
|
|
127
|
-
game?: GameState;
|
|
128
|
-
}
|
|
129
|
-
export declare class CalciteError extends Error {
|
|
130
|
-
readonly code: string;
|
|
131
|
-
constructor(code: string, message: string);
|
|
132
|
-
}
|
|
133
|
-
export declare function parseServer(server: string | ServerAddress): ServerAddress;
|
|
134
|
-
/** Offline username derived from a client name (3-16 chars of [A-Za-z0-9_]). */
|
|
135
|
-
export declare function defaultUsername(name: string): string;
|
|
136
|
-
export interface InstallOptions {
|
|
137
|
-
paths?: CalcitePaths;
|
|
138
|
-
javaPath?: string;
|
|
139
|
-
allowJavaDownload?: boolean;
|
|
140
|
-
onLine?: (line: string) => void;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Downloads everything a version needs (client, libraries, natives, assets, mappings, Java, HeadlessMC) without
|
|
144
|
-
* starting the game, so later launches start fast and work offline.
|
|
145
|
-
*/
|
|
146
|
-
export declare function installVersion(spec: string, opts?: InstallOptions): Promise<{
|
|
147
|
-
id: string;
|
|
148
|
-
java: string;
|
|
149
|
-
probe: string;
|
|
150
|
-
}>;
|
|
1
|
+
import { ClientCore } from './client-core.js';
|
|
2
|
+
import { type BlockFace, type BlockInfo, type BlockPosition, type ChatLine, type ClickMode, type ContainerInfo, type DigResult, type EntityInfo, type EntityQuery, type GameState, type HitTarget, type InventoryInfo, type ItemInfo, type LogLine, type MoveControls, type Phase, type WalkResult } from './types.js';
|
|
3
|
+
export * from './types.js';
|
|
4
|
+
export { installVersion, type InstallOptions } from './install.js';
|
|
151
5
|
/**
|
|
152
6
|
* One Minecraft client controlled by Calcite.
|
|
153
7
|
*
|
|
154
8
|
* Events: 'phase' (Phase), 'log' (LogLine), 'chat' (ChatLine), 'state' (GameState), 'exit' (code).
|
|
155
9
|
*/
|
|
156
|
-
export declare class Client extends
|
|
157
|
-
readonly options: Required<Pick<ClientOptions, 'name' | 'version'>> & ClientOptions;
|
|
158
|
-
readonly paths: CalcitePaths;
|
|
159
|
-
readonly gameDir: string;
|
|
160
|
-
readonly render: RenderMode;
|
|
161
|
-
readonly account: Account;
|
|
162
|
-
readonly server?: ServerAddress;
|
|
163
|
-
private phaseValue;
|
|
164
|
-
private logs;
|
|
165
|
-
private chats;
|
|
166
|
-
private seq;
|
|
167
|
-
private probe;
|
|
168
|
-
private run;
|
|
169
|
-
private display;
|
|
170
|
-
private releaseInstance;
|
|
171
|
-
private probeConfig;
|
|
172
|
-
private java;
|
|
173
|
-
private versionJson;
|
|
174
|
-
private names;
|
|
175
|
-
private headlessValue;
|
|
176
|
-
private lastState;
|
|
177
|
-
private lastError;
|
|
178
|
-
/** Error code of a failure that relaunching cannot fix (reported by start() instead of "crashed"). */
|
|
179
|
-
private fatalCode;
|
|
180
|
-
private startedAt;
|
|
181
|
-
private reconnects;
|
|
182
|
-
private stopping;
|
|
183
|
-
private poller;
|
|
184
|
-
private inGameSince;
|
|
185
|
-
private relaunching;
|
|
186
|
-
private everInGame;
|
|
187
|
-
private joinRequested;
|
|
188
|
-
private readonly log;
|
|
189
|
-
constructor(options: ClientOptions);
|
|
190
|
-
get phase(): Phase;
|
|
191
|
-
get headless(): boolean;
|
|
192
|
-
private setPhase;
|
|
193
|
-
private note;
|
|
194
|
-
private pushLog;
|
|
195
|
-
/**
|
|
196
|
-
* Prepares everything (Java, game files, mappings), launches the client and resolves once it is in a world
|
|
197
|
-
* (or on the title screen when no server is configured).
|
|
198
|
-
*/
|
|
199
|
-
start(): Promise<ClientStatus>;
|
|
200
|
-
/** Downloads and verifies everything needed to launch (idempotent). */
|
|
201
|
-
prepare(): Promise<void>;
|
|
202
|
-
private resolveHeadless;
|
|
203
|
-
private launch;
|
|
204
|
-
private onProbeConnected;
|
|
205
|
-
private poll;
|
|
206
|
-
private reconnectLimit;
|
|
207
|
-
private maybeReconnect;
|
|
208
|
-
private onGameExit;
|
|
209
|
-
private waitUntilStarted;
|
|
210
|
-
private cleanupRun;
|
|
211
|
-
private shutdown;
|
|
212
|
-
/** Stops the game and releases all resources. */
|
|
213
|
-
stop(): Promise<void>;
|
|
214
|
-
status(): ClientStatus;
|
|
215
|
-
private requireProbe;
|
|
10
|
+
export declare class Client extends ClientCore {
|
|
216
11
|
state(): Promise<GameState>;
|
|
217
12
|
entities(query?: EntityQuery): Promise<EntityInfo[]>;
|
|
218
13
|
chat(message: string): Promise<void>;
|
|
219
14
|
command(command: string): Promise<void>;
|
|
220
15
|
respawn(): Promise<void>;
|
|
16
|
+
/** Turns the player to an absolute rotation (degrees; yaw 0 = south, pitch -90 = up) or towards a point. */
|
|
17
|
+
look(to: {
|
|
18
|
+
yaw?: number;
|
|
19
|
+
pitch?: number;
|
|
20
|
+
} | {
|
|
21
|
+
x: number;
|
|
22
|
+
y: number;
|
|
23
|
+
z: number;
|
|
24
|
+
}): Promise<{
|
|
25
|
+
yaw: number;
|
|
26
|
+
pitch: number;
|
|
27
|
+
}>;
|
|
28
|
+
/**
|
|
29
|
+
* Holds movement controls until changed (or for {@code ticks} game ticks, 20 per second). Pass false to release
|
|
30
|
+
* a control; {@link stop} releases all of them.
|
|
31
|
+
*/
|
|
32
|
+
move(controls: MoveControls, opts?: {
|
|
33
|
+
ticks?: number;
|
|
34
|
+
}): Promise<MoveControls & {
|
|
35
|
+
releaseInTicks?: number;
|
|
36
|
+
}>;
|
|
37
|
+
/** Releases every control and cancels a running walkTo/dig/held use. */
|
|
38
|
+
stopActions(): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Walks in a straight line to (x, z), jumping over single blocks and swimming. Resolves when within
|
|
41
|
+
* {@code range} blocks, or with {@code arrived: false} when stuck (no progress for 3 s) or timed out.
|
|
42
|
+
* There is no path finding: route around obstacles with intermediate points.
|
|
43
|
+
*/
|
|
44
|
+
walkTo(x: number, z: number, opts?: {
|
|
45
|
+
range?: number;
|
|
46
|
+
sprint?: boolean;
|
|
47
|
+
timeoutMs?: number;
|
|
48
|
+
}): Promise<WalkResult>;
|
|
49
|
+
/** Left click: attacks the entity (facing it first) or whatever the crosshair points at. */
|
|
50
|
+
attack(entityId?: number): Promise<HitTarget>;
|
|
51
|
+
/**
|
|
52
|
+
* Right click: interacts with an entity, a block (opening chests, pressing buttons, placing the held block
|
|
53
|
+
* against that face) or, with no target, whatever the crosshair points at / the held item in the air.
|
|
54
|
+
* {@code holdTicks} keeps the button pressed afterwards (eating, drinking, drawing a bow, shields).
|
|
55
|
+
*/
|
|
56
|
+
use(target?: {
|
|
57
|
+
entityId?: number;
|
|
58
|
+
block?: BlockPosition & {
|
|
59
|
+
face?: BlockFace;
|
|
60
|
+
};
|
|
61
|
+
holdTicks?: number;
|
|
62
|
+
}): Promise<HitTarget>;
|
|
63
|
+
/** Mines a block like a player (holding left click, taking the real break time). */
|
|
64
|
+
dig(block: BlockPosition & {
|
|
65
|
+
face?: BlockFace;
|
|
66
|
+
}, opts?: {
|
|
67
|
+
timeoutMs?: number;
|
|
68
|
+
}): Promise<DigResult>;
|
|
69
|
+
/** The block at a position as the client sees it. */
|
|
70
|
+
block(pos: BlockPosition): Promise<BlockInfo>;
|
|
71
|
+
/** What the crosshair points at. */
|
|
72
|
+
target(): Promise<HitTarget>;
|
|
73
|
+
inventory(): Promise<InventoryInfo>;
|
|
74
|
+
/** Selects hotbar slot 0-8. */
|
|
75
|
+
selectSlot(slot: number): Promise<{
|
|
76
|
+
selected: number;
|
|
77
|
+
item: ItemInfo | null;
|
|
78
|
+
}>;
|
|
79
|
+
/** The open container (chest, furnace, villager trade, ...) or the inventory; {@code waitMs} waits for one to open. */
|
|
80
|
+
container(opts?: {
|
|
81
|
+
waitMs?: number;
|
|
82
|
+
}): Promise<ContainerInfo>;
|
|
83
|
+
/**
|
|
84
|
+
* Clicks a slot of the open container (or the inventory). Modes: pickup (default; button 0 left, 1 right),
|
|
85
|
+
* quick_move (shift click), swap (button = hotbar slot 0-8 or 40 for the offhand), clone, throw (button 1 =
|
|
86
|
+
* whole stack), quick_craft, pickup_all. Slot -999 is outside the window.
|
|
87
|
+
*/
|
|
88
|
+
click(slot: number, opts?: {
|
|
89
|
+
button?: number;
|
|
90
|
+
mode?: ClickMode;
|
|
91
|
+
}): Promise<ContainerInfo>;
|
|
92
|
+
closeContainer(): Promise<void>;
|
|
93
|
+
/** Drops one item (or the whole stack) from the selected hotbar slot. */
|
|
94
|
+
drop(opts?: {
|
|
95
|
+
all?: boolean;
|
|
96
|
+
}): Promise<ItemInfo>;
|
|
221
97
|
setRender(enabled: boolean): Promise<void>;
|
|
222
98
|
/** Takes a screenshot and returns the PNG. With {@code keep} the file stays in the game's screenshots folder. */
|
|
223
99
|
screenshot({ keep }?: {
|