nucleation 0.3.1 → 0.3.3
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/Blocks.d.ts +83 -0
- package/Blocks.mjs +279 -0
- package/BuildingTool.d.ts +17 -0
- package/BuildingTool.mjs +47 -0
- package/Palette.d.ts +22 -0
- package/Palette.mjs +65 -0
- package/PaletteBuilder.d.ts +25 -0
- package/PaletteBuilder.mjs +91 -0
- package/index.d.ts +2 -0
- package/index.mjs +2 -0
- package/nucleation.wasm +0 -0
- package/package.json +1 -1
package/Blocks.d.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import type { NucleationError } from "./NucleationError"
|
|
3
|
+
import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Namespace for read-only queries over the built-in block table
|
|
9
|
+
* (Java 26.2 blocks + official semantics extracted from the vanilla
|
|
10
|
+
* jars: definition kinds, base-block links, block tags, model
|
|
11
|
+
* geometry). All list results are JSON array strings sorted by id;
|
|
12
|
+
* block/tag/kind arguments accept both `minecraft:`-prefixed and
|
|
13
|
+
* short forms (`minecraft:oak_stairs` / `oak_stairs`).
|
|
14
|
+
*/
|
|
15
|
+
export class Blocks {
|
|
16
|
+
/** @internal */
|
|
17
|
+
get ffiValue(): pointer;
|
|
18
|
+
/** @internal */
|
|
19
|
+
constructor();
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Full facts for one block as a JSON object:
|
|
24
|
+
* `{id, kind, base_block, tags: [...], full_cube, transparent,
|
|
25
|
+
* color: [r, g, b] | null, properties: {name: [values...]},
|
|
26
|
+
* default_state: {name: value}}`. `kind` is the official
|
|
27
|
+
* definition kind (`minecraft:stair`, plain full blocks are
|
|
28
|
+
* `minecraft:block`); `base_block` is the block this one is a
|
|
29
|
+
* shape variant of (or `null`); `color` is the texture-derived
|
|
30
|
+
* average RGB. Errors with `NotFound` for unknown ids.
|
|
31
|
+
*/
|
|
32
|
+
static getJson(id: string): string;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* All known block ids as a sorted JSON array string.
|
|
36
|
+
*/
|
|
37
|
+
static idsJson(): string;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Ids of every block carrying the vanilla block tag, as a sorted
|
|
41
|
+
* JSON array string (`[]` for unknown tags). Accepts
|
|
42
|
+
* `minecraft:wool` and short `wool` forms, including nested paths
|
|
43
|
+
* like `mineable/pickaxe`.
|
|
44
|
+
*/
|
|
45
|
+
static byTagJson(tag: string): string;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Ids of every block of the given official definition kind
|
|
49
|
+
* (`minecraft:stair`, `minecraft:slab`, `minecraft:door`, ...), as
|
|
50
|
+
* a sorted JSON array string (`[]` for unknown kinds).
|
|
51
|
+
*/
|
|
52
|
+
static byKindJson(kind: string): string;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The base block followed by all its shape variants — blocks whose
|
|
56
|
+
* `base_block` is `base_id` (stairs, slabs, walls, fences of the
|
|
57
|
+
* base) — as a JSON array string. The base itself is always first;
|
|
58
|
+
* variants follow sorted by id. Errors with `NotFound` for unknown
|
|
59
|
+
* base ids.
|
|
60
|
+
*/
|
|
61
|
+
static variantsOfJson(baseId: string): string;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* All known vanilla block tag names as a sorted JSON array string
|
|
65
|
+
* (`minecraft:`-prefixed, e.g. `minecraft:wool`).
|
|
66
|
+
*/
|
|
67
|
+
static tagsJson(): string;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Every property-value combination of the block as a JSON array of
|
|
71
|
+
* `{prop: value}` objects (a single `{}` entry for property-less
|
|
72
|
+
* blocks). Errors with `NotFound` for unknown ids and with
|
|
73
|
+
* `InvalidArgument` if the combination count exceeds 4096 (guard
|
|
74
|
+
* against pathological output; the current data tops out at 1350
|
|
75
|
+
* for `minecraft:note_block`).
|
|
76
|
+
*/
|
|
77
|
+
static statesJson(id: string): string;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Total number of blocks in the table.
|
|
81
|
+
*/
|
|
82
|
+
static count(): number;
|
|
83
|
+
}
|
package/Blocks.mjs
ADDED
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import { NucleationError } from "./NucleationError.mjs"
|
|
3
|
+
import wasm from "./diplomat-wasm.mjs";
|
|
4
|
+
import * as diplomatRuntime from "./diplomat-runtime.mjs";
|
|
5
|
+
|
|
6
|
+
const Blocks_box_destroy_registry = new FinalizationRegistry((ptr) => {
|
|
7
|
+
wasm.Blocks_destroy(ptr);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Namespace for read-only queries over the built-in block table
|
|
12
|
+
* (Java 26.2 blocks + official semantics extracted from the vanilla
|
|
13
|
+
* jars: definition kinds, base-block links, block tags, model
|
|
14
|
+
* geometry). All list results are JSON array strings sorted by id;
|
|
15
|
+
* block/tag/kind arguments accept both `minecraft:`-prefixed and
|
|
16
|
+
* short forms (`minecraft:oak_stairs` / `oak_stairs`).
|
|
17
|
+
*/
|
|
18
|
+
export class Blocks {
|
|
19
|
+
// Internal ptr reference:
|
|
20
|
+
#ptr = null;
|
|
21
|
+
|
|
22
|
+
// Lifetimes are only to keep dependencies alive.
|
|
23
|
+
// Since JS won't garbage collect until there are no incoming edges.
|
|
24
|
+
#selfEdge = [];
|
|
25
|
+
|
|
26
|
+
#internalConstructor(symbol, ptr, selfEdge) {
|
|
27
|
+
if (symbol !== diplomatRuntime.internalConstructor) {
|
|
28
|
+
console.error("Blocks is an Opaque type. You cannot call its constructor.");
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
this.#ptr = ptr;
|
|
32
|
+
this.#selfEdge = selfEdge;
|
|
33
|
+
|
|
34
|
+
// Are we being borrowed? If not, we can register.
|
|
35
|
+
if (this.#selfEdge.length === 0) {
|
|
36
|
+
Blocks_box_destroy_registry.register(this, this.#ptr);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
/** @internal */
|
|
42
|
+
get ffiValue() {
|
|
43
|
+
return this.#ptr;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Full facts for one block as a JSON object:
|
|
49
|
+
* `{id, kind, base_block, tags: [...], full_cube, transparent,
|
|
50
|
+
* color: [r, g, b] | null, properties: {name: [values...]},
|
|
51
|
+
* default_state: {name: value}}`. `kind` is the official
|
|
52
|
+
* definition kind (`minecraft:stair`, plain full blocks are
|
|
53
|
+
* `minecraft:block`); `base_block` is the block this one is a
|
|
54
|
+
* shape variant of (or `null`); `color` is the texture-derived
|
|
55
|
+
* average RGB. Errors with `NotFound` for unknown ids.
|
|
56
|
+
*/
|
|
57
|
+
static getJson(id) {
|
|
58
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
59
|
+
|
|
60
|
+
const idSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, id)));
|
|
61
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
62
|
+
|
|
63
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
const result = wasm.Blocks_get_json(diplomatReceive.buffer, idSlice.ptr, write.buffer);
|
|
67
|
+
|
|
68
|
+
try {
|
|
69
|
+
if (!diplomatReceive.resultFlag) {
|
|
70
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
71
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
72
|
+
}
|
|
73
|
+
return write.readString8();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
finally {
|
|
77
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
78
|
+
functionCleanupArena.free();
|
|
79
|
+
|
|
80
|
+
diplomatReceive.free();
|
|
81
|
+
write.free();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* All known block ids as a sorted JSON array string.
|
|
87
|
+
*/
|
|
88
|
+
static idsJson() {
|
|
89
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
90
|
+
|
|
91
|
+
wasm.Blocks_ids_json(write.buffer);
|
|
92
|
+
|
|
93
|
+
try {
|
|
94
|
+
return write.readString8();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
finally {
|
|
98
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
99
|
+
write.free();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Ids of every block carrying the vanilla block tag, as a sorted
|
|
105
|
+
* JSON array string (`[]` for unknown tags). Accepts
|
|
106
|
+
* `minecraft:wool` and short `wool` forms, including nested paths
|
|
107
|
+
* like `mineable/pickaxe`.
|
|
108
|
+
*/
|
|
109
|
+
static byTagJson(tag) {
|
|
110
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
111
|
+
|
|
112
|
+
const tagSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, tag)));
|
|
113
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
114
|
+
|
|
115
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
const result = wasm.Blocks_by_tag_json(diplomatReceive.buffer, tagSlice.ptr, write.buffer);
|
|
119
|
+
|
|
120
|
+
try {
|
|
121
|
+
if (!diplomatReceive.resultFlag) {
|
|
122
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
123
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
124
|
+
}
|
|
125
|
+
return write.readString8();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
finally {
|
|
129
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
130
|
+
functionCleanupArena.free();
|
|
131
|
+
|
|
132
|
+
diplomatReceive.free();
|
|
133
|
+
write.free();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Ids of every block of the given official definition kind
|
|
139
|
+
* (`minecraft:stair`, `minecraft:slab`, `minecraft:door`, ...), as
|
|
140
|
+
* a sorted JSON array string (`[]` for unknown kinds).
|
|
141
|
+
*/
|
|
142
|
+
static byKindJson(kind) {
|
|
143
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
144
|
+
|
|
145
|
+
const kindSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, kind)));
|
|
146
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
147
|
+
|
|
148
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
const result = wasm.Blocks_by_kind_json(diplomatReceive.buffer, kindSlice.ptr, write.buffer);
|
|
152
|
+
|
|
153
|
+
try {
|
|
154
|
+
if (!diplomatReceive.resultFlag) {
|
|
155
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
156
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
157
|
+
}
|
|
158
|
+
return write.readString8();
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
finally {
|
|
162
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
163
|
+
functionCleanupArena.free();
|
|
164
|
+
|
|
165
|
+
diplomatReceive.free();
|
|
166
|
+
write.free();
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* The base block followed by all its shape variants — blocks whose
|
|
172
|
+
* `base_block` is `base_id` (stairs, slabs, walls, fences of the
|
|
173
|
+
* base) — as a JSON array string. The base itself is always first;
|
|
174
|
+
* variants follow sorted by id. Errors with `NotFound` for unknown
|
|
175
|
+
* base ids.
|
|
176
|
+
*/
|
|
177
|
+
static variantsOfJson(baseId) {
|
|
178
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
179
|
+
|
|
180
|
+
const baseIdSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, baseId)));
|
|
181
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
182
|
+
|
|
183
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
const result = wasm.Blocks_variants_of_json(diplomatReceive.buffer, baseIdSlice.ptr, write.buffer);
|
|
187
|
+
|
|
188
|
+
try {
|
|
189
|
+
if (!diplomatReceive.resultFlag) {
|
|
190
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
191
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
192
|
+
}
|
|
193
|
+
return write.readString8();
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
finally {
|
|
197
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
198
|
+
functionCleanupArena.free();
|
|
199
|
+
|
|
200
|
+
diplomatReceive.free();
|
|
201
|
+
write.free();
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* All known vanilla block tag names as a sorted JSON array string
|
|
207
|
+
* (`minecraft:`-prefixed, e.g. `minecraft:wool`).
|
|
208
|
+
*/
|
|
209
|
+
static tagsJson() {
|
|
210
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
211
|
+
|
|
212
|
+
wasm.Blocks_tags_json(write.buffer);
|
|
213
|
+
|
|
214
|
+
try {
|
|
215
|
+
return write.readString8();
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
finally {
|
|
219
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
220
|
+
write.free();
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Every property-value combination of the block as a JSON array of
|
|
226
|
+
* `{prop: value}` objects (a single `{}` entry for property-less
|
|
227
|
+
* blocks). Errors with `NotFound` for unknown ids and with
|
|
228
|
+
* `InvalidArgument` if the combination count exceeds 4096 (guard
|
|
229
|
+
* against pathological output; the current data tops out at 1350
|
|
230
|
+
* for `minecraft:note_block`).
|
|
231
|
+
*/
|
|
232
|
+
static statesJson(id) {
|
|
233
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
234
|
+
|
|
235
|
+
const idSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, id)));
|
|
236
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
237
|
+
|
|
238
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
const result = wasm.Blocks_states_json(diplomatReceive.buffer, idSlice.ptr, write.buffer);
|
|
242
|
+
|
|
243
|
+
try {
|
|
244
|
+
if (!diplomatReceive.resultFlag) {
|
|
245
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
246
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
247
|
+
}
|
|
248
|
+
return write.readString8();
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
finally {
|
|
252
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
253
|
+
functionCleanupArena.free();
|
|
254
|
+
|
|
255
|
+
diplomatReceive.free();
|
|
256
|
+
write.free();
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Total number of blocks in the table.
|
|
262
|
+
*/
|
|
263
|
+
static count() {
|
|
264
|
+
|
|
265
|
+
const result = wasm.Blocks_count();
|
|
266
|
+
|
|
267
|
+
try {
|
|
268
|
+
return result;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
finally {
|
|
272
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
constructor(symbol, ptr, selfEdge) {
|
|
277
|
+
return this.#internalConstructor(...arguments)
|
|
278
|
+
}
|
|
279
|
+
}
|
package/BuildingTool.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// generated by diplomat-tool
|
|
2
2
|
import type { Brush } from "./Brush"
|
|
3
|
+
import type { NucleationError } from "./NucleationError"
|
|
3
4
|
import type { Schematic } from "./Schematic"
|
|
4
5
|
import type { Shape } from "./Shape"
|
|
5
6
|
import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
|
|
@@ -26,4 +27,20 @@ export class BuildingTool {
|
|
|
26
27
|
* Fill `count` copies of `shape`, each offset by `offset * i`.
|
|
27
28
|
*/
|
|
28
29
|
static rstack(schematic: Schematic, shape: Shape, brush: Brush, count: number, offsetX: number, offsetY: number, offsetZ: number): void;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Masked fill that preserves everything already placed: `brush` is
|
|
33
|
+
* only written where `schematic` currently has air (or nothing at
|
|
34
|
+
* all), so existing structures inside `shape` survive untouched.
|
|
35
|
+
*/
|
|
36
|
+
static fillOnlyAir(schematic: Schematic, shape: Shape, brush: Brush): void;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Masked fill that only overwrites the listed blocks: `targets_json`
|
|
40
|
+
* is a JSON array of block ids (e.g. `["minecraft:stone"]`, state
|
|
41
|
+
* properties ignored) and every cell of `shape` whose current block
|
|
42
|
+
* id is in the list is replaced by `brush` — everything else,
|
|
43
|
+
* including air, is left alone.
|
|
44
|
+
*/
|
|
45
|
+
static fillReplacing(schematic: Schematic, shape: Shape, brush: Brush, targetsJson: string): void;
|
|
29
46
|
}
|
package/BuildingTool.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// generated by diplomat-tool
|
|
2
2
|
import { Brush } from "./Brush.mjs"
|
|
3
|
+
import { NucleationError } from "./NucleationError.mjs"
|
|
3
4
|
import { Schematic } from "./Schematic.mjs"
|
|
4
5
|
import { Shape } from "./Shape.mjs"
|
|
5
6
|
import wasm from "./diplomat-wasm.mjs";
|
|
@@ -68,6 +69,52 @@ export class BuildingTool {
|
|
|
68
69
|
}
|
|
69
70
|
}
|
|
70
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Masked fill that preserves everything already placed: `brush` is
|
|
74
|
+
* only written where `schematic` currently has air (or nothing at
|
|
75
|
+
* all), so existing structures inside `shape` survive untouched.
|
|
76
|
+
*/
|
|
77
|
+
static fillOnlyAir(schematic, shape, brush) {
|
|
78
|
+
wasm.BuildingTool_fill_only_air(schematic.ffiValue, shape.ffiValue, brush.ffiValue);
|
|
79
|
+
|
|
80
|
+
try {}
|
|
81
|
+
|
|
82
|
+
finally {
|
|
83
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Masked fill that only overwrites the listed blocks: `targets_json`
|
|
89
|
+
* is a JSON array of block ids (e.g. `["minecraft:stone"]`, state
|
|
90
|
+
* properties ignored) and every cell of `shape` whose current block
|
|
91
|
+
* id is in the list is replaced by `brush` — everything else,
|
|
92
|
+
* including air, is left alone.
|
|
93
|
+
*/
|
|
94
|
+
static fillReplacing(schematic, shape, brush, targetsJson) {
|
|
95
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
96
|
+
|
|
97
|
+
const targetsJsonSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, targetsJson)));
|
|
98
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
const result = wasm.BuildingTool_fill_replacing(diplomatReceive.buffer, schematic.ffiValue, shape.ffiValue, brush.ffiValue, targetsJsonSlice.ptr);
|
|
102
|
+
|
|
103
|
+
try {
|
|
104
|
+
if (!diplomatReceive.resultFlag) {
|
|
105
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
106
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
finally {
|
|
111
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
112
|
+
functionCleanupArena.free();
|
|
113
|
+
|
|
114
|
+
diplomatReceive.free();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
71
118
|
constructor(symbol, ptr, selfEdge) {
|
|
72
119
|
return this.#internalConstructor(...arguments)
|
|
73
120
|
}
|
package/Palette.d.ts
CHANGED
|
@@ -59,6 +59,28 @@ export class Palette {
|
|
|
59
59
|
*/
|
|
60
60
|
static grayscale(): Palette;
|
|
61
61
|
|
|
62
|
+
/**
|
|
63
|
+
* The planks family — a natural light→dark wood ramp.
|
|
64
|
+
*/
|
|
65
|
+
static wood(): Palette;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* A copy of this palette ordered by perceptual lightness (Oklab L,
|
|
69
|
+
* dark → light). Combined with `block_ids_json`, gives a
|
|
70
|
+
* ready-to-index ramp: `ids[i]` for intensity `i / (len - 1)`.
|
|
71
|
+
*/
|
|
72
|
+
sortedByLightness(): Palette;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* JSON array of exactly `steps` block ids sampling the color
|
|
76
|
+
* gradient from (`r1`,`g1`,`b1`) to (`r2`,`g2`,`b2`) in Oklab
|
|
77
|
+
* space, each step snapped to this palette's closest block. Built
|
|
78
|
+
* for value→block lookups (heatmaps, fractals): index the returned
|
|
79
|
+
* list by `intensity * (steps - 1)`. Entries may repeat on coarse
|
|
80
|
+
* palettes; errors with `NotFound` on an empty palette.
|
|
81
|
+
*/
|
|
82
|
+
gradientIdsJson(r1: number, g1: number, b1: number, r2: number, g2: number, b2: number, steps: number): string;
|
|
83
|
+
|
|
62
84
|
/**
|
|
63
85
|
* Custom palette from a JSON array of block ids, e.g.
|
|
64
86
|
* `["minecraft:stone", "minecraft:oak_planks"]`. Ids blockpedia has
|
package/Palette.mjs
CHANGED
|
@@ -172,6 +172,71 @@ export class Palette {
|
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
+
/**
|
|
176
|
+
* The planks family — a natural light→dark wood ramp.
|
|
177
|
+
*/
|
|
178
|
+
static wood() {
|
|
179
|
+
|
|
180
|
+
const result = wasm.Palette_wood();
|
|
181
|
+
|
|
182
|
+
try {
|
|
183
|
+
return new Palette(diplomatRuntime.internalConstructor, result, []);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
finally {
|
|
187
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* A copy of this palette ordered by perceptual lightness (Oklab L,
|
|
193
|
+
* dark → light). Combined with `block_ids_json`, gives a
|
|
194
|
+
* ready-to-index ramp: `ids[i]` for intensity `i / (len - 1)`.
|
|
195
|
+
*/
|
|
196
|
+
sortedByLightness() {
|
|
197
|
+
|
|
198
|
+
const result = wasm.Palette_sorted_by_lightness(this.ffiValue);
|
|
199
|
+
|
|
200
|
+
try {
|
|
201
|
+
return new Palette(diplomatRuntime.internalConstructor, result, []);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
finally {
|
|
205
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* JSON array of exactly `steps` block ids sampling the color
|
|
211
|
+
* gradient from (`r1`,`g1`,`b1`) to (`r2`,`g2`,`b2`) in Oklab
|
|
212
|
+
* space, each step snapped to this palette's closest block. Built
|
|
213
|
+
* for value→block lookups (heatmaps, fractals): index the returned
|
|
214
|
+
* list by `intensity * (steps - 1)`. Entries may repeat on coarse
|
|
215
|
+
* palettes; errors with `NotFound` on an empty palette.
|
|
216
|
+
*/
|
|
217
|
+
gradientIdsJson(r1, g1, b1, r2, g2, b2, steps) {
|
|
218
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
219
|
+
|
|
220
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
const result = wasm.Palette_gradient_ids_json(diplomatReceive.buffer, this.ffiValue, r1, g1, b1, r2, g2, b2, steps, write.buffer);
|
|
224
|
+
|
|
225
|
+
try {
|
|
226
|
+
if (!diplomatReceive.resultFlag) {
|
|
227
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
228
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
229
|
+
}
|
|
230
|
+
return write.readString8();
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
finally {
|
|
234
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
235
|
+
diplomatReceive.free();
|
|
236
|
+
write.free();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
175
240
|
/**
|
|
176
241
|
* Custom palette from a JSON array of block ids, e.g.
|
|
177
242
|
* `["minecraft:stone", "minecraft:oak_planks"]`. Ids blockpedia has
|
package/PaletteBuilder.d.ts
CHANGED
|
@@ -35,6 +35,8 @@ export class PaletteBuilder {
|
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* Keep only full cube blocks (no stairs, slabs, fences, ...).
|
|
38
|
+
* Metadata-driven: uses the official model geometry extracted from
|
|
39
|
+
* the vanilla jars, not block-name guessing.
|
|
38
40
|
*/
|
|
39
41
|
fullBlocksOnly(): void;
|
|
40
42
|
|
|
@@ -45,6 +47,8 @@ export class PaletteBuilder {
|
|
|
45
47
|
|
|
46
48
|
/**
|
|
47
49
|
* Exclude transparent/translucent blocks (glass, leaves, ...).
|
|
50
|
+
* Metadata-driven: uses the per-block transparency flag from the
|
|
51
|
+
* block-data pipeline, not block-name guessing.
|
|
48
52
|
*/
|
|
49
53
|
excludeTransparent(): void;
|
|
50
54
|
|
|
@@ -69,6 +73,27 @@ export class PaletteBuilder {
|
|
|
69
73
|
*/
|
|
70
74
|
includeKeyword(keyword: string): void;
|
|
71
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Require the vanilla block tag `t` (`minecraft:wool` or short
|
|
78
|
+
* `wool`, nested paths like `mineable/pickaxe` too). Repeatable —
|
|
79
|
+
* a block must carry ALL required tags (AND semantics).
|
|
80
|
+
*/
|
|
81
|
+
tag(t: string): void;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Exclude blocks carrying the vanilla block tag `t` (any listed
|
|
85
|
+
* tag disqualifies). Repeatable.
|
|
86
|
+
*/
|
|
87
|
+
excludeTag(t: string): void;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Keep only blocks of the official definition kind `k`
|
|
91
|
+
* (`minecraft:stair` or short `stair`; plain full blocks are
|
|
92
|
+
* `minecraft:block`). Repeatable — a block matching ANY listed
|
|
93
|
+
* kind passes (OR semantics).
|
|
94
|
+
*/
|
|
95
|
+
kind(k: string): void;
|
|
96
|
+
|
|
72
97
|
/**
|
|
73
98
|
* Build the palette; consumes the builder.
|
|
74
99
|
*/
|
package/PaletteBuilder.mjs
CHANGED
|
@@ -105,6 +105,8 @@ export class PaletteBuilder {
|
|
|
105
105
|
|
|
106
106
|
/**
|
|
107
107
|
* Keep only full cube blocks (no stairs, slabs, fences, ...).
|
|
108
|
+
* Metadata-driven: uses the official model geometry extracted from
|
|
109
|
+
* the vanilla jars, not block-name guessing.
|
|
108
110
|
*/
|
|
109
111
|
fullBlocksOnly() {
|
|
110
112
|
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
@@ -149,6 +151,8 @@ export class PaletteBuilder {
|
|
|
149
151
|
|
|
150
152
|
/**
|
|
151
153
|
* Exclude transparent/translucent blocks (glass, leaves, ...).
|
|
154
|
+
* Metadata-driven: uses the per-block transparency flag from the
|
|
155
|
+
* block-data pipeline, not block-name guessing.
|
|
152
156
|
*/
|
|
153
157
|
excludeTransparent() {
|
|
154
158
|
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
@@ -268,6 +272,93 @@ export class PaletteBuilder {
|
|
|
268
272
|
}
|
|
269
273
|
}
|
|
270
274
|
|
|
275
|
+
/**
|
|
276
|
+
* Require the vanilla block tag `t` (`minecraft:wool` or short
|
|
277
|
+
* `wool`, nested paths like `mineable/pickaxe` too). Repeatable —
|
|
278
|
+
* a block must carry ALL required tags (AND semantics).
|
|
279
|
+
*/
|
|
280
|
+
tag(t) {
|
|
281
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
282
|
+
|
|
283
|
+
const tSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, t)));
|
|
284
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
const result = wasm.PaletteBuilder_tag(diplomatReceive.buffer, this.ffiValue, tSlice.ptr);
|
|
288
|
+
|
|
289
|
+
try {
|
|
290
|
+
if (!diplomatReceive.resultFlag) {
|
|
291
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
292
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
finally {
|
|
297
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
298
|
+
functionCleanupArena.free();
|
|
299
|
+
|
|
300
|
+
diplomatReceive.free();
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Exclude blocks carrying the vanilla block tag `t` (any listed
|
|
306
|
+
* tag disqualifies). Repeatable.
|
|
307
|
+
*/
|
|
308
|
+
excludeTag(t) {
|
|
309
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
310
|
+
|
|
311
|
+
const tSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, t)));
|
|
312
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
const result = wasm.PaletteBuilder_exclude_tag(diplomatReceive.buffer, this.ffiValue, tSlice.ptr);
|
|
316
|
+
|
|
317
|
+
try {
|
|
318
|
+
if (!diplomatReceive.resultFlag) {
|
|
319
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
320
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
finally {
|
|
325
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
326
|
+
functionCleanupArena.free();
|
|
327
|
+
|
|
328
|
+
diplomatReceive.free();
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Keep only blocks of the official definition kind `k`
|
|
334
|
+
* (`minecraft:stair` or short `stair`; plain full blocks are
|
|
335
|
+
* `minecraft:block`). Repeatable — a block matching ANY listed
|
|
336
|
+
* kind passes (OR semantics).
|
|
337
|
+
*/
|
|
338
|
+
kind(k) {
|
|
339
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
340
|
+
|
|
341
|
+
const kSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, k)));
|
|
342
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
const result = wasm.PaletteBuilder_kind(diplomatReceive.buffer, this.ffiValue, kSlice.ptr);
|
|
346
|
+
|
|
347
|
+
try {
|
|
348
|
+
if (!diplomatReceive.resultFlag) {
|
|
349
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
350
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
finally {
|
|
355
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
356
|
+
functionCleanupArena.free();
|
|
357
|
+
|
|
358
|
+
diplomatReceive.free();
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
271
362
|
/**
|
|
272
363
|
* Build the palette; consumes the builder.
|
|
273
364
|
*/
|
package/index.d.ts
CHANGED
package/index.mjs
CHANGED
package/nucleation.wasm
CHANGED
|
Binary file
|