nucleation 0.3.17 → 0.3.19

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/Schematic.mjs CHANGED
@@ -60,6 +60,23 @@ export class Schematic {
60
60
  }
61
61
  }
62
62
 
63
+ /**
64
+ * Return an independent deep copy. Subsequent block, region, entity,
65
+ * metadata, or transform changes do not affect the original.
66
+ */
67
+ deepClone() {
68
+
69
+ const result = wasm.Schematic_deep_clone(this.ffiValue);
70
+
71
+ try {
72
+ return new Schematic(diplomatRuntime.internalConstructor, result, []);
73
+ }
74
+
75
+ finally {
76
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
77
+ }
78
+ }
79
+
63
80
  /**
64
81
  * The allocated dimensions (width, height, length) of the schematic's
65
82
  * bounding box.
@@ -820,8 +837,65 @@ export class Schematic {
820
837
  }
821
838
 
822
839
  /**
823
- * Copy a region from `source` into this schematic. `excluded_blocks_json`
824
- * is a JSON array of block strings to skip (empty string or `[]` for none).
840
+ * Stamp a merged source box into the default region. Excluded blocks
841
+ * are skipped, preserving destination content. Empty string or `[]`
842
+ * means no exclusions.
843
+ */
844
+ stampBox(source, minX, minY, minZ, maxX, maxY, maxZ, targetX, targetY, targetZ, excludedBlocksJson) {
845
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
846
+
847
+ const excludedBlocksJsonSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, excludedBlocksJson)));
848
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
849
+
850
+
851
+ const result = wasm.Schematic_stamp_box(diplomatReceive.buffer, this.ffiValue, source.ffiValue, minX, minY, minZ, maxX, maxY, maxZ, targetX, targetY, targetZ, excludedBlocksJsonSlice.ptr);
852
+
853
+ try {
854
+ if (!diplomatReceive.resultFlag) {
855
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
856
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
857
+ }
858
+ }
859
+
860
+ finally {
861
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
862
+ functionCleanupArena.free();
863
+
864
+ diplomatReceive.free();
865
+ }
866
+ }
867
+
868
+ /**
869
+ * Stamp one explicitly named source region into the default region.
870
+ * The region's minimum corner is mapped to the target position.
871
+ */
872
+ stampRegion(source, sourceRegionName, targetX, targetY, targetZ, excludedBlocksJson) {
873
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
874
+
875
+ const sourceRegionNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, sourceRegionName)));
876
+ const excludedBlocksJsonSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, excludedBlocksJson)));
877
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
878
+
879
+
880
+ const result = wasm.Schematic_stamp_region(diplomatReceive.buffer, this.ffiValue, source.ffiValue, sourceRegionNameSlice.ptr, targetX, targetY, targetZ, excludedBlocksJsonSlice.ptr);
881
+
882
+ try {
883
+ if (!diplomatReceive.resultFlag) {
884
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
885
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
886
+ }
887
+ }
888
+
889
+ finally {
890
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
891
+ functionCleanupArena.free();
892
+
893
+ diplomatReceive.free();
894
+ }
895
+ }
896
+
897
+ /**
898
+ * Compatibility alias for `stamp_box`.
825
899
  */
826
900
  copyRegion(source, minX, minY, minZ, maxX, maxY, maxZ, targetX, targetY, targetZ, excludedBlocksJson) {
827
901
  let functionCleanupArena = new diplomatRuntime.CleanupArena();
@@ -847,8 +921,33 @@ export class Schematic {
847
921
  }
848
922
  }
849
923
 
