nucleation 0.2.18 → 0.3.1
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/Autostack.d.ts +43 -0
- package/Autostack.mjs +134 -0
- package/BlockPos.d.ts +28 -0
- package/BlockPos.mjs +129 -0
- package/BlockState.d.ts +39 -0
- package/BlockState.mjs +134 -0
- package/Brush.d.ts +68 -0
- package/Brush.mjs +220 -0
- package/BuildingTool.d.ts +29 -0
- package/BuildingTool.mjs +74 -0
- package/ChunkMeshResult.d.ts +75 -0
- package/ChunkMeshResult.mjs +253 -0
- package/CircuitBuilder.d.ts +118 -0
- package/CircuitBuilder.mjs +516 -0
- package/DefinitionRegion.d.ts +274 -0
- package/DefinitionRegion.mjs +973 -0
- package/Diff.d.ts +88 -0
- package/Diff.mjs +316 -0
- package/Dimensions.d.ts +28 -0
- package/Dimensions.mjs +129 -0
- package/ExecutionMode.d.ts +42 -0
- package/ExecutionMode.mjs +127 -0
- package/Fingerprint.d.ts +44 -0
- package/Fingerprint.mjs +197 -0
- package/InterpolationSpace.d.ts +25 -0
- package/InterpolationSpace.mjs +73 -0
- package/IoLayout.d.ts +26 -0
- package/IoLayout.mjs +81 -0
- package/IoLayoutBuilder.d.ts +73 -0
- package/IoLayoutBuilder.mjs +315 -0
- package/IoType.d.ts +41 -0
- package/IoType.mjs +125 -0
- package/ItemModelConfig.d.ts +65 -0
- package/ItemModelConfig.mjs +223 -0
- package/ItemModelPackBuilder.d.ts +32 -0
- package/ItemModelPackBuilder.mjs +104 -0
- package/ItemModelResult.d.ts +72 -0
- package/ItemModelResult.mjs +268 -0
- package/ItemScale.d.ts +31 -0
- package/ItemScale.mjs +132 -0
- package/LayoutFunction.d.ts +52 -0
- package/LayoutFunction.mjs +159 -0
- package/MchprsWorld.d.ts +131 -0
- package/MchprsWorld.mjs +423 -0
- package/MeshBounds.d.ts +40 -0
- package/MeshBounds.mjs +180 -0
- package/MeshConfig.d.ts +101 -0
- package/MeshConfig.mjs +306 -0
- package/MeshJob.d.ts +44 -0
- package/MeshJob.mjs +116 -0
- package/MeshPhase.d.ts +38 -0
- package/MeshPhase.mjs +90 -0
- package/MeshProgress.d.ts +32 -0
- package/MeshProgress.mjs +133 -0
- package/MeshResult.d.ts +60 -0
- package/MeshResult.mjs +206 -0
- package/MultiMeshResult.d.ts +50 -0
- package/MultiMeshResult.mjs +166 -0
- package/Nbt.d.ts +50 -0
- package/Nbt.mjs +161 -0
- package/NucleationError.d.ts +36 -0
- package/NucleationError.mjs +104 -0
- package/OutputCondition.d.ts +45 -0
- package/OutputCondition.mjs +129 -0
- package/Palette.d.ts +84 -0
- package/Palette.mjs +269 -0
- package/PaletteBuilder.d.ts +76 -0
- package/PaletteBuilder.mjs +297 -0
- package/README.md +28 -197
- package/RawMeshExport.d.ts +74 -0
- package/RawMeshExport.mjs +243 -0
- package/RedstoneGraph.d.ts +58 -0
- package/RedstoneGraph.mjs +242 -0
- package/RegionBounds.d.ts +41 -0
- package/RegionBounds.mjs +181 -0
- package/RenderConfig.d.ts +66 -0
- package/RenderConfig.mjs +170 -0
- package/Renderer.d.ts +35 -0
- package/Renderer.mjs +139 -0
- package/ResourcePack.d.ts +105 -0
- package/ResourcePack.mjs +447 -0
- package/ResourcePackList.d.ts +32 -0
- package/ResourcePackList.mjs +96 -0
- package/Schematic.d.ts +655 -0
- package/Schematic.mjs +2647 -0
- package/SchematicBuilder.d.ts +103 -0
- package/SchematicBuilder.mjs +401 -0
- package/SchematicRegions.d.ts +93 -0
- package/SchematicRegions.mjs +411 -0
- package/Scripting.d.ts +40 -0
- package/Scripting.mjs +138 -0
- package/Sdf.d.ts +31 -0
- package/Sdf.mjs +107 -0
- package/Shape.d.ts +108 -0
- package/Shape.mjs +336 -0
- package/SortStrategy.d.ts +86 -0
- package/SortStrategy.mjs +272 -0
- package/Store.d.ts +83 -0
- package/Store.mjs +369 -0
- package/StoreIo.d.ts +71 -0
- package/StoreIo.mjs +292 -0
- package/TextureAtlas.d.ts +40 -0
- package/TextureAtlas.mjs +122 -0
- package/TextureInfo.d.ts +34 -0
- package/TextureInfo.mjs +148 -0
- package/TypedCircuitExecutor.d.ts +101 -0
- package/TypedCircuitExecutor.mjs +378 -0
- package/Value.d.ts +73 -0
- package/Value.mjs +275 -0
- package/WorldChunkView.d.ts +63 -0
- package/WorldChunkView.mjs +201 -0
- package/WorldSink.d.ts +50 -0
- package/WorldSink.mjs +177 -0
- package/WorldStream.d.ts +45 -0
- package/WorldStream.mjs +184 -0
- package/diplomat-runtime.d.ts +15 -0
- package/diplomat-runtime.mjs +774 -0
- package/diplomat-wasm.mjs +52 -0
- package/diplomat.config.mjs +6 -0
- package/index.d.ts +117 -0
- package/index.mjs +120 -0
- package/{nucleation_bg.wasm → nucleation.wasm} +0 -0
- package/package.json +19 -41
- package/LICENSE +0 -21
- package/api.js +0 -608
- package/nucleation-cdn-loader.js +0 -15
- package/nucleation-original.js +0 -8383
- package/nucleation.d.ts +0 -2947
- package/nucleation.js +0 -36
package/Schematic.mjs
ADDED
|
@@ -0,0 +1,2647 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import { BlockPos } from "./BlockPos.mjs"
|
|
3
|
+
import { BlockState } from "./BlockState.mjs"
|
|
4
|
+
import { Dimensions } from "./Dimensions.mjs"
|
|
5
|
+
import { NucleationError } from "./NucleationError.mjs"
|
|
6
|
+
import wasm from "./diplomat-wasm.mjs";
|
|
7
|
+
import * as diplomatRuntime from "./diplomat-runtime.mjs";
|
|
8
|
+
|
|
9
|
+
const Schematic_box_destroy_registry = new FinalizationRegistry((ptr) => {
|
|
10
|
+
wasm.Schematic_destroy(ptr);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export class Schematic {
|
|
14
|
+
// Internal ptr reference:
|
|
15
|
+
#ptr = null;
|
|
16
|
+
|
|
17
|
+
// Lifetimes are only to keep dependencies alive.
|
|
18
|
+
// Since JS won't garbage collect until there are no incoming edges.
|
|
19
|
+
#selfEdge = [];
|
|
20
|
+
|
|
21
|
+
#internalConstructor(symbol, ptr, selfEdge) {
|
|
22
|
+
if (symbol !== diplomatRuntime.internalConstructor) {
|
|
23
|
+
console.error("Schematic is an Opaque type. You cannot call its constructor.");
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
this.#ptr = ptr;
|
|
27
|
+
this.#selfEdge = selfEdge;
|
|
28
|
+
|
|
29
|
+
// Are we being borrowed? If not, we can register.
|
|
30
|
+
if (this.#selfEdge.length === 0) {
|
|
31
|
+
Schematic_box_destroy_registry.register(this, this.#ptr);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
/** @internal */
|
|
37
|
+
get ffiValue() {
|
|
38
|
+
return this.#ptr;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Create a new, empty schematic with the given name.
|
|
44
|
+
*/
|
|
45
|
+
static create(name) {
|
|
46
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
47
|
+
|
|
48
|
+
const nameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, name)));
|
|
49
|
+
|
|
50
|
+
const result = wasm.Schematic_create(nameSlice.ptr);
|
|
51
|
+
|
|
52
|
+
try {
|
|
53
|
+
return new Schematic(diplomatRuntime.internalConstructor, result, []);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
finally {
|
|
57
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
58
|
+
functionCleanupArena.free();
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The allocated dimensions (width, height, length) of the schematic's
|
|
65
|
+
* bounding box.
|
|
66
|
+
*/
|
|
67
|
+
dimensions() {
|
|
68
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 12, 4, false);
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
const result = wasm.Schematic_dimensions(diplomatReceive.buffer, this.ffiValue);
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
return Dimensions._fromFFI(diplomatRuntime.internalConstructor, diplomatReceive.buffer);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
finally {
|
|
78
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
79
|
+
diplomatReceive.free();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Returns `true` if a block was placed (out-of-range coordinates extend the
|
|
85
|
+
* schematic rather than erroring, matching `UniversalSchematic::set_block`).
|
|
86
|
+
*/
|
|
87
|
+
setBlock(x, y, z, blockName) {
|
|
88
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
89
|
+
|
|
90
|
+
const blockNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, blockName)));
|
|
91
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 1, true);
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
const result = wasm.Schematic_set_block(diplomatReceive.buffer, this.ffiValue, x, y, z, blockNameSlice.ptr);
|
|
95
|
+
|
|
96
|
+
try {
|
|
97
|
+
if (!diplomatReceive.resultFlag) {
|
|
98
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
99
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
100
|
+
}
|
|
101
|
+
return (new Uint8Array(wasm.memory.buffer, diplomatReceive.buffer, 1))[0] === 1;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
finally {
|
|
105
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
106
|
+
functionCleanupArena.free();
|
|
107
|
+
|
|
108
|
+
diplomatReceive.free();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* The name of the block at a position. `NotFound` if the position is
|
|
114
|
+
* outside every region.
|
|
115
|
+
*/
|
|
116
|
+
getBlockName(x, y, z) {
|
|
117
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
118
|
+
|
|
119
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
const result = wasm.Schematic_get_block_name(diplomatReceive.buffer, this.ffiValue, x, y, z, write.buffer);
|
|
123
|
+
|
|
124
|
+
try {
|
|
125
|
+
if (!diplomatReceive.resultFlag) {
|
|
126
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
127
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
128
|
+
}
|
|
129
|
+
return write.readString8();
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
finally {
|
|
133
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
134
|
+
diplomatReceive.free();
|
|
135
|
+
write.free();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Save the schematic to a file, always in Litematic format (the
|
|
141
|
+
* extension is not consulted; use `save_to_file_with_format` for
|
|
142
|
+
* other formats).
|
|
143
|
+
*/
|
|
144
|
+
saveToFile(path) {
|
|
145
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
146
|
+
|
|
147
|
+
const pathSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, path)));
|
|
148
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
const result = wasm.Schematic_save_to_file(diplomatReceive.buffer, this.ffiValue, pathSlice.ptr);
|
|
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
|
+
}
|
|
159
|
+
|
|
160
|
+
finally {
|
|
161
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
162
|
+
functionCleanupArena.free();
|
|
163
|
+
|
|
164
|
+
diplomatReceive.free();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Load a schematic from a Litematic file (this path is
|
|
170
|
+
* Litematic-only; use `from_data` for format auto-detection).
|
|
171
|
+
*/
|
|
172
|
+
static loadFromFile(path) {
|
|
173
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
174
|
+
|
|
175
|
+
const pathSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, path)));
|
|
176
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
const result = wasm.Schematic_load_from_file(diplomatReceive.buffer, pathSlice.ptr);
|
|
180
|
+
|
|
181
|
+
try {
|
|
182
|
+
if (!diplomatReceive.resultFlag) {
|
|
183
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
184
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
185
|
+
}
|
|
186
|
+
return new Schematic(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
finally {
|
|
190
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
191
|
+
functionCleanupArena.free();
|
|
192
|
+
|
|
193
|
+
diplomatReceive.free();
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Build a schematic from raw byte data, auto-detecting the format.
|
|
199
|
+
* Supports Litematic, Sponge Schematic, and McStructure (Bedrock) formats.
|
|
200
|
+
* `Parse` if a format was detected but failed to parse, `InvalidArgument` if
|
|
201
|
+
* no format was recognized.
|
|
202
|
+
*/
|
|
203
|
+
static fromData(data) {
|
|
204
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
205
|
+
|
|
206
|
+
const dataSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.slice(wasm, data, "u8")));
|
|
207
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
const result = wasm.Schematic_from_data(diplomatReceive.buffer, dataSlice.ptr);
|
|
211
|
+
|
|
212
|
+
try {
|
|
213
|
+
if (!diplomatReceive.resultFlag) {
|
|
214
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
215
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
216
|
+
}
|
|
217
|
+
return new Schematic(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
finally {
|
|
221
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
222
|
+
functionCleanupArena.free();
|
|
223
|
+
|
|
224
|
+
diplomatReceive.free();
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Build a schematic from Litematic data.
|
|
230
|
+
*/
|
|
231
|
+
static fromLitematic(data) {
|
|
232
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
233
|
+
|
|
234
|
+
const dataSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.slice(wasm, data, "u8")));
|
|
235
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
const result = wasm.Schematic_from_litematic(diplomatReceive.buffer, dataSlice.ptr);
|
|
239
|
+
|
|
240
|
+
try {
|
|
241
|
+
if (!diplomatReceive.resultFlag) {
|
|
242
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
243
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
244
|
+
}
|
|
245
|
+
return new Schematic(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
finally {
|
|
249
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
250
|
+
functionCleanupArena.free();
|
|
251
|
+
|
|
252
|
+
diplomatReceive.free();
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* The schematic as Litematic bytes, base64-encoded.
|
|
258
|
+
*/
|
|
259
|
+
toLitematicB64() {
|
|
260
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
261
|
+
|
|
262
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
const result = wasm.Schematic_to_litematic_b64(diplomatReceive.buffer, this.ffiValue, write.buffer);
|
|
266
|
+
|
|
267
|
+
try {
|
|
268
|
+
if (!diplomatReceive.resultFlag) {
|
|
269
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
270
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
271
|
+
}
|
|
272
|
+
return write.readString8();
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
finally {
|
|
276
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
277
|
+
diplomatReceive.free();
|
|
278
|
+
write.free();
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Build a schematic from classic `.schematic` data.
|
|
284
|
+
*/
|
|
285
|
+
static fromSchematic(data) {
|
|
286
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
287
|
+
|
|
288
|
+
const dataSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.slice(wasm, data, "u8")));
|
|
289
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
const result = wasm.Schematic_from_schematic(diplomatReceive.buffer, dataSlice.ptr);
|
|
293
|
+
|
|
294
|
+
try {
|
|
295
|
+
if (!diplomatReceive.resultFlag) {
|
|
296
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
297
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
298
|
+
}
|
|
299
|
+
return new Schematic(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
finally {
|
|
303
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
304
|
+
functionCleanupArena.free();
|
|
305
|
+
|
|
306
|
+
diplomatReceive.free();
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* The schematic as classic `.schematic` bytes, base64-encoded.
|
|
312
|
+
*/
|
|
313
|
+
toSchematicB64() {
|
|
314
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
315
|
+
|
|
316
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
const result = wasm.Schematic_to_schematic_b64(diplomatReceive.buffer, this.ffiValue, write.buffer);
|
|
320
|
+
|
|
321
|
+
try {
|
|
322
|
+
if (!diplomatReceive.resultFlag) {
|
|
323
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
324
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
325
|
+
}
|
|
326
|
+
return write.readString8();
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
finally {
|
|
330
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
331
|
+
diplomatReceive.free();
|
|
332
|
+
write.free();
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Build a schematic from snapshot (fast binary) data.
|
|
338
|
+
*/
|
|
339
|
+
static fromSnapshot(data) {
|
|
340
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
341
|
+
|
|
342
|
+
const dataSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.slice(wasm, data, "u8")));
|
|
343
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
const result = wasm.Schematic_from_snapshot(diplomatReceive.buffer, dataSlice.ptr);
|
|
347
|
+
|
|
348
|
+
try {
|
|
349
|
+
if (!diplomatReceive.resultFlag) {
|
|
350
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
351
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
352
|
+
}
|
|
353
|
+
return new Schematic(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
finally {
|
|
357
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
358
|
+
functionCleanupArena.free();
|
|
359
|
+
|
|
360
|
+
diplomatReceive.free();
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* The schematic as snapshot (fast binary) bytes, base64-encoded.
|
|
366
|
+
*/
|
|
367
|
+
toSnapshotB64() {
|
|
368
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
369
|
+
|
|
370
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
const result = wasm.Schematic_to_snapshot_b64(diplomatReceive.buffer, this.ffiValue, write.buffer);
|
|
374
|
+
|
|
375
|
+
try {
|
|
376
|
+
if (!diplomatReceive.resultFlag) {
|
|
377
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
378
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
379
|
+
}
|
|
380
|
+
return write.readString8();
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
finally {
|
|
384
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
385
|
+
diplomatReceive.free();
|
|
386
|
+
write.free();
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Build a schematic from McStructure (Bedrock) data.
|
|
392
|
+
*/
|
|
393
|
+
static fromMcstructure(data) {
|
|
394
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
395
|
+
|
|
396
|
+
const dataSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.slice(wasm, data, "u8")));
|
|
397
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
const result = wasm.Schematic_from_mcstructure(diplomatReceive.buffer, dataSlice.ptr);
|
|
401
|
+
|
|
402
|
+
try {
|
|
403
|
+
if (!diplomatReceive.resultFlag) {
|
|
404
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
405
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
406
|
+
}
|
|
407
|
+
return new Schematic(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
finally {
|
|
411
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
412
|
+
functionCleanupArena.free();
|
|
413
|
+
|
|
414
|
+
diplomatReceive.free();
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* The schematic as McStructure (Bedrock) bytes, base64-encoded.
|
|
420
|
+
*/
|
|
421
|
+
toMcstructureB64() {
|
|
422
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
423
|
+
|
|
424
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
const result = wasm.Schematic_to_mcstructure_b64(diplomatReceive.buffer, this.ffiValue, write.buffer);
|
|
428
|
+
|
|
429
|
+
try {
|
|
430
|
+
if (!diplomatReceive.resultFlag) {
|
|
431
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
432
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
433
|
+
}
|
|
434
|
+
return write.readString8();
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
finally {
|
|
438
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
439
|
+
diplomatReceive.free();
|
|
440
|
+
write.free();
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Import from a single MCA region file.
|
|
446
|
+
*/
|
|
447
|
+
static fromMca(data) {
|
|
448
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
449
|
+
|
|
450
|
+
const dataSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.slice(wasm, data, "u8")));
|
|
451
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
452
|
+
|
|
453
|
+
|
|
454
|
+
const result = wasm.Schematic_from_mca(diplomatReceive.buffer, dataSlice.ptr);
|
|
455
|
+
|
|
456
|
+
try {
|
|
457
|
+
if (!diplomatReceive.resultFlag) {
|
|
458
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
459
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
460
|
+
}
|
|
461
|
+
return new Schematic(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
finally {
|
|
465
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
466
|
+
functionCleanupArena.free();
|
|
467
|
+
|
|
468
|
+
diplomatReceive.free();
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* Import from MCA with coordinate bounds.
|
|
474
|
+
*/
|
|
475
|
+
static fromMcaBounded(data, minX, minY, minZ, maxX, maxY, maxZ) {
|
|
476
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
477
|
+
|
|
478
|
+
const dataSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.slice(wasm, data, "u8")));
|
|
479
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
const result = wasm.Schematic_from_mca_bounded(diplomatReceive.buffer, dataSlice.ptr, minX, minY, minZ, maxX, maxY, maxZ);
|
|
483
|
+
|
|
484
|
+
try {
|
|
485
|
+
if (!diplomatReceive.resultFlag) {
|
|
486
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
487
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
488
|
+
}
|
|
489
|
+
return new Schematic(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
finally {
|
|
493
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
494
|
+
functionCleanupArena.free();
|
|
495
|
+
|
|
496
|
+
diplomatReceive.free();
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* Import from a zipped world folder.
|
|
502
|
+
*/
|
|
503
|
+
static fromWorldZip(data) {
|
|
504
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
505
|
+
|
|
506
|
+
const dataSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.slice(wasm, data, "u8")));
|
|
507
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
const result = wasm.Schematic_from_world_zip(diplomatReceive.buffer, dataSlice.ptr);
|
|
511
|
+
|
|
512
|
+
try {
|
|
513
|
+
if (!diplomatReceive.resultFlag) {
|
|
514
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
515
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
516
|
+
}
|
|
517
|
+
return new Schematic(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
finally {
|
|
521
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
522
|
+
functionCleanupArena.free();
|
|
523
|
+
|
|
524
|
+
diplomatReceive.free();
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* Import from zipped world with coordinate bounds.
|
|
530
|
+
*/
|
|
531
|
+
static fromWorldZipBounded(data, minX, minY, minZ, maxX, maxY, maxZ) {
|
|
532
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
533
|
+
|
|
534
|
+
const dataSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.slice(wasm, data, "u8")));
|
|
535
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
const result = wasm.Schematic_from_world_zip_bounded(diplomatReceive.buffer, dataSlice.ptr, minX, minY, minZ, maxX, maxY, maxZ);
|
|
539
|
+
|
|
540
|
+
try {
|
|
541
|
+
if (!diplomatReceive.resultFlag) {
|
|
542
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
543
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
544
|
+
}
|
|
545
|
+
return new Schematic(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
finally {
|
|
549
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
550
|
+
functionCleanupArena.free();
|
|
551
|
+
|
|
552
|
+
diplomatReceive.free();
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* Import from a Minecraft world directory path.
|
|
558
|
+
*/
|
|
559
|
+
static fromWorldDirectory(path) {
|
|
560
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
561
|
+
|
|
562
|
+
const pathSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, path)));
|
|
563
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
564
|
+
|
|
565
|
+
|
|
566
|
+
const result = wasm.Schematic_from_world_directory(diplomatReceive.buffer, pathSlice.ptr);
|
|
567
|
+
|
|
568
|
+
try {
|
|
569
|
+
if (!diplomatReceive.resultFlag) {
|
|
570
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
571
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
572
|
+
}
|
|
573
|
+
return new Schematic(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
finally {
|
|
577
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
578
|
+
functionCleanupArena.free();
|
|
579
|
+
|
|
580
|
+
diplomatReceive.free();
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* Import from world directory with coordinate bounds.
|
|
586
|
+
*/
|
|
587
|
+
static fromWorldDirectoryBounded(path, minX, minY, minZ, maxX, maxY, maxZ) {
|
|
588
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
589
|
+
|
|
590
|
+
const pathSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, path)));
|
|
591
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
592
|
+
|
|
593
|
+
|
|
594
|
+
const result = wasm.Schematic_from_world_directory_bounded(diplomatReceive.buffer, pathSlice.ptr, minX, minY, minZ, maxX, maxY, maxZ);
|
|
595
|
+
|
|
596
|
+
try {
|
|
597
|
+
if (!diplomatReceive.resultFlag) {
|
|
598
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
599
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
600
|
+
}
|
|
601
|
+
return new Schematic(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
finally {
|
|
605
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
606
|
+
functionCleanupArena.free();
|
|
607
|
+
|
|
608
|
+
diplomatReceive.free();
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
/**
|
|
613
|
+
* Export the schematic as a Minecraft world: a JSON array of
|
|
614
|
+
* `{"path": <relative file path>, "data_b64": <base64 bytes>}` entries
|
|
615
|
+
* (the old `CFileMap`). `options_json` may be empty for defaults.
|
|
616
|
+
*/
|
|
617
|
+
toWorldJson(optionsJson) {
|
|
618
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
619
|
+
|
|
620
|
+
const optionsJsonSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, optionsJson)));
|
|
621
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
622
|
+
|
|
623
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
624
|
+
|
|
625
|
+
|
|
626
|
+
const result = wasm.Schematic_to_world_json(diplomatReceive.buffer, this.ffiValue, optionsJsonSlice.ptr, write.buffer);
|
|
627
|
+
|
|
628
|
+
try {
|
|
629
|
+
if (!diplomatReceive.resultFlag) {
|
|
630
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
631
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
632
|
+
}
|
|
633
|
+
return write.readString8();
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
finally {
|
|
637
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
638
|
+
functionCleanupArena.free();
|
|
639
|
+
|
|
640
|
+
diplomatReceive.free();
|
|
641
|
+
write.free();
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* Export and write world files to a directory. `options_json` may be empty.
|
|
647
|
+
*/
|
|
648
|
+
saveWorld(directory, optionsJson) {
|
|
649
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
650
|
+
|
|
651
|
+
const directorySlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, directory)));
|
|
652
|
+
const optionsJsonSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, optionsJson)));
|
|
653
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
654
|
+
|
|
655
|
+
|
|
656
|
+
const result = wasm.Schematic_save_world(diplomatReceive.buffer, this.ffiValue, directorySlice.ptr, optionsJsonSlice.ptr);
|
|
657
|
+
|
|
658
|
+
try {
|
|
659
|
+
if (!diplomatReceive.resultFlag) {
|
|
660
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
661
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
finally {
|
|
666
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
667
|
+
functionCleanupArena.free();
|
|
668
|
+
|
|
669
|
+
diplomatReceive.free();
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
/**
|
|
674
|
+
* Export the schematic as a zipped Minecraft world, base64-encoded.
|
|
675
|
+
* `options_json` may be empty for defaults.
|
|
676
|
+
*/
|
|
677
|
+
toWorldZipB64(optionsJson) {
|
|
678
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
679
|
+
|
|
680
|
+
const optionsJsonSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, optionsJson)));
|
|
681
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
682
|
+
|
|
683
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
const result = wasm.Schematic_to_world_zip_b64(diplomatReceive.buffer, this.ffiValue, optionsJsonSlice.ptr, write.buffer);
|
|
687
|
+
|
|
688
|
+
try {
|
|
689
|
+
if (!diplomatReceive.resultFlag) {
|
|
690
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
691
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
692
|
+
}
|
|
693
|
+
return write.readString8();
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
finally {
|
|
697
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
698
|
+
functionCleanupArena.free();
|
|
699
|
+
|
|
700
|
+
diplomatReceive.free();
|
|
701
|
+
write.free();
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
/**
|
|
706
|
+
* Set a block with properties given as a JSON object of string→string
|
|
707
|
+
* (the old `CProperty` array).
|
|
708
|
+
*/
|
|
709
|
+
setBlockWithProperties(x, y, z, blockName, propertiesJson) {
|
|
710
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
711
|
+
|
|
712
|
+
const blockNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, blockName)));
|
|
713
|
+
const propertiesJsonSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, propertiesJson)));
|
|
714
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
715
|
+
|
|
716
|
+
|
|
717
|
+
const result = wasm.Schematic_set_block_with_properties(diplomatReceive.buffer, this.ffiValue, x, y, z, blockNameSlice.ptr, propertiesJsonSlice.ptr);
|
|
718
|
+
|
|
719
|
+
try {
|
|
720
|
+
if (!diplomatReceive.resultFlag) {
|
|
721
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
722
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
finally {
|
|
727
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
728
|
+
functionCleanupArena.free();
|
|
729
|
+
|
|
730
|
+
diplomatReceive.free();
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
/**
|
|
735
|
+
* Set a block from a full block string, e.g.
|
|
736
|
+
* `minecraft:chest[facing=north]{Items:[...]}`.
|
|
737
|
+
*/
|
|
738
|
+
setBlockFromString(x, y, z, blockString) {
|
|
739
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
740
|
+
|
|
741
|
+
const blockStringSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, blockString)));
|
|
742
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
743
|
+
|
|
744
|
+
|
|
745
|
+
const result = wasm.Schematic_set_block_from_string(diplomatReceive.buffer, this.ffiValue, x, y, z, blockStringSlice.ptr);
|
|
746
|
+
|
|
747
|
+
try {
|
|
748
|
+
if (!diplomatReceive.resultFlag) {
|
|
749
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
750
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
finally {
|
|
755
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
756
|
+
functionCleanupArena.free();
|
|
757
|
+
|
|
758
|
+
diplomatReceive.free();
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
/**
|
|
763
|
+
* Pre-resolve a plain block name to a palette index for use with `place`.
|
|
764
|
+
* Pair them in hot loops with many unique block names to skip the per-call
|
|
765
|
+
* name → palette lookup.
|
|
766
|
+
*/
|
|
767
|
+
prepareBlock(blockName) {
|
|
768
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
769
|
+
|
|
770
|
+
const blockNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, blockName)));
|
|
771
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
772
|
+
|
|
773
|
+
|
|
774
|
+
const result = wasm.Schematic_prepare_block(diplomatReceive.buffer, this.ffiValue, blockNameSlice.ptr);
|
|
775
|
+
|
|
776
|
+
try {
|
|
777
|
+
if (!diplomatReceive.resultFlag) {
|
|
778
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
779
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
780
|
+
}
|
|
781
|
+
return (new Int32Array(wasm.memory.buffer, diplomatReceive.buffer, 1))[0];
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
finally {
|
|
785
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
786
|
+
functionCleanupArena.free();
|
|
787
|
+
|
|
788
|
+
diplomatReceive.free();
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
/**
|
|
793
|
+
* Place a block by pre-resolved palette index (from `prepare_block`).
|
|
794
|
+
*/
|
|
795
|
+
place(x, y, z, paletteIndex) {
|
|
796
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
797
|
+
|
|
798
|
+
|
|
799
|
+
const result = wasm.Schematic_place(diplomatReceive.buffer, this.ffiValue, x, y, z, paletteIndex);
|
|
800
|
+
|
|
801
|
+
try {
|
|
802
|
+
if (!diplomatReceive.resultFlag) {
|
|
803
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
804
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
finally {
|
|
809
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
810
|
+
diplomatReceive.free();
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
/**
|
|
815
|
+
* Batch-set blocks at multiple positions to the same block (name, block
|
|
816
|
+
* string with properties, or block string with NBT). `positions` is flat
|
|
817
|
+
* `[x0,y0,z0, x1,y1,z1, ...]` (length must be a multiple of 3).
|
|
818
|
+
* Returns the number of blocks set.
|
|
819
|
+
*/
|
|
820
|
+
setBlocks(positions, blockName) {
|
|
821
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
822
|
+
|
|
823
|
+
const positionsSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.slice(wasm, positions, "i32")));
|
|
824
|
+
const blockNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, blockName)));
|
|
825
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
const result = wasm.Schematic_set_blocks(diplomatReceive.buffer, this.ffiValue, positionsSlice.ptr, blockNameSlice.ptr);
|
|
829
|
+
|
|
830
|
+
try {
|
|
831
|
+
if (!diplomatReceive.resultFlag) {
|
|
832
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
833
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
834
|
+
}
|
|
835
|
+
return (new Int32Array(wasm.memory.buffer, diplomatReceive.buffer, 1))[0];
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
finally {
|
|
839
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
840
|
+
functionCleanupArena.free();
|
|
841
|
+
|
|
842
|
+
diplomatReceive.free();
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
/**
|
|
847
|
+
* Batch-get block names at multiple positions. `positions` is flat
|
|
848
|
+
* `[x0,y0,z0, ...]` (length must be a multiple of 3). Writes a JSON array,
|
|
849
|
+
* one entry per position: the block name string, or `null` for
|
|
850
|
+
* empty/out-of-bounds positions.
|
|
851
|
+
*/
|
|
852
|
+
getBlocksJson(positions) {
|
|
853
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
854
|
+
|
|
855
|
+
const positionsSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.slice(wasm, positions, "i32")));
|
|
856
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
857
|
+
|
|
858
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
859
|
+
|
|
860
|
+
|
|
861
|
+
const result = wasm.Schematic_get_blocks_json(diplomatReceive.buffer, this.ffiValue, positionsSlice.ptr, write.buffer);
|
|
862
|
+
|
|
863
|
+
try {
|
|
864
|
+
if (!diplomatReceive.resultFlag) {
|
|
865
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
866
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
867
|
+
}
|
|
868
|
+
return write.readString8();
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
finally {
|
|
872
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
873
|
+
functionCleanupArena.free();
|
|
874
|
+
|
|
875
|
+
diplomatReceive.free();
|
|
876
|
+
write.free();
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
/**
|
|
881
|
+
* Copy a region from `source` into this schematic. `excluded_blocks_json`
|
|
882
|
+
* is a JSON array of block strings to skip (empty string or `[]` for none).
|
|
883
|
+
*/
|
|
884
|
+
copyRegion(source, minX, minY, minZ, maxX, maxY, maxZ, targetX, targetY, targetZ, excludedBlocksJson) {
|
|
885
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
886
|
+
|
|
887
|
+
const excludedBlocksJsonSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, excludedBlocksJson)));
|
|
888
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
889
|
+
|
|
890
|
+
|
|
891
|
+
const result = wasm.Schematic_copy_region(diplomatReceive.buffer, this.ffiValue, source.ffiValue, minX, minY, minZ, maxX, maxY, maxZ, targetX, targetY, targetZ, excludedBlocksJsonSlice.ptr);
|
|
892
|
+
|
|
893
|
+
try {
|
|
894
|
+
if (!diplomatReceive.resultFlag) {
|
|
895
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
896
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
finally {
|
|
901
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
902
|
+
functionCleanupArena.free();
|
|
903
|
+
|
|
904
|
+
diplomatReceive.free();
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
/**
|
|
909
|
+
* The block at a position with its properties, as a `BlockState`.
|
|
910
|
+
*/
|
|
911
|
+
getBlockWithProperties(x, y, z) {
|
|
912
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
913
|
+
|
|
914
|
+
|
|
915
|
+
const result = wasm.Schematic_get_block_with_properties(diplomatReceive.buffer, this.ffiValue, x, y, z);
|
|
916
|
+
|
|
917
|
+
try {
|
|
918
|
+
if (!diplomatReceive.resultFlag) {
|
|
919
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
920
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
921
|
+
}
|
|
922
|
+
return new BlockState(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
finally {
|
|
926
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
927
|
+
diplomatReceive.free();
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
/**
|
|
932
|
+
* The full block string (name, properties, NBT) at a position.
|
|
933
|
+
*/
|
|
934
|
+
getBlockString(x, y, z) {
|
|
935
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
936
|
+
|
|
937
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
938
|
+
|
|
939
|
+
|
|
940
|
+
const result = wasm.Schematic_get_block_string(diplomatReceive.buffer, this.ffiValue, x, y, z, write.buffer);
|
|
941
|
+
|
|
942
|
+
try {
|
|
943
|
+
if (!diplomatReceive.resultFlag) {
|
|
944
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
945
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
946
|
+
}
|
|
947
|
+
return write.readString8();
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
finally {
|
|
951
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
952
|
+
diplomatReceive.free();
|
|
953
|
+
write.free();
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
/**
|
|
958
|
+
* The block entity at a position as JSON
|
|
959
|
+
* `{"id": ..., "position": [x,y,z], "nbt": {...}}` (the old `CBlockEntity`).
|
|
960
|
+
*/
|
|
961
|
+
getBlockEntityJson(x, y, z) {
|
|
962
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
963
|
+
|
|
964
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
965
|
+
|
|
966
|
+
|
|
967
|
+
const result = wasm.Schematic_get_block_entity_json(diplomatReceive.buffer, this.ffiValue, x, y, z, write.buffer);
|
|
968
|
+
|
|
969
|
+
try {
|
|
970
|
+
if (!diplomatReceive.resultFlag) {
|
|
971
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
972
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
973
|
+
}
|
|
974
|
+
return write.readString8();
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
finally {
|
|
978
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
979
|
+
diplomatReceive.free();
|
|
980
|
+
write.free();
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
/**
|
|
985
|
+
* Every block entity as a JSON array of
|
|
986
|
+
* `{"id": ..., "position": [x,y,z], "nbt": {...}}`.
|
|
987
|
+
*/
|
|
988
|
+
getAllBlockEntitiesJson() {
|
|
989
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
990
|
+
|
|
991
|
+
wasm.Schematic_get_all_block_entities_json(this.ffiValue, write.buffer);
|
|
992
|
+
|
|
993
|
+
try {
|
|
994
|
+
return write.readString8();
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
finally {
|
|
998
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
999
|
+
write.free();
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
/**
|
|
1004
|
+
* The number of mobile entities (not block entities).
|
|
1005
|
+
*/
|
|
1006
|
+
entityCount() {
|
|
1007
|
+
|
|
1008
|
+
const result = wasm.Schematic_entity_count(this.ffiValue);
|
|
1009
|
+
|
|
1010
|
+
try {
|
|
1011
|
+
return result;
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
finally {
|
|
1015
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
/**
|
|
1020
|
+
* Every mobile entity as a JSON array of
|
|
1021
|
+
* `{"id": ..., "position": [x,y,z], "nbt": {...}}` (the old `CEntityArray`).
|
|
1022
|
+
*/
|
|
1023
|
+
getEntitiesJson() {
|
|
1024
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
1025
|
+
|
|
1026
|
+
wasm.Schematic_get_entities_json(this.ffiValue, write.buffer);
|
|
1027
|
+
|
|
1028
|
+
try {
|
|
1029
|
+
return write.readString8();
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
finally {
|
|
1033
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1034
|
+
write.free();
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
/**
|
|
1039
|
+
* Add a mobile entity. `nbt_json` is a JSON object (may be empty).
|
|
1040
|
+
*/
|
|
1041
|
+
addEntity(id, x, y, z, nbtJson) {
|
|
1042
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
1043
|
+
|
|
1044
|
+
const idSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, id)));
|
|
1045
|
+
const nbtJsonSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, nbtJson)));
|
|
1046
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
1047
|
+
|
|
1048
|
+
|
|
1049
|
+
const result = wasm.Schematic_add_entity(diplomatReceive.buffer, this.ffiValue, idSlice.ptr, x, y, z, nbtJsonSlice.ptr);
|
|
1050
|
+
|
|
1051
|
+
try {
|
|
1052
|
+
if (!diplomatReceive.resultFlag) {
|
|
1053
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
1054
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
finally {
|
|
1059
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1060
|
+
functionCleanupArena.free();
|
|
1061
|
+
|
|
1062
|
+
diplomatReceive.free();
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
/**
|
|
1067
|
+
* Remove a mobile entity by index.
|
|
1068
|
+
*/
|
|
1069
|
+
removeEntity(index) {
|
|
1070
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
1071
|
+
|
|
1072
|
+
|
|
1073
|
+
const result = wasm.Schematic_remove_entity(diplomatReceive.buffer, this.ffiValue, index);
|
|
1074
|
+
|
|
1075
|
+
try {
|
|
1076
|
+
if (!diplomatReceive.resultFlag) {
|
|
1077
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
1078
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
finally {
|
|
1083
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1084
|
+
diplomatReceive.free();
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
/**
|
|
1089
|
+
* The canonical in-memory data version (the forward-conversion target).
|
|
1090
|
+
*/
|
|
1091
|
+
static canonicalDataVersion() {
|
|
1092
|
+
|
|
1093
|
+
const result = wasm.Schematic_canonical_data_version();
|
|
1094
|
+
|
|
1095
|
+
try {
|
|
1096
|
+
return result;
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
finally {
|
|
1100
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
/**
|
|
1105
|
+
* Convert block/item/entity data between Minecraft data versions. Forward
|
|
1106
|
+
* (`target >= source`) is lossless; reverse is lossy. Writes a JSON loss
|
|
1107
|
+
* report (`[]` when lossless).
|
|
1108
|
+
*/
|
|
1109
|
+
convertToDataVersion(targetDataVersion, sourceDataVersion) {
|
|
1110
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
1111
|
+
|
|
1112
|
+
wasm.Schematic_convert_to_data_version(this.ffiValue, targetDataVersion, sourceDataVersion, write.buffer);
|
|
1113
|
+
|
|
1114
|
+
try {
|
|
1115
|
+
return write.readString8();
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
finally {
|
|
1119
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1120
|
+
write.free();
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
/**
|
|
1125
|
+
* Convert to `target_data_version` using the schematic's captured source
|
|
1126
|
+
* version (else `mc_version`, else canonical) as origin, updating metadata
|
|
1127
|
+
* to the target. Writes a JSON loss report (`[]` when lossless).
|
|
1128
|
+
*/
|
|
1129
|
+
convertToVersion(targetDataVersion) {
|
|
1130
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
1131
|
+
|
|
1132
|
+
wasm.Schematic_convert_to_version(this.ffiValue, targetDataVersion, write.buffer);
|
|
1133
|
+
|
|
1134
|
+
try {
|
|
1135
|
+
return write.readString8();
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
finally {
|
|
1139
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1140
|
+
write.free();
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
/**
|
|
1145
|
+
* The Minecraft data version of the file this schematic was loaded from, or
|
|
1146
|
+
* `-1` if none was captured (versionless / freshly built).
|
|
1147
|
+
*/
|
|
1148
|
+
sourceDataVersion() {
|
|
1149
|
+
|
|
1150
|
+
const result = wasm.Schematic_source_data_version(this.ffiValue);
|
|
1151
|
+
|
|
1152
|
+
try {
|
|
1153
|
+
return result;
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
finally {
|
|
1157
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
/**
|
|
1162
|
+
* Override the source data version for formats that carry no Java data
|
|
1163
|
+
* version, so the converter knows what to convert *from*.
|
|
1164
|
+
*/
|
|
1165
|
+
setSourceDataVersion(version) {
|
|
1166
|
+
wasm.Schematic_set_source_data_version(this.ffiValue, version);
|
|
1167
|
+
|
|
1168
|
+
try {}
|
|
1169
|
+
|
|
1170
|
+
finally {
|
|
1171
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
/**
|
|
1176
|
+
* Serialize a `.litematic` targeting a specific Minecraft data version. A
|
|
1177
|
+
* COPY is converted and the matching Version header written; the schematic
|
|
1178
|
+
* is left unchanged. Writes JSON
|
|
1179
|
+
* `{"data_b64": <base64 .litematic>, "loss": <loss report>}`.
|
|
1180
|
+
*/
|
|
1181
|
+
toLitematicForVersionJson(targetDataVersion) {
|
|
1182
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
1183
|
+
|
|
1184
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
1185
|
+
|
|
1186
|
+
|
|
1187
|
+
const result = wasm.Schematic_to_litematic_for_version_json(diplomatReceive.buffer, this.ffiValue, targetDataVersion, write.buffer);
|
|
1188
|
+
|
|
1189
|
+
try {
|
|
1190
|
+
if (!diplomatReceive.resultFlag) {
|
|
1191
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
1192
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
1193
|
+
}
|
|
1194
|
+
return write.readString8();
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
finally {
|
|
1198
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1199
|
+
diplomatReceive.free();
|
|
1200
|
+
write.free();
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
/**
|
|
1205
|
+
* The block entity's NBT as a typed SNBT string. Round-trips losslessly.
|
|
1206
|
+
*/
|
|
1207
|
+
getBlockEntitySnbt(x, y, z) {
|
|
1208
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
1209
|
+
|
|
1210
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
1211
|
+
|
|
1212
|
+
|
|
1213
|
+
const result = wasm.Schematic_get_block_entity_snbt(diplomatReceive.buffer, this.ffiValue, x, y, z, write.buffer);
|
|
1214
|
+
|
|
1215
|
+
try {
|
|
1216
|
+
if (!diplomatReceive.resultFlag) {
|
|
1217
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
1218
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
1219
|
+
}
|
|
1220
|
+
return write.readString8();
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
finally {
|
|
1224
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1225
|
+
diplomatReceive.free();
|
|
1226
|
+
write.free();
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
/**
|
|
1231
|
+
* Set (or replace) a block entity at a position from a typed SNBT string.
|
|
1232
|
+
*/
|
|
1233
|
+
setBlockEntity(x, y, z, id, snbt) {
|
|
1234
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
1235
|
+
|
|
1236
|
+
const idSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, id)));
|
|
1237
|
+
const snbtSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, snbt)));
|
|
1238
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
1239
|
+
|
|
1240
|
+
|
|
1241
|
+
const result = wasm.Schematic_set_block_entity(diplomatReceive.buffer, this.ffiValue, x, y, z, idSlice.ptr, snbtSlice.ptr);
|
|
1242
|
+
|
|
1243
|
+
try {
|
|
1244
|
+
if (!diplomatReceive.resultFlag) {
|
|
1245
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
1246
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
finally {
|
|
1251
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1252
|
+
functionCleanupArena.free();
|
|
1253
|
+
|
|
1254
|
+
diplomatReceive.free();
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
/**
|
|
1259
|
+
* Remove the block entity at a position. `NotFound` if none was there.
|
|
1260
|
+
*/
|
|
1261
|
+
removeBlockEntity(x, y, z) {
|
|
1262
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
1263
|
+
|
|
1264
|
+
|
|
1265
|
+
const result = wasm.Schematic_remove_block_entity(diplomatReceive.buffer, this.ffiValue, x, y, z);
|
|
1266
|
+
|
|
1267
|
+
try {
|
|
1268
|
+
if (!diplomatReceive.resultFlag) {
|
|
1269
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
1270
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
finally {
|
|
1275
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1276
|
+
diplomatReceive.free();
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
/**
|
|
1281
|
+
* Every block entity as a JSON array of `{id, position: [x,y,z], snbt}`.
|
|
1282
|
+
* The `snbt` is the inner data only (no `Id`/`Pos`).
|
|
1283
|
+
*/
|
|
1284
|
+
getAllBlockEntitiesSnbtJson() {
|
|
1285
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
1286
|
+
|
|
1287
|
+
wasm.Schematic_get_all_block_entities_snbt_json(this.ffiValue, write.buffer);
|
|
1288
|
+
|
|
1289
|
+
try {
|
|
1290
|
+
return write.readString8();
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
finally {
|
|
1294
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1295
|
+
write.free();
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
/**
|
|
1300
|
+
* Every mobile entity as a JSON array of typed SNBT strings (full compound
|
|
1301
|
+
* incl. `id`/`Pos`).
|
|
1302
|
+
*/
|
|
1303
|
+
getEntitiesSnbtJson() {
|
|
1304
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
1305
|
+
|
|
1306
|
+
wasm.Schematic_get_entities_snbt_json(this.ffiValue, write.buffer);
|
|
1307
|
+
|
|
1308
|
+
try {
|
|
1309
|
+
return write.readString8();
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
finally {
|
|
1313
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1314
|
+
write.free();
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1318
|
+
/**
|
|
1319
|
+
* Add a mobile entity from a full SNBT entity compound (must contain `id`
|
|
1320
|
+
* and `Pos`).
|
|
1321
|
+
*/
|
|
1322
|
+
addEntityFromSnbt(snbt) {
|
|
1323
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
1324
|
+
|
|
1325
|
+
const snbtSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, snbt)));
|
|
1326
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
1327
|
+
|
|
1328
|
+
|
|
1329
|
+
const result = wasm.Schematic_add_entity_from_snbt(diplomatReceive.buffer, this.ffiValue, snbtSlice.ptr);
|
|
1330
|
+
|
|
1331
|
+
try {
|
|
1332
|
+
if (!diplomatReceive.resultFlag) {
|
|
1333
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
1334
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
finally {
|
|
1339
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1340
|
+
functionCleanupArena.free();
|
|
1341
|
+
|
|
1342
|
+
diplomatReceive.free();
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
/**
|
|
1347
|
+
* Every non-air block as a JSON array of
|
|
1348
|
+
* `{"x", "y", "z", "name", "properties"}` (the old `CBlockArray`).
|
|
1349
|
+
*/
|
|
1350
|
+
getAllBlocksJson() {
|
|
1351
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
1352
|
+
|
|
1353
|
+
wasm.Schematic_get_all_blocks_json(this.ffiValue, write.buffer);
|
|
1354
|
+
|
|
1355
|
+
try {
|
|
1356
|
+
return write.readString8();
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
finally {
|
|
1360
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1361
|
+
write.free();
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
/**
|
|
1366
|
+
* All blocks within a sub-region (chunk) of the schematic, as the same
|
|
1367
|
+
* JSON array shape as `get_all_blocks_json`.
|
|
1368
|
+
*/
|
|
1369
|
+
getChunkBlocksJson(offsetX, offsetY, offsetZ, width, height, length) {
|
|
1370
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
1371
|
+
|
|
1372
|
+
wasm.Schematic_get_chunk_blocks_json(this.ffiValue, offsetX, offsetY, offsetZ, width, height, length, write.buffer);
|
|
1373
|
+
|
|
1374
|
+
try {
|
|
1375
|
+
return write.readString8();
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
finally {
|
|
1379
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1380
|
+
write.free();
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
/**
|
|
1385
|
+
* Split the schematic into chunks (default bottom-up strategy). Writes a
|
|
1386
|
+
* JSON array of `{"chunk_x", "chunk_y", "chunk_z", "blocks": [...]}` where
|
|
1387
|
+
* blocks have the `get_all_blocks_json` shape (the old `CChunkArray`).
|
|
1388
|
+
*/
|
|
1389
|
+
getChunksJson(chunkWidth, chunkHeight, chunkLength) {
|
|
1390
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
1391
|
+
|
|
1392
|
+
wasm.Schematic_get_chunks_json(this.ffiValue, chunkWidth, chunkHeight, chunkLength, write.buffer);
|
|
1393
|
+
|
|
1394
|
+
try {
|
|
1395
|
+
return write.readString8();
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
finally {
|
|
1399
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1400
|
+
write.free();
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1404
|
+
/**
|
|
1405
|
+
* Split the schematic into chunks with a loading strategy: one of
|
|
1406
|
+
* `distance_to_camera`, `top_down`, `bottom_up`, `center_outward`,
|
|
1407
|
+
* `random` (anything else falls back to `bottom_up`). Camera coordinates
|
|
1408
|
+
* are only used by `distance_to_camera`. Same JSON shape as
|
|
1409
|
+
* `get_chunks_json`.
|
|
1410
|
+
*/
|
|
1411
|
+
getChunksWithStrategyJson(chunkWidth, chunkHeight, chunkLength, strategy, cameraX, cameraY, cameraZ) {
|
|
1412
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
1413
|
+
|
|
1414
|
+
const strategySlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, strategy)));
|
|
1415
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
1416
|
+
|
|
1417
|
+
wasm.Schematic_get_chunks_with_strategy_json(this.ffiValue, chunkWidth, chunkHeight, chunkLength, strategySlice.ptr, cameraX, cameraY, cameraZ, write.buffer);
|
|
1418
|
+
|
|
1419
|
+
try {
|
|
1420
|
+
return write.readString8();
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
finally {
|
|
1424
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1425
|
+
functionCleanupArena.free();
|
|
1426
|
+
|
|
1427
|
+
write.free();
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
/**
|
|
1432
|
+
* The total number of non-air blocks in the schematic.
|
|
1433
|
+
*/
|
|
1434
|
+
blockCount() {
|
|
1435
|
+
|
|
1436
|
+
const result = wasm.Schematic_block_count(this.ffiValue);
|
|
1437
|
+
|
|
1438
|
+
try {
|
|
1439
|
+
return result;
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
finally {
|
|
1443
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
/**
|
|
1448
|
+
* The total volume of the schematic's bounding box.
|
|
1449
|
+
*/
|
|
1450
|
+
volume() {
|
|
1451
|
+
|
|
1452
|
+
const result = wasm.Schematic_volume(this.ffiValue);
|
|
1453
|
+
|
|
1454
|
+
try {
|
|
1455
|
+
return result;
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
finally {
|
|
1459
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1463
|
+
/**
|
|
1464
|
+
* The names of all regions, as a JSON array of strings.
|
|
1465
|
+
*/
|
|
1466
|
+
regionNamesJson() {
|
|
1467
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
1468
|
+
|
|
1469
|
+
wasm.Schematic_region_names_json(this.ffiValue, write.buffer);
|
|
1470
|
+
|
|
1471
|
+
try {
|
|
1472
|
+
return write.readString8();
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1475
|
+
finally {
|
|
1476
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1477
|
+
write.free();
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
/**
|
|
1482
|
+
* Basic debug info about the schematic (name + region count).
|
|
1483
|
+
*/
|
|
1484
|
+
debugInfo() {
|
|
1485
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
1486
|
+
|
|
1487
|
+
wasm.Schematic_debug_info(this.ffiValue, write.buffer);
|
|
1488
|
+
|
|
1489
|
+
try {
|
|
1490
|
+
return write.readString8();
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
finally {
|
|
1494
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1495
|
+
write.free();
|
|
1496
|
+
}
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
/**
|
|
1500
|
+
* A formatted schematic layout string (old `schematic_print`).
|
|
1501
|
+
*/
|
|
1502
|
+
printString() {
|
|
1503
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
1504
|
+
|
|
1505
|
+
wasm.Schematic_print_string(this.ffiValue, write.buffer);
|
|
1506
|
+
|
|
1507
|
+
try {
|
|
1508
|
+
return write.readString8();
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
finally {
|
|
1512
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1513
|
+
write.free();
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1517
|
+
/**
|
|
1518
|
+
* A formatted schematic layout string (old `schematic_print_schematic`;
|
|
1519
|
+
* same output as `print_string`).
|
|
1520
|
+
*/
|
|
1521
|
+
printSchematicString() {
|
|
1522
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
1523
|
+
|
|
1524
|
+
wasm.Schematic_print_schematic_string(this.ffiValue, write.buffer);
|
|
1525
|
+
|
|
1526
|
+
try {
|
|
1527
|
+
return write.readString8();
|
|
1528
|
+
}
|
|
1529
|
+
|
|
1530
|
+
finally {
|
|
1531
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1532
|
+
write.free();
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
/**
|
|
1537
|
+
* A detailed debug string, including a visual layout (old `debug_schematic`).
|
|
1538
|
+
*/
|
|
1539
|
+
debugString() {
|
|
1540
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
1541
|
+
|
|
1542
|
+
wasm.Schematic_debug_string(this.ffiValue, write.buffer);
|
|
1543
|
+
|
|
1544
|
+
try {
|
|
1545
|
+
return write.readString8();
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1548
|
+
finally {
|
|
1549
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1550
|
+
write.free();
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
/**
|
|
1555
|
+
* A detailed debug string with a JSON layout (old `debug_json_schematic`).
|
|
1556
|
+
*/
|
|
1557
|
+
debugJsonString() {
|
|
1558
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
1559
|
+
|
|
1560
|
+
wasm.Schematic_debug_json_string(this.ffiValue, write.buffer);
|
|
1561
|
+
|
|
1562
|
+
try {
|
|
1563
|
+
return write.readString8();
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
finally {
|
|
1567
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1568
|
+
write.free();
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
|
|
1572
|
+
/**
|
|
1573
|
+
* The schematic name. `NotFound` if not set.
|
|
1574
|
+
*/
|
|
1575
|
+
name() {
|
|
1576
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
1577
|
+
|
|
1578
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
1579
|
+
|
|
1580
|
+
|
|
1581
|
+
const result = wasm.Schematic_name(diplomatReceive.buffer, this.ffiValue, write.buffer);
|
|
1582
|
+
|
|
1583
|
+
try {
|
|
1584
|
+
if (!diplomatReceive.resultFlag) {
|
|
1585
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
1586
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
1587
|
+
}
|
|
1588
|
+
return write.readString8();
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
finally {
|
|
1592
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1593
|
+
diplomatReceive.free();
|
|
1594
|
+
write.free();
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
/**
|
|
1599
|
+
* Set the schematic name.
|
|
1600
|
+
*/
|
|
1601
|
+
setName(name) {
|
|
1602
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
1603
|
+
|
|
1604
|
+
const nameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, name)));
|
|
1605
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
1606
|
+
|
|
1607
|
+
|
|
1608
|
+
const result = wasm.Schematic_set_name(diplomatReceive.buffer, this.ffiValue, nameSlice.ptr);
|
|
1609
|
+
|
|
1610
|
+
try {
|
|
1611
|
+
if (!diplomatReceive.resultFlag) {
|
|
1612
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
1613
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
|
|
1617
|
+
finally {
|
|
1618
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1619
|
+
functionCleanupArena.free();
|
|
1620
|
+
|
|
1621
|
+
diplomatReceive.free();
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
|
|
1625
|
+
/**
|
|
1626
|
+
* The schematic author. `NotFound` if not set.
|
|
1627
|
+
*/
|
|
1628
|
+
author() {
|
|
1629
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
1630
|
+
|
|
1631
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
1632
|
+
|
|
1633
|
+
|
|
1634
|
+
const result = wasm.Schematic_author(diplomatReceive.buffer, this.ffiValue, write.buffer);
|
|
1635
|
+
|
|
1636
|
+
try {
|
|
1637
|
+
if (!diplomatReceive.resultFlag) {
|
|
1638
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
1639
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
1640
|
+
}
|
|
1641
|
+
return write.readString8();
|
|
1642
|
+
}
|
|
1643
|
+
|
|
1644
|
+
finally {
|
|
1645
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1646
|
+
diplomatReceive.free();
|
|
1647
|
+
write.free();
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
/**
|
|
1652
|
+
* Set the schematic author.
|
|
1653
|
+
*/
|
|
1654
|
+
setAuthor(author) {
|
|
1655
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
1656
|
+
|
|
1657
|
+
const authorSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, author)));
|
|
1658
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
1659
|
+
|
|
1660
|
+
|
|
1661
|
+
const result = wasm.Schematic_set_author(diplomatReceive.buffer, this.ffiValue, authorSlice.ptr);
|
|
1662
|
+
|
|
1663
|
+
try {
|
|
1664
|
+
if (!diplomatReceive.resultFlag) {
|
|
1665
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
1666
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
|
|
1670
|
+
finally {
|
|
1671
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1672
|
+
functionCleanupArena.free();
|
|
1673
|
+
|
|
1674
|
+
diplomatReceive.free();
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
/**
|
|
1679
|
+
* The schematic description. `NotFound` if not set.
|
|
1680
|
+
*/
|
|
1681
|
+
description() {
|
|
1682
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
1683
|
+
|
|
1684
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
1685
|
+
|
|
1686
|
+
|
|
1687
|
+
const result = wasm.Schematic_description(diplomatReceive.buffer, this.ffiValue, write.buffer);
|
|
1688
|
+
|
|
1689
|
+
try {
|
|
1690
|
+
if (!diplomatReceive.resultFlag) {
|
|
1691
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
1692
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
1693
|
+
}
|
|
1694
|
+
return write.readString8();
|
|
1695
|
+
}
|
|
1696
|
+
|
|
1697
|
+
finally {
|
|
1698
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1699
|
+
diplomatReceive.free();
|
|
1700
|
+
write.free();
|
|
1701
|
+
}
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
/**
|
|
1705
|
+
* Set the schematic description.
|
|
1706
|
+
*/
|
|
1707
|
+
setDescription(description) {
|
|
1708
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
1709
|
+
|
|
1710
|
+
const descriptionSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, description)));
|
|
1711
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
1712
|
+
|
|
1713
|
+
|
|
1714
|
+
const result = wasm.Schematic_set_description(diplomatReceive.buffer, this.ffiValue, descriptionSlice.ptr);
|
|
1715
|
+
|
|
1716
|
+
try {
|
|
1717
|
+
if (!diplomatReceive.resultFlag) {
|
|
1718
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
1719
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1723
|
+
finally {
|
|
1724
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1725
|
+
functionCleanupArena.free();
|
|
1726
|
+
|
|
1727
|
+
diplomatReceive.free();
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1731
|
+
/**
|
|
1732
|
+
* The creation timestamp (milliseconds since epoch), or `-1` if not set.
|
|
1733
|
+
*/
|
|
1734
|
+
created() {
|
|
1735
|
+
|
|
1736
|
+
const result = wasm.Schematic_created(this.ffiValue);
|
|
1737
|
+
|
|
1738
|
+
try {
|
|
1739
|
+
return result;
|
|
1740
|
+
}
|
|
1741
|
+
|
|
1742
|
+
finally {
|
|
1743
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1744
|
+
}
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
/**
|
|
1748
|
+
* Set the creation timestamp (milliseconds since epoch).
|
|
1749
|
+
*/
|
|
1750
|
+
setCreated(created) {
|
|
1751
|
+
wasm.Schematic_set_created(this.ffiValue, created);
|
|
1752
|
+
|
|
1753
|
+
try {}
|
|
1754
|
+
|
|
1755
|
+
finally {
|
|
1756
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
|
|
1760
|
+
/**
|
|
1761
|
+
* The modification timestamp (milliseconds since epoch), or `-1` if not set.
|
|
1762
|
+
*/
|
|
1763
|
+
modified() {
|
|
1764
|
+
|
|
1765
|
+
const result = wasm.Schematic_modified(this.ffiValue);
|
|
1766
|
+
|
|
1767
|
+
try {
|
|
1768
|
+
return result;
|
|
1769
|
+
}
|
|
1770
|
+
|
|
1771
|
+
finally {
|
|
1772
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
|
|
1776
|
+
/**
|
|
1777
|
+
* Set the modification timestamp (milliseconds since epoch).
|
|
1778
|
+
*/
|
|
1779
|
+
setModified(modified) {
|
|
1780
|
+
wasm.Schematic_set_modified(this.ffiValue, modified);
|
|
1781
|
+
|
|
1782
|
+
try {}
|
|
1783
|
+
|
|
1784
|
+
finally {
|
|
1785
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1788
|
+
|
|
1789
|
+
/**
|
|
1790
|
+
* The Litematic format version, or `-1` if not set.
|
|
1791
|
+
*/
|
|
1792
|
+
lmVersion() {
|
|
1793
|
+
|
|
1794
|
+
const result = wasm.Schematic_lm_version(this.ffiValue);
|
|
1795
|
+
|
|
1796
|
+
try {
|
|
1797
|
+
return result;
|
|
1798
|
+
}
|
|
1799
|
+
|
|
1800
|
+
finally {
|
|
1801
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
|
|
1805
|
+
/**
|
|
1806
|
+
* Set the Litematic format version.
|
|
1807
|
+
*/
|
|
1808
|
+
setLmVersion(version) {
|
|
1809
|
+
wasm.Schematic_set_lm_version(this.ffiValue, version);
|
|
1810
|
+
|
|
1811
|
+
try {}
|
|
1812
|
+
|
|
1813
|
+
finally {
|
|
1814
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1815
|
+
}
|
|
1816
|
+
}
|
|
1817
|
+
|
|
1818
|
+
/**
|
|
1819
|
+
* The Minecraft data version, or `-1` if not set.
|
|
1820
|
+
*/
|
|
1821
|
+
mcVersion() {
|
|
1822
|
+
|
|
1823
|
+
const result = wasm.Schematic_mc_version(this.ffiValue);
|
|
1824
|
+
|
|
1825
|
+
try {
|
|
1826
|
+
return result;
|
|
1827
|
+
}
|
|
1828
|
+
|
|
1829
|
+
finally {
|
|
1830
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
|
|
1834
|
+
/**
|
|
1835
|
+
* Set the Minecraft data version.
|
|
1836
|
+
*/
|
|
1837
|
+
setMcVersion(version) {
|
|
1838
|
+
wasm.Schematic_set_mc_version(this.ffiValue, version);
|
|
1839
|
+
|
|
1840
|
+
try {}
|
|
1841
|
+
|
|
1842
|
+
finally {
|
|
1843
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1844
|
+
}
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1847
|
+
/**
|
|
1848
|
+
* The WorldEdit version, or `-1` if not set.
|
|
1849
|
+
*/
|
|
1850
|
+
weVersion() {
|
|
1851
|
+
|
|
1852
|
+
const result = wasm.Schematic_we_version(this.ffiValue);
|
|
1853
|
+
|
|
1854
|
+
try {
|
|
1855
|
+
return result;
|
|
1856
|
+
}
|
|
1857
|
+
|
|
1858
|
+
finally {
|
|
1859
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1862
|
+
|
|
1863
|
+
/**
|
|
1864
|
+
* Set the WorldEdit version.
|
|
1865
|
+
*/
|
|
1866
|
+
setWeVersion(version) {
|
|
1867
|
+
wasm.Schematic_set_we_version(this.ffiValue, version);
|
|
1868
|
+
|
|
1869
|
+
try {}
|
|
1870
|
+
|
|
1871
|
+
finally {
|
|
1872
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1873
|
+
}
|
|
1874
|
+
}
|
|
1875
|
+
|
|
1876
|
+
/**
|
|
1877
|
+
* Mirror the default region along the X axis (in place). Block
|
|
1878
|
+
* orientations (e.g. `facing` properties), block entities, and
|
|
1879
|
+
* entities are mirrored too.
|
|
1880
|
+
*/
|
|
1881
|
+
flipX() {
|
|
1882
|
+
wasm.Schematic_flip_x(this.ffiValue);
|
|
1883
|
+
|
|
1884
|
+
try {}
|
|
1885
|
+
|
|
1886
|
+
finally {
|
|
1887
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
|
|
1891
|
+
/**
|
|
1892
|
+
* Mirror the default region along the Y axis (in place). Block
|
|
1893
|
+
* orientations, block entities, and entities are mirrored too.
|
|
1894
|
+
*/
|
|
1895
|
+
flipY() {
|
|
1896
|
+
wasm.Schematic_flip_y(this.ffiValue);
|
|
1897
|
+
|
|
1898
|
+
try {}
|
|
1899
|
+
|
|
1900
|
+
finally {
|
|
1901
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
|
|
1905
|
+
/**
|
|
1906
|
+
* Mirror the default region along the Z axis (in place). Block
|
|
1907
|
+
* orientations, block entities, and entities are mirrored too.
|
|
1908
|
+
*/
|
|
1909
|
+
flipZ() {
|
|
1910
|
+
wasm.Schematic_flip_z(this.ffiValue);
|
|
1911
|
+
|
|
1912
|
+
try {}
|
|
1913
|
+
|
|
1914
|
+
finally {
|
|
1915
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1916
|
+
}
|
|
1917
|
+
}
|
|
1918
|
+
|
|
1919
|
+
/**
|
|
1920
|
+
* Rotate the default region about the X axis. `degrees` must be a
|
|
1921
|
+
* multiple of 90 (anything else is a no-op; negative values wrap).
|
|
1922
|
+
* +90° maps +Z onto +Y (south face rotates up). The region keeps its
|
|
1923
|
+
* minimum corner; block orientations and entities are updated.
|
|
1924
|
+
*/
|
|
1925
|
+
rotateX(degrees) {
|
|
1926
|
+
wasm.Schematic_rotate_x(this.ffiValue, degrees);
|
|
1927
|
+
|
|
1928
|
+
try {}
|
|
1929
|
+
|
|
1930
|
+
finally {
|
|
1931
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1932
|
+
}
|
|
1933
|
+
}
|
|
1934
|
+
|
|
1935
|
+
/**
|
|
1936
|
+
* Rotate the default region about the Y axis (horizontal plane).
|
|
1937
|
+
* `degrees` must be a multiple of 90 (anything else is a no-op;
|
|
1938
|
+
* negative values wrap). +90° maps +X onto -Z (east to north, i.e.
|
|
1939
|
+
* counterclockwise seen from above). The region keeps its minimum
|
|
1940
|
+
* corner; block orientations and entities are updated.
|
|
1941
|
+
*/
|
|
1942
|
+
rotateY(degrees) {
|
|
1943
|
+
wasm.Schematic_rotate_y(this.ffiValue, degrees);
|
|
1944
|
+
|
|
1945
|
+
try {}
|
|
1946
|
+
|
|
1947
|
+
finally {
|
|
1948
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1949
|
+
}
|
|
1950
|
+
}
|
|
1951
|
+
|
|
1952
|
+
/**
|
|
1953
|
+
* Rotate the default region about the Z axis. `degrees` must be a
|
|
1954
|
+
* multiple of 90 (anything else is a no-op; negative values wrap).
|
|
1955
|
+
* +90° maps +Y onto +X (up rotates east). The region keeps its
|
|
1956
|
+
* minimum corner; block orientations and entities are updated.
|
|
1957
|
+
*/
|
|
1958
|
+
rotateZ(degrees) {
|
|
1959
|
+
wasm.Schematic_rotate_z(this.ffiValue, degrees);
|
|
1960
|
+
|
|
1961
|
+
try {}
|
|
1962
|
+
|
|
1963
|
+
finally {
|
|
1964
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1967
|
+
|
|
1968
|
+
/**
|
|
1969
|
+
* Mirror a named region along the X axis (like `flip_x`). `NotFound`
|
|
1970
|
+
* if no region has that name.
|
|
1971
|
+
*/
|
|
1972
|
+
flipRegionX(regionName) {
|
|
1973
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
1974
|
+
|
|
1975
|
+
const regionNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, regionName)));
|
|
1976
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
1977
|
+
|
|
1978
|
+
|
|
1979
|
+
const result = wasm.Schematic_flip_region_x(diplomatReceive.buffer, this.ffiValue, regionNameSlice.ptr);
|
|
1980
|
+
|
|
1981
|
+
try {
|
|
1982
|
+
if (!diplomatReceive.resultFlag) {
|
|
1983
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
1984
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
1985
|
+
}
|
|
1986
|
+
}
|
|
1987
|
+
|
|
1988
|
+
finally {
|
|
1989
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1990
|
+
functionCleanupArena.free();
|
|
1991
|
+
|
|
1992
|
+
diplomatReceive.free();
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
|
|
1996
|
+
/**
|
|
1997
|
+
* Mirror a named region along the Y axis (like `flip_y`). `NotFound`
|
|
1998
|
+
* if no region has that name.
|
|
1999
|
+
*/
|
|
2000
|
+
flipRegionY(regionName) {
|
|
2001
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
2002
|
+
|
|
2003
|
+
const regionNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, regionName)));
|
|
2004
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
2005
|
+
|
|
2006
|
+
|
|
2007
|
+
const result = wasm.Schematic_flip_region_y(diplomatReceive.buffer, this.ffiValue, regionNameSlice.ptr);
|
|
2008
|
+
|
|
2009
|
+
try {
|
|
2010
|
+
if (!diplomatReceive.resultFlag) {
|
|
2011
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
2012
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
2013
|
+
}
|
|
2014
|
+
}
|
|
2015
|
+
|
|
2016
|
+
finally {
|
|
2017
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
2018
|
+
functionCleanupArena.free();
|
|
2019
|
+
|
|
2020
|
+
diplomatReceive.free();
|
|
2021
|
+
}
|
|
2022
|
+
}
|
|
2023
|
+
|
|
2024
|
+
/**
|
|
2025
|
+
* Mirror a named region along the Z axis (like `flip_z`). `NotFound`
|
|
2026
|
+
* if no region has that name.
|
|
2027
|
+
*/
|
|
2028
|
+
flipRegionZ(regionName) {
|
|
2029
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
2030
|
+
|
|
2031
|
+
const regionNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, regionName)));
|
|
2032
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
2033
|
+
|
|
2034
|
+
|
|
2035
|
+
const result = wasm.Schematic_flip_region_z(diplomatReceive.buffer, this.ffiValue, regionNameSlice.ptr);
|
|
2036
|
+
|
|
2037
|
+
try {
|
|
2038
|
+
if (!diplomatReceive.resultFlag) {
|
|
2039
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
2040
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
2041
|
+
}
|
|
2042
|
+
}
|
|
2043
|
+
|
|
2044
|
+
finally {
|
|
2045
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
2046
|
+
functionCleanupArena.free();
|
|
2047
|
+
|
|
2048
|
+
diplomatReceive.free();
|
|
2049
|
+
}
|
|
2050
|
+
}
|
|
2051
|
+
|
|
2052
|
+
/**
|
|
2053
|
+
* Rotate a named region about the X axis by a multiple of 90 degrees
|
|
2054
|
+
* (same semantics as `rotate_x`). `NotFound` if no region has that
|
|
2055
|
+
* name.
|
|
2056
|
+
*/
|
|
2057
|
+
rotateRegionX(regionName, degrees) {
|
|
2058
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
2059
|
+
|
|
2060
|
+
const regionNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, regionName)));
|
|
2061
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
2062
|
+
|
|
2063
|
+
|
|
2064
|
+
const result = wasm.Schematic_rotate_region_x(diplomatReceive.buffer, this.ffiValue, regionNameSlice.ptr, degrees);
|
|
2065
|
+
|
|
2066
|
+
try {
|
|
2067
|
+
if (!diplomatReceive.resultFlag) {
|
|
2068
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
2069
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
2070
|
+
}
|
|
2071
|
+
}
|
|
2072
|
+
|
|
2073
|
+
finally {
|
|
2074
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
2075
|
+
functionCleanupArena.free();
|
|
2076
|
+
|
|
2077
|
+
diplomatReceive.free();
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
|
|
2081
|
+
/**
|
|
2082
|
+
* Rotate a named region about the Y axis by a multiple of 90 degrees
|
|
2083
|
+
* (same semantics as `rotate_y`). `NotFound` if no region has that
|
|
2084
|
+
* name.
|
|
2085
|
+
*/
|
|
2086
|
+
rotateRegionY(regionName, degrees) {
|
|
2087
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
2088
|
+
|
|
2089
|
+
const regionNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, regionName)));
|
|
2090
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
2091
|
+
|
|
2092
|
+
|
|
2093
|
+
const result = wasm.Schematic_rotate_region_y(diplomatReceive.buffer, this.ffiValue, regionNameSlice.ptr, degrees);
|
|
2094
|
+
|
|
2095
|
+
try {
|
|
2096
|
+
if (!diplomatReceive.resultFlag) {
|
|
2097
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
2098
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
2101
|
+
|
|
2102
|
+
finally {
|
|
2103
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
2104
|
+
functionCleanupArena.free();
|
|
2105
|
+
|
|
2106
|
+
diplomatReceive.free();
|
|
2107
|
+
}
|
|
2108
|
+
}
|
|
2109
|
+
|
|
2110
|
+
/**
|
|
2111
|
+
* Rotate a named region about the Z axis by a multiple of 90 degrees
|
|
2112
|
+
* (same semantics as `rotate_z`). `NotFound` if no region has that
|
|
2113
|
+
* name.
|
|
2114
|
+
*/
|
|
2115
|
+
rotateRegionZ(regionName, degrees) {
|
|
2116
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
2117
|
+
|
|
2118
|
+
const regionNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, regionName)));
|
|
2119
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
2120
|
+
|
|
2121
|
+
|
|
2122
|
+
const result = wasm.Schematic_rotate_region_z(diplomatReceive.buffer, this.ffiValue, regionNameSlice.ptr, degrees);
|
|
2123
|
+
|
|
2124
|
+
try {
|
|
2125
|
+
if (!diplomatReceive.resultFlag) {
|
|
2126
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
2127
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
2128
|
+
}
|
|
2129
|
+
}
|
|
2130
|
+
|
|
2131
|
+
finally {
|
|
2132
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
2133
|
+
functionCleanupArena.free();
|
|
2134
|
+
|
|
2135
|
+
diplomatReceive.free();
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2138
|
+
|
|
2139
|
+
/**
|
|
2140
|
+
* Fill a cuboid with a block.
|
|
2141
|
+
*/
|
|
2142
|
+
fillCuboid(minX, minY, minZ, maxX, maxY, maxZ, blockName) {
|
|
2143
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
2144
|
+
|
|
2145
|
+
const blockNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, blockName)));
|
|
2146
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
2147
|
+
|
|
2148
|
+
|
|
2149
|
+
const result = wasm.Schematic_fill_cuboid(diplomatReceive.buffer, this.ffiValue, minX, minY, minZ, maxX, maxY, maxZ, blockNameSlice.ptr);
|
|
2150
|
+
|
|
2151
|
+
try {
|
|
2152
|
+
if (!diplomatReceive.resultFlag) {
|
|
2153
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
2154
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
2155
|
+
}
|
|
2156
|
+
}
|
|
2157
|
+
|
|
2158
|
+
finally {
|
|
2159
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
2160
|
+
functionCleanupArena.free();
|
|
2161
|
+
|
|
2162
|
+
diplomatReceive.free();
|
|
2163
|
+
}
|
|
2164
|
+
}
|
|
2165
|
+
|
|
2166
|
+
/**
|
|
2167
|
+
* Fill a sphere with a block.
|
|
2168
|
+
*/
|
|
2169
|
+
fillSphere(cx, cy, cz, radius, blockName) {
|
|
2170
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
2171
|
+
|
|
2172
|
+
const blockNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, blockName)));
|
|
2173
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
2174
|
+
|
|
2175
|
+
|
|
2176
|
+
const result = wasm.Schematic_fill_sphere(diplomatReceive.buffer, this.ffiValue, cx, cy, cz, radius, blockNameSlice.ptr);
|
|
2177
|
+
|
|
2178
|
+
try {
|
|
2179
|
+
if (!diplomatReceive.resultFlag) {
|
|
2180
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
2181
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
2182
|
+
}
|
|
2183
|
+
}
|
|
2184
|
+
|
|
2185
|
+
finally {
|
|
2186
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
2187
|
+
functionCleanupArena.free();
|
|
2188
|
+
|
|
2189
|
+
diplomatReceive.free();
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
|
|
2193
|
+
/**
|
|
2194
|
+
* Serialize to a named format, base64-encoded. `version` and `settings`
|
|
2195
|
+
* may be empty strings for defaults.
|
|
2196
|
+
*/
|
|
2197
|
+
saveAsB64(format, version, settings) {
|
|
2198
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
2199
|
+
|
|
2200
|
+
const formatSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, format)));
|
|
2201
|
+
const versionSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, version)));
|
|
2202
|
+
const settingsSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, settings)));
|
|
2203
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
2204
|
+
|
|
2205
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
2206
|
+
|
|
2207
|
+
|
|
2208
|
+
const result = wasm.Schematic_save_as_b64(diplomatReceive.buffer, this.ffiValue, formatSlice.ptr, versionSlice.ptr, settingsSlice.ptr, write.buffer);
|
|
2209
|
+
|
|
2210
|
+
try {
|
|
2211
|
+
if (!diplomatReceive.resultFlag) {
|
|
2212
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
2213
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
2214
|
+
}
|
|
2215
|
+
return write.readString8();
|
|
2216
|
+
}
|
|
2217
|
+
|
|
2218
|
+
finally {
|
|
2219
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
2220
|
+
functionCleanupArena.free();
|
|
2221
|
+
|
|
2222
|
+
diplomatReceive.free();
|
|
2223
|
+
write.free();
|
|
2224
|
+
}
|
|
2225
|
+
}
|
|
2226
|
+
|
|
2227
|
+
/**
|
|
2228
|
+
* Save to a file. If `format` is empty, the format is auto-detected from
|
|
2229
|
+
* the file extension; `version` may be empty for the default.
|
|
2230
|
+
*/
|
|
2231
|
+
saveToFileWithFormat(path, format, version) {
|
|
2232
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
2233
|
+
|
|
2234
|
+
const pathSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, path)));
|
|
2235
|
+
const formatSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, format)));
|
|
2236
|
+
const versionSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, version)));
|
|
2237
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
2238
|
+
|
|
2239
|
+
|
|
2240
|
+
const result = wasm.Schematic_save_to_file_with_format(diplomatReceive.buffer, this.ffiValue, pathSlice.ptr, formatSlice.ptr, versionSlice.ptr);
|
|
2241
|
+
|
|
2242
|
+
try {
|
|
2243
|
+
if (!diplomatReceive.resultFlag) {
|
|
2244
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
2245
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
2246
|
+
}
|
|
2247
|
+
}
|
|
2248
|
+
|
|
2249
|
+
finally {
|
|
2250
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
2251
|
+
functionCleanupArena.free();
|
|
2252
|
+
|
|
2253
|
+
diplomatReceive.free();
|
|
2254
|
+
}
|
|
2255
|
+
}
|
|
2256
|
+
|
|
2257
|
+
/**
|
|
2258
|
+
* Serialize as a Sponge schematic targeting a specific format version,
|
|
2259
|
+
* base64-encoded.
|
|
2260
|
+
*/
|
|
2261
|
+
toSchematicVersionB64(version) {
|
|
2262
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
2263
|
+
|
|
2264
|
+
const versionSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, version)));
|
|
2265
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
2266
|
+
|
|
2267
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
2268
|
+
|
|
2269
|
+
|
|
2270
|
+
const result = wasm.Schematic_to_schematic_version_b64(diplomatReceive.buffer, this.ffiValue, versionSlice.ptr, write.buffer);
|
|
2271
|
+
|
|
2272
|
+
try {
|
|
2273
|
+
if (!diplomatReceive.resultFlag) {
|
|
2274
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
2275
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
2276
|
+
}
|
|
2277
|
+
return write.readString8();
|
|
2278
|
+
}
|
|
2279
|
+
|
|
2280
|
+
finally {
|
|
2281
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
2282
|
+
functionCleanupArena.free();
|
|
2283
|
+
|
|
2284
|
+
diplomatReceive.free();
|
|
2285
|
+
write.free();
|
|
2286
|
+
}
|
|
2287
|
+
}
|
|
2288
|
+
|
|
2289
|
+
/**
|
|
2290
|
+
* The available Sponge schematic exporter versions, as a JSON array of
|
|
2291
|
+
* strings.
|
|
2292
|
+
*/
|
|
2293
|
+
static availableSchematicVersionsJson() {
|
|
2294
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
2295
|
+
|
|
2296
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
2297
|
+
|
|
2298
|
+
|
|
2299
|
+
const result = wasm.Schematic_available_schematic_versions_json(diplomatReceive.buffer, write.buffer);
|
|
2300
|
+
|
|
2301
|
+
try {
|
|
2302
|
+
if (!diplomatReceive.resultFlag) {
|
|
2303
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
2304
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
2305
|
+
}
|
|
2306
|
+
return write.readString8();
|
|
2307
|
+
}
|
|
2308
|
+
|
|
2309
|
+
finally {
|
|
2310
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
2311
|
+
diplomatReceive.free();
|
|
2312
|
+
write.free();
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
|
|
2316
|
+
/**
|
|
2317
|
+
* Set a block with NBT data given as a JSON object of string→string
|
|
2318
|
+
* (may be empty).
|
|
2319
|
+
*/
|
|
2320
|
+
setBlockWithNbt(x, y, z, blockName, nbtJson) {
|
|
2321
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
2322
|
+
|
|
2323
|
+
const blockNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, blockName)));
|
|
2324
|
+
const nbtJsonSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, nbtJson)));
|
|
2325
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
2326
|
+
|
|
2327
|
+
|
|
2328
|
+
const result = wasm.Schematic_set_block_with_nbt(diplomatReceive.buffer, this.ffiValue, x, y, z, blockNameSlice.ptr, nbtJsonSlice.ptr);
|
|
2329
|
+
|
|
2330
|
+
try {
|
|
2331
|
+
if (!diplomatReceive.resultFlag) {
|
|
2332
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
2333
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
2334
|
+
}
|
|
2335
|
+
}
|
|
2336
|
+
|
|
2337
|
+
finally {
|
|
2338
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
2339
|
+
functionCleanupArena.free();
|
|
2340
|
+
|
|
2341
|
+
diplomatReceive.free();
|
|
2342
|
+
}
|
|
2343
|
+
}
|
|
2344
|
+
|
|
2345
|
+
/**
|
|
2346
|
+
* Set a block (by name) in a named region.
|
|
2347
|
+
*/
|
|
2348
|
+
setBlockInRegion(regionName, x, y, z, blockName) {
|
|
2349
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
2350
|
+
|
|
2351
|
+
const regionNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, regionName)));
|
|
2352
|
+
const blockNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, blockName)));
|
|
2353
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
2354
|
+
|
|
2355
|
+
|
|
2356
|
+
const result = wasm.Schematic_set_block_in_region(diplomatReceive.buffer, this.ffiValue, regionNameSlice.ptr, x, y, z, blockNameSlice.ptr);
|
|
2357
|
+
|
|
2358
|
+
try {
|
|
2359
|
+
if (!diplomatReceive.resultFlag) {
|
|
2360
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
2361
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
2362
|
+
}
|
|
2363
|
+
}
|
|
2364
|
+
|
|
2365
|
+
finally {
|
|
2366
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
2367
|
+
functionCleanupArena.free();
|
|
2368
|
+
|
|
2369
|
+
diplomatReceive.free();
|
|
2370
|
+
}
|
|
2371
|
+
}
|
|
2372
|
+
|
|
2373
|
+
/**
|
|
2374
|
+
* The schematic bounding box as a JSON array
|
|
2375
|
+
* `[min_x, min_y, min_z, max_x, max_y, max_z]`.
|
|
2376
|
+
*/
|
|
2377
|
+
boundingBoxJson() {
|
|
2378
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
2379
|
+
|
|
2380
|
+
wasm.Schematic_bounding_box_json(this.ffiValue, write.buffer);
|
|
2381
|
+
|
|
2382
|
+
try {
|
|
2383
|
+
return write.readString8();
|
|
2384
|
+
}
|
|
2385
|
+
|
|
2386
|
+
finally {
|
|
2387
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
2388
|
+
write.free();
|
|
2389
|
+
}
|
|
2390
|
+
}
|
|
2391
|
+
|
|
2392
|
+
/**
|
|
2393
|
+
* A named region's bounding box as a JSON array
|
|
2394
|
+
* `[min_x, min_y, min_z, max_x, max_y, max_z]`. `"default"`/`"Default"`
|
|
2395
|
+
* address the default region.
|
|
2396
|
+
*/
|
|
2397
|
+
regionBoundingBoxJson(regionName) {
|
|
2398
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
2399
|
+
|
|
2400
|
+
const regionNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, regionName)));
|
|
2401
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
2402
|
+
|
|
2403
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
2404
|
+
|
|
2405
|
+
|
|
2406
|
+
const result = wasm.Schematic_region_bounding_box_json(diplomatReceive.buffer, this.ffiValue, regionNameSlice.ptr, write.buffer);
|
|
2407
|
+
|
|
2408
|
+
try {
|
|
2409
|
+
if (!diplomatReceive.resultFlag) {
|
|
2410
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
2411
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
2412
|
+
}
|
|
2413
|
+
return write.readString8();
|
|
2414
|
+
}
|
|
2415
|
+
|
|
2416
|
+
finally {
|
|
2417
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
2418
|
+
functionCleanupArena.free();
|
|
2419
|
+
|
|
2420
|
+
diplomatReceive.free();
|
|
2421
|
+
write.free();
|
|
2422
|
+
}
|
|
2423
|
+
}
|
|
2424
|
+
|
|
2425
|
+
/**
|
|
2426
|
+
* The merged-region palette block names, as a JSON array of strings.
|
|
2427
|
+
*/
|
|
2428
|
+
paletteJson() {
|
|
2429
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
2430
|
+
|
|
2431
|
+
wasm.Schematic_palette_json(this.ffiValue, write.buffer);
|
|
2432
|
+
|
|
2433
|
+
try {
|
|
2434
|
+
return write.readString8();
|
|
2435
|
+
}
|
|
2436
|
+
|
|
2437
|
+
finally {
|
|
2438
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
2439
|
+
write.free();
|
|
2440
|
+
}
|
|
2441
|
+
}
|
|
2442
|
+
|
|
2443
|
+
/**
|
|
2444
|
+
* The tight (content) dimensions.
|
|
2445
|
+
*/
|
|
2446
|
+
tightDimensions() {
|
|
2447
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 12, 4, false);
|
|
2448
|
+
|
|
2449
|
+
|
|
2450
|
+
const result = wasm.Schematic_tight_dimensions(diplomatReceive.buffer, this.ffiValue);
|
|
2451
|
+
|
|
2452
|
+
try {
|
|
2453
|
+
return Dimensions._fromFFI(diplomatRuntime.internalConstructor, diplomatReceive.buffer);
|
|
2454
|
+
}
|
|
2455
|
+
|
|
2456
|
+
finally {
|
|
2457
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
2458
|
+
diplomatReceive.free();
|
|
2459
|
+
}
|
|
2460
|
+
}
|
|
2461
|
+
|
|
2462
|
+
/**
|
|
2463
|
+
* The allocated dimensions (same as `dimensions`; named for parity with
|
|
2464
|
+
* the old `schematic_get_allocated_dimensions`).
|
|
2465
|
+
*/
|
|
2466
|
+
allocatedDimensions() {
|
|
2467
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 12, 4, false);
|
|
2468
|
+
|
|
2469
|
+
|
|
2470
|
+
const result = wasm.Schematic_allocated_dimensions(diplomatReceive.buffer, this.ffiValue);
|
|
2471
|
+
|
|
2472
|
+
try {
|
|
2473
|
+
return Dimensions._fromFFI(diplomatRuntime.internalConstructor, diplomatReceive.buffer);
|
|
2474
|
+
}
|
|
2475
|
+
|
|
2476
|
+
finally {
|
|
2477
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
2478
|
+
diplomatReceive.free();
|
|
2479
|
+
}
|
|
2480
|
+
}
|
|
2481
|
+
|
|
2482
|
+
/**
|
|
2483
|
+
* Every sign in the schematic, as a JSON array of
|
|
2484
|
+
* `{"pos": [x,y,z], "text": [...]}`.
|
|
2485
|
+
*/
|
|
2486
|
+
extractSignsJson() {
|
|
2487
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
2488
|
+
|
|
2489
|
+
wasm.Schematic_extract_signs_json(this.ffiValue, write.buffer);
|
|
2490
|
+
|
|
2491
|
+
try {
|
|
2492
|
+
return write.readString8();
|
|
2493
|
+
}
|
|
2494
|
+
|
|
2495
|
+
finally {
|
|
2496
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
2497
|
+
write.free();
|
|
2498
|
+
}
|
|
2499
|
+
}
|
|
2500
|
+
|
|
2501
|
+
/**
|
|
2502
|
+
* Compile the schematic's insign annotations to JSON.
|
|
2503
|
+
*/
|
|
2504
|
+
compileInsignJson() {
|
|
2505
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
2506
|
+
|
|
2507
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
2508
|
+
|
|
2509
|
+
|
|
2510
|
+
const result = wasm.Schematic_compile_insign_json(diplomatReceive.buffer, this.ffiValue, write.buffer);
|
|
2511
|
+
|
|
2512
|
+
try {
|
|
2513
|
+
if (!diplomatReceive.resultFlag) {
|
|
2514
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
2515
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
2516
|
+
}
|
|
2517
|
+
return write.readString8();
|
|
2518
|
+
}
|
|
2519
|
+
|
|
2520
|
+
finally {
|
|
2521
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
2522
|
+
diplomatReceive.free();
|
|
2523
|
+
write.free();
|
|
2524
|
+
}
|
|
2525
|
+
}
|
|
2526
|
+
|
|
2527
|
+
/**
|
|
2528
|
+
* Every region's palette, as a JSON object mapping region name → array of
|
|
2529
|
+
* block names (the default region under `"default"`).
|
|
2530
|
+
*/
|
|
2531
|
+
allPalettesJson() {
|
|
2532
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
2533
|
+
|
|
2534
|
+
wasm.Schematic_all_palettes_json(this.ffiValue, write.buffer);
|
|
2535
|
+
|
|
2536
|
+
try {
|
|
2537
|
+
return write.readString8();
|
|
2538
|
+
}
|
|
2539
|
+
|
|
2540
|
+
finally {
|
|
2541
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
2542
|
+
write.free();
|
|
2543
|
+
}
|
|
2544
|
+
}
|
|
2545
|
+
|
|
2546
|
+
/**
|
|
2547
|
+
* The default region's palette block names, as a JSON array of strings.
|
|
2548
|
+
*/
|
|
2549
|
+
defaultRegionPaletteJson() {
|
|
2550
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
2551
|
+
|
|
2552
|
+
wasm.Schematic_default_region_palette_json(this.ffiValue, write.buffer);
|
|
2553
|
+
|
|
2554
|
+
try {
|
|
2555
|
+
return write.readString8();
|
|
2556
|
+
}
|
|
2557
|
+
|
|
2558
|
+
finally {
|
|
2559
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
2560
|
+
write.free();
|
|
2561
|
+
}
|
|
2562
|
+
}
|
|
2563
|
+
|
|
2564
|
+
/**
|
|
2565
|
+
* A named region's palette block names, as a JSON array of strings.
|
|
2566
|
+
* `"default"`/`"Default"` address the default region.
|
|
2567
|
+
*/
|
|
2568
|
+
regionPaletteJson(regionName) {
|
|
2569
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
2570
|
+
|
|
2571
|
+
const regionNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, regionName)));
|
|
2572
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
2573
|
+
|
|
2574
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
2575
|
+
|
|
2576
|
+
|
|
2577
|
+
const result = wasm.Schematic_region_palette_json(diplomatReceive.buffer, this.ffiValue, regionNameSlice.ptr, write.buffer);
|
|
2578
|
+
|
|
2579
|
+
try {
|
|
2580
|
+
if (!diplomatReceive.resultFlag) {
|
|
2581
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
2582
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
2583
|
+
}
|
|
2584
|
+
return write.readString8();
|
|
2585
|
+
}
|
|
2586
|
+
|
|
2587
|
+
finally {
|
|
2588
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
2589
|
+
functionCleanupArena.free();
|
|
2590
|
+
|
|
2591
|
+
diplomatReceive.free();
|
|
2592
|
+
write.free();
|
|
2593
|
+
}
|
|
2594
|
+
}
|
|
2595
|
+
|
|
2596
|
+
/**
|
|
2597
|
+
* The minimum corner of the tight (content) bounds. `NotFound` when the
|
|
2598
|
+
* schematic has no content.
|
|
2599
|
+
*/
|
|
2600
|
+
tightBoundsMin() {
|
|
2601
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 13, 4, true);
|
|
2602
|
+
|
|
2603
|
+
|
|
2604
|
+
const result = wasm.Schematic_tight_bounds_min(diplomatReceive.buffer, this.ffiValue);
|
|
2605
|
+
|
|
2606
|
+
try {
|
|
2607
|
+
if (!diplomatReceive.resultFlag) {
|
|
2608
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
2609
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
2610
|
+
}
|
|
2611
|
+
return BlockPos._fromFFI(diplomatRuntime.internalConstructor, diplomatReceive.buffer);
|
|
2612
|
+
}
|
|
2613
|
+
|
|
2614
|
+
finally {
|
|
2615
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
2616
|
+
diplomatReceive.free();
|
|
2617
|
+
}
|
|
2618
|
+
}
|
|
2619
|
+
|
|
2620
|
+
/**
|
|
2621
|
+
* The maximum corner of the tight (content) bounds. `NotFound` when the
|
|
2622
|
+
* schematic has no content.
|
|
2623
|
+
*/
|
|
2624
|
+
tightBoundsMax() {
|
|
2625
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 13, 4, true);
|
|
2626
|
+
|
|
2627
|
+
|
|
2628
|
+
const result = wasm.Schematic_tight_bounds_max(diplomatReceive.buffer, this.ffiValue);
|
|
2629
|
+
|
|
2630
|
+
try {
|
|
2631
|
+
if (!diplomatReceive.resultFlag) {
|
|
2632
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
2633
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
2634
|
+
}
|
|
2635
|
+
return BlockPos._fromFFI(diplomatRuntime.internalConstructor, diplomatReceive.buffer);
|
|
2636
|
+
}
|
|
2637
|
+
|
|
2638
|
+
finally {
|
|
2639
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
2640
|
+
diplomatReceive.free();
|
|
2641
|
+
}
|
|
2642
|
+
}
|
|
2643
|
+
|
|
2644
|
+
constructor(symbol, ptr, selfEdge) {
|
|
2645
|
+
return this.#internalConstructor(...arguments)
|
|
2646
|
+
}
|
|
2647
|
+
}
|