924
+ /**
925
+ * The full block state at a position. `NotFound` if the position is
926
+ * outside every region.
927
+ */
928
+ getBlock(x, y, z) {
929
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
930
+
931
+
932
+ const result = wasm.Schematic_get_block(diplomatReceive.buffer, this.ffiValue, x, y, z);
933
+
934
+ try {
935
+ if (!diplomatReceive.resultFlag) {
936
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
937
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
938
+ }
939
+ return new BlockState(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
940
+ }
941
+
942
+ finally {
943
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
944
+ diplomatReceive.free();
945
+ }
946
+ }
947
+
850
948
  /**
851
949
  * The block at a position with its properties, as a `BlockState`.
950
+ * Kept as an explicit alias for callers migrating from the older API.
852
951
  */
853
952
  getBlockWithProperties(x, y, z) {
854
953
  const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
@@ -870,6 +969,66 @@ export class Schematic {
870
969
  }
871
970
  }
872
971
 
972
+ /**
973
+ * The full block state at a position in one specific region. This
974
+ * avoids composite lookup ambiguity when regions overlap.
975
+ */
976
+ getBlockInRegion(regionName, x, y, z) {
977
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
978
+
979
+ const regionNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, regionName)));
980
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
981
+
982
+
983
+ const result = wasm.Schematic_get_block_in_region(diplomatReceive.buffer, this.ffiValue, regionNameSlice.ptr, x, y, z);
984
+
985
+ try {
986
+ if (!diplomatReceive.resultFlag) {
987
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
988
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
989
+ }
990
+ return new BlockState(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
991
+ }
992
+
993
+ finally {
994
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
995
+ functionCleanupArena.free();
996
+
997
+ diplomatReceive.free();
998
+ }
999
+ }
1000
+
1001
+ /**
1002
+ * The block string at a position in one specific region.
1003
+ */
1004
+ getBlockStringInRegion(regionName, x, y, z) {
1005
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
1006
+
1007
+ const regionNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, regionName)));
1008
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
1009
+
1010
+ const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
1011
+
1012
+
1013
+ const result = wasm.Schematic_get_block_string_in_region(diplomatReceive.buffer, this.ffiValue, regionNameSlice.ptr, x, y, z, write.buffer);
1014
+
1015
+ try {
1016
+ if (!diplomatReceive.resultFlag) {
1017
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
1018
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
1019
+ }
1020
+ return write.readString8();
1021
+ }
1022
+
1023
+ finally {
1024
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1025
+ functionCleanupArena.free();
1026
+
1027
+ diplomatReceive.free();
1028
+ write.free();
1029
+ }
1030
+ }
1031
+
873
1032
  /**
874
1033
  * The full block string (name, properties, NBT) at a position.
875
1034
  */
@@ -923,6 +1082,37 @@ export class Schematic {
923
1082
  }
924
1083
  }
925
1084
 
1085
+ /**
1086
+ * The block entity at a position in one specific region as JSON.
1087
+ */
1088
+ getBlockEntityJsonInRegion(regionName, x, y, z) {
1089
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
1090
+
1091
+ const regionNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, regionName)));
1092
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
1093
+
1094
+ const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
1095
+
1096
+
1097
+ const result = wasm.Schematic_get_block_entity_json_in_region(diplomatReceive.buffer, this.ffiValue, regionNameSlice.ptr, x, y, z, write.buffer);
1098
+
1099
+ try {
1100
+ if (!diplomatReceive.resultFlag) {
1101
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
1102
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
1103
+ }
1104
+ return write.readString8();
1105
+ }
1106
+
1107
+ finally {
1108
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1109
+ functionCleanupArena.free();
1110
+
1111
+ diplomatReceive.free();
1112
+ write.free();
1113
+ }
1114
+ }
1115
+
926
1116
  /**
927
1117
  * Every block entity as a JSON array of
928
1118
  * `{"id": ..., "position": [x,y,z], "nbt": {...}}`.
@@ -1005,6 +1195,36 @@ export class Schematic {
1005
1195
  }
1006
1196
  }
1007
1197
 
1198
+ /**
1199
+ * Add an armor stand without hand-authoring entity NBT.
1200
+ *
1201
+ * `armor_material` accepts `diamond`, `netherite`, `iron`, etc.; an
1202
+ * empty string creates an unarmored stand. `yaw` uses Minecraft degrees.
1203
+ */
1204
+ addArmorStand(x, y, z, yaw, armorMaterial) {
1205
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
1206
+
1207
+ const armorMaterialSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, armorMaterial)));
1208
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
1209
+
1210
+
1211
+ const result = wasm.Schematic_add_armor_stand(diplomatReceive.buffer, this.ffiValue, x, y, z, yaw, armorMaterialSlice.ptr);
1212
+
1213
+ try {
1214
+ if (!diplomatReceive.resultFlag) {
1215
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
1216
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
1217
+ }
1218
+ }
1219
+
1220
+ finally {
1221
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
1222
+ functionCleanupArena.free();
1223
+
1224
+ diplomatReceive.free();
1225
+ }
1226
+ }
1227
+
1008
1228
  /**
1009
1229
  * Remove a mobile entity by index.
1010
1230
  */
@@ -1817,8 +2037,7 @@ export class Schematic {
1817
2037
 
1818
2038
  /**
1819
2039
  * Mirror the default region along the X axis (in place). Block
1820
- * orientations (e.g. `facing` properties), block entities, and
1821
- * entities are mirrored too.
2040
+ * orientations, block entities, and entities are mirrored too.
1822
2041
  */
1823
2042
  flipX() {
1824
2043
  wasm.Schematic_flip_x(this.ffiValue);
@@ -1831,8 +2050,7 @@ export class Schematic {
1831
2050
  }
1832
2051
 
1833
2052
  /**
1834
- * Mirror the default region along the Y axis (in place). Block
1835
- * orientations, block entities, and entities are mirrored too.
2053
+ * Mirror the default region along the Y axis (in place).
1836
2054
  */
1837
2055
  flipY() {
1838
2056
  wasm.Schematic_flip_y(this.ffiValue);
@@ -1845,8 +2063,7 @@ export class Schematic {
1845
2063
  }
1846
2064
 
1847
2065
  /**
1848
- * Mirror the default region along the Z axis (in place). Block
1849
- * orientations, block entities, and entities are mirrored too.
2066
+ * Mirror the default region along the Z axis (in place).
1850
2067
  */
1851
2068
  flipZ() {
1852
2069
  wasm.Schematic_flip_z(this.ffiValue);
@@ -1859,57 +2076,100 @@ export class Schematic {
1859
2076
  }
1860
2077
 
1861
2078
  /**
1862
- * Rotate the default region about the X axis. `degrees` must be a
1863
- * multiple of 90 (anything else is a no-op; negative values wrap).
1864
- * +90° maps +Z onto +Y (south face rotates up). The region keeps its
1865
- * minimum corner; block orientations and entities are updated.
2079
+ * Rotate the default region about the X axis. +90° maps south (+Z)
2080
+ * to down (-Y). Only multiples of 90 are accepted; invalid angles
2081
+ * return `InvalidArgument` without changing the schematic. Negative
2082
+ * values wrap.
1866
2083
  */
1867
2084
  rotateX(degrees) {
1868
- wasm.Schematic_rotate_x(this.ffiValue, degrees);
2085
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
1869
2086
 
1870
- try {}
2087
+
2088
+ const result = wasm.Schematic_rotate_x(diplomatReceive.buffer, this.ffiValue, degrees);
2089
+
2090
+ try {
2091
+ if (!diplomatReceive.resultFlag) {
2092
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
2093
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
2094
+ }
2095
+ }
1871
2096
 
1872
2097
  finally {
1873
2098
  diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
2099
+ diplomatReceive.free();
1874
2100
  }
1875
2101
  }
1876
2102
 
1877
2103
  /**
1878
- * Rotate the default region about the Y axis (horizontal plane).
1879
- * `degrees` must be a multiple of 90 (anything else is a no-op;
1880
- * negative values wrap). +90° maps +X onto -Z (east to north, i.e.
1881
- * counterclockwise seen from above). The region keeps its minimum
1882
- * corner; block orientations and entities are updated.
2104
+ * Rotate the default region clockwise about the Y axis when viewed
2105
+ * from above. +90° maps east (+X) to south (+Z).
1883
2106
  */
1884
2107
  rotateY(degrees) {
1885
- wasm.Schematic_rotate_y(this.ffiValue, degrees);
2108
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
1886
2109
 
1887
- try {}
2110
+
2111
+ const result = wasm.Schematic_rotate_y(diplomatReceive.buffer, this.ffiValue, degrees);
2112
+
2113
+ try {
2114
+ if (!diplomatReceive.resultFlag) {
2115
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
2116
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
2117
+ }
2118
+ }
1888
2119
 
1889
2120
  finally {
1890
2121
  diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
2122
+ diplomatReceive.free();
1891
2123
  }
1892
2124
  }
1893
2125
 
1894
2126
  /**
1895
- * Rotate the default region about the Z axis. `degrees` must be a
1896
- * multiple of 90 (anything else is a no-op; negative values wrap).
1897
- * +90° maps +Y onto +X (up rotates east). The region keeps its
1898
- * minimum corner; block orientations and entities are updated.
2127
+ * Rotate the default region about the Z axis. +90° maps up (+Y) to
2128
+ * west (-X).
1899
2129
  */
1900
2130
  rotateZ(degrees) {
1901
- wasm.Schematic_rotate_z(this.ffiValue, degrees);
2131
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
1902
2132
 
1903
- try {}
2133
+
2134
+ const result = wasm.Schematic_rotate_z(diplomatReceive.buffer, this.ffiValue, degrees);
2135
+
2136
+ try {
2137
+ if (!diplomatReceive.resultFlag) {
2138
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
2139
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
2140
+ }
2141
+ }
2142
+
2143
+ finally {
2144
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
2145
+ diplomatReceive.free();
2146
+ }
2147
+ }
2148
+
2149
+ /**
2150
+ * Move the default region and all attached block entities/entities.
2151
+ */
2152
+ translate(dx, dy, dz) {
2153
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
2154
+
2155
+
2156
+ const result = wasm.Schematic_translate(diplomatReceive.buffer, this.ffiValue, dx, dy, dz);
2157
+
2158
+ try {
2159
+ if (!diplomatReceive.resultFlag) {
2160
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
2161
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
2162
+ }
2163
+ }
1904
2164
 
1905
2165
  finally {
1906
2166
  diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
2167
+ diplomatReceive.free();
1907
2168
  }
1908
2169
  }
1909
2170
 
1910
2171
  /**
1911
- * Mirror a named region along the X axis (like `flip_x`). `NotFound`
1912
- * if no region has that name.
2172
+ * Mirror a named region along the X axis.
1913
2173
  */
1914
2174
  flipRegionX(regionName) {
1915
2175
  let functionCleanupArena = new diplomatRuntime.CleanupArena();
@@ -1936,8 +2196,7 @@ export class Schematic {
1936
2196
  }
1937
2197
 
1938
2198
  /**
1939
- * Mirror a named region along the Y axis (like `flip_y`). `NotFound`
1940
- * if no region has that name.
2199
+ * Mirror a named region along the Y axis.
1941
2200
  */
1942
2201
  flipRegionY(regionName) {
1943
2202
  let functionCleanupArena = new diplomatRuntime.CleanupArena();
@@ -1964,8 +2223,7 @@ export class Schematic {
1964
2223
  }
1965
2224
 
1966
2225
  /**
1967
- * Mirror a named region along the Z axis (like `flip_z`). `NotFound`
1968
- * if no region has that name.
2226
+ * Mirror a named region along the Z axis.
1969
2227
  */
1970
2228
  flipRegionZ(regionName) {
1971
2229
  let functionCleanupArena = new diplomatRuntime.CleanupArena();
@@ -1992,9 +2250,7 @@ export class Schematic {
1992
2250
  }
1993
2251
 
1994
2252
  /**
1995
- * Rotate a named region about the X axis by a multiple of 90 degrees
1996
- * (same semantics as `rotate_x`). `NotFound` if no region has that
1997
- * name.
2253
+ * Rotate a named region about the X axis by a multiple of 90 degrees.
1998
2254
  */
1999
2255
  rotateRegionX(regionName, degrees) {
2000
2256
  let functionCleanupArena = new diplomatRuntime.CleanupArena();
@@ -2021,9 +2277,8 @@ export class Schematic {
2021
2277
  }
2022
2278
 
2023
2279
  /**
2024
- * Rotate a named region about the Y axis by a multiple of 90 degrees
2025
- * (same semantics as `rotate_y`). `NotFound` if no region has that
2026
- * name.
2280
+ * Rotate a named region clockwise about the Y axis by a multiple of
2281
+ * 90 degrees.
2027
2282
  */
2028
2283
  rotateRegionY(regionName, degrees) {
2029
2284
  let functionCleanupArena = new diplomatRuntime.CleanupArena();
@@ -2050,9 +2305,7 @@ export class Schematic {
2050
2305
  }
2051
2306
 
2052
2307
  /**
2053
- * Rotate a named region about the Z axis by a multiple of 90 degrees
2054
- * (same semantics as `rotate_z`). `NotFound` if no region has that
2055
- * name.
2308
+ * Rotate a named region about the Z axis by a multiple of 90 degrees.
2056
2309
  */
2057
2310
  rotateRegionZ(regionName, degrees) {
2058
2311
  let functionCleanupArena = new diplomatRuntime.CleanupArena();
@@ -2078,6 +2331,187 @@ export class Schematic {
2078
2331
  }
2079
2332
  }
2080
2333
 
2334
+ /**
2335
+ * Move one named region without affecting its siblings.
2336
+ */
2337
+ translateRegion(regionName, dx, dy, dz) {
2338
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
2339
+
2340
+ const regionNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, regionName)));
2341
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
2342
+
2343
+
2344
+ const result = wasm.Schematic_translate_region(diplomatReceive.buffer, this.ffiValue, regionNameSlice.ptr, dx, dy, dz);
2345
+
2346
+ try {
2347
+ if (!diplomatReceive.resultFlag) {
2348
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
2349
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
2350
+ }
2351
+ }
2352
+
2353
+ finally {
2354
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
2355
+ functionCleanupArena.free();
2356
+
2357
+ diplomatReceive.free();
2358
+ }
2359
+ }
2360
+
2361
+ /**
2362
+ * Rotate every region as one rigid schematic around the shared bounds.
2363
+ */
2364
+ rotateSchematicX(degrees) {
2365
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
2366
+
2367
+
2368
+ const result = wasm.Schematic_rotate_schematic_x(diplomatReceive.buffer, this.ffiValue, degrees);
2369
+
2370
+ try {
2371
+ if (!diplomatReceive.resultFlag) {
2372
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
2373
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
2374
+ }
2375
+ }
2376
+
2377
+ finally {
2378
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
2379
+ diplomatReceive.free();
2380
+ }
2381
+ }
2382
+
2383
+ /**
2384
+ * Rotate every region as one rigid schematic around the shared bounds.
2385
+ */
2386
+ rotateSchematicY(degrees) {
2387
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
2388
+
2389
+
2390
+ const result = wasm.Schematic_rotate_schematic_y(diplomatReceive.buffer, this.ffiValue, degrees);
2391
+
2392
+ try {
2393
+ if (!diplomatReceive.resultFlag) {
2394
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
2395
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
2396
+ }
2397
+ }
2398
+
2399
+ finally {
2400
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
2401
+ diplomatReceive.free();
2402
+ }
2403
+ }
2404
+
2405
+ /**
2406
+ * Rotate every region as one rigid schematic around the shared bounds.
2407
+ */
2408
+ rotateSchematicZ(degrees) {
2409
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
2410
+
2411
+
2412
+ const result = wasm.Schematic_rotate_schematic_z(diplomatReceive.buffer, this.ffiValue, degrees);
2413
+
2414
+ try {
2415
+ if (!diplomatReceive.resultFlag) {
2416
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
2417
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
2418
+ }
2419
+ }
2420
+
2421
+ finally {
2422
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
2423
+ diplomatReceive.free();
2424
+ }
2425
+ }
2426
+
2427
+ /**
2428
+ * Mirror every region across the shared schematic X bounds.
2429
+ */
2430
+ flipSchematicX() {
2431
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
2432
+
2433
+
2434
+ const result = wasm.Schematic_flip_schematic_x(diplomatReceive.buffer, this.ffiValue);
2435
+
2436
+ try {
2437
+ if (!diplomatReceive.resultFlag) {
2438
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
2439
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
2440
+ }
2441
+ }
2442
+
2443
+ finally {
2444
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
2445
+ diplomatReceive.free();
2446
+ }
2447
+ }
2448
+
2449
+ /**
2450
+ * Mirror every region across the shared schematic Y bounds.
2451
+ */
2452
+ flipSchematicY() {
2453
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
2454
+
2455
+
2456
+ const result = wasm.Schematic_flip_schematic_y(diplomatReceive.buffer, this.ffiValue);
2457
+
2458
+ try {
2459
+ if (!diplomatReceive.resultFlag) {
2460
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
2461
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
2462
+ }
2463
+ }
2464
+
2465
+ finally {
2466
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
2467
+ diplomatReceive.free();
2468
+ }
2469
+ }
2470
+
2471
+ /**
2472
+ * Mirror every region across the shared schematic Z bounds.
2473
+ */
2474
+ flipSchematicZ() {
2475
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
2476
+
2477
+
2478
+ const result = wasm.Schematic_flip_schematic_z(diplomatReceive.buffer, this.ffiValue);
2479
+
2480
+ try {
2481
+ if (!diplomatReceive.resultFlag) {
2482
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
2483
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
2484
+ }
2485
+ }
2486
+
2487
+ finally {
2488
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
2489
+ diplomatReceive.free();
2490
+ }
2491
+ }
2492
+
2493
+ /**
2494
+ * Move every region by the same delta, preserving their relative layout.
2495
+ */
2496
+ translateSchematic(dx, dy, dz) {
2497
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
2498
+
2499
+
2500
+ const result = wasm.Schematic_translate_schematic(diplomatReceive.buffer, this.ffiValue, dx, dy, dz);
2501
+
2502
+ try {
2503
+ if (!diplomatReceive.resultFlag) {
2504
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
2505
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
2506
+ }
2507
+ }
2508
+
2509
+ finally {
2510
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
2511
+ diplomatReceive.free();
2512
+ }
2513
+ }
2514
+
2081
2515
  /**
2082
2516
  * Fill a cuboid with a block.
2083
2517
  */
@@ -2282,6 +2716,116 @@ export class Schematic {
2282
2716
  }
2283
2717
  }
2284
2718
 
2719
+ /**
2720
+ * Whether a default or named schematic region exists.
2721
+ */
2722
+ hasRegion(regionName) {
2723
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
2724
+
2725
+ const regionNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, regionName)));
2726
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 1, true);
2727
+
2728
+
2729
+ const result = wasm.Schematic_has_region(diplomatReceive.buffer, this.ffiValue, regionNameSlice.ptr);
2730
+
2731
+ try {
2732
+ if (!diplomatReceive.resultFlag) {
2733
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
2734
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
2735
+ }
2736
+ return (new Uint8Array(wasm.memory.buffer, diplomatReceive.buffer, 1))[0] === 1;
2737
+ }
2738
+
2739
+ finally {
2740
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
2741
+ functionCleanupArena.free();
2742
+
2743
+ diplomatReceive.free();
2744
+ }
2745
+ }
2746
+
2747
+ /**
2748
+ * Create an empty named region. Its first block anchors its bounds.
2749
+ */
2750
+ createRegion(regionName) {
2751
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
2752
+
2753
+ const regionNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, regionName)));
2754
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
2755
+
2756
+
2757
+ const result = wasm.Schematic_create_region(diplomatReceive.buffer, this.ffiValue, regionNameSlice.ptr);
2758
+
2759
+ try {
2760
+ if (!diplomatReceive.resultFlag) {
2761
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
2762
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
2763
+ }
2764
+ }
2765
+
2766
+ finally {
2767
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
2768
+ functionCleanupArena.free();
2769
+
2770
+ diplomatReceive.free();
2771
+ }
2772
+ }
2773
+
2774
+ /**
2775
+ * Remove a named region. The default region cannot be removed.
2776
+ */
2777
+ removeRegion(regionName) {
2778
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
2779
+
2780
+ const regionNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, regionName)));
2781
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
2782
+
2783
+
2784
+ const result = wasm.Schematic_remove_region(diplomatReceive.buffer, this.ffiValue, regionNameSlice.ptr);
2785
+
2786
+ try {
2787
+ if (!diplomatReceive.resultFlag) {
2788
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
2789
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
2790
+ }
2791
+ }
2792
+
2793
+ finally {
2794
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
2795
+ functionCleanupArena.free();
2796
+
2797
+ diplomatReceive.free();
2798
+ }
2799
+ }
2800
+
2801
+ /**
2802
+ * Rename a named region. The default region cannot be renamed.
2803
+ */
2804
+ renameRegion(oldName, newName) {
2805
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
2806
+
2807
+ const oldNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, oldName)));
2808
+ const newNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, newName)));
2809
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
2810
+
2811
+
2812
+ const result = wasm.Schematic_rename_region(diplomatReceive.buffer, this.ffiValue, oldNameSlice.ptr, newNameSlice.ptr);
2813
+
2814
+ try {
2815
+ if (!diplomatReceive.resultFlag) {
2816
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
2817
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
2818
+ }
2819
+ }
2820
+
2821
+ finally {
2822
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
2823
+ functionCleanupArena.free();
2824
+
2825
+ diplomatReceive.free();
2826
+ }
2827
+ }
2828
+
2285
2829
  /**
2286
2830
  * The schematic bounding box as a JSON array
2287
2831
  * `[min_x, min_y, min_z, max_x, max_y, max_z]`.