nucleation 0.1.79 → 0.1.81

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -105,6 +105,25 @@ simWorld.flush();
105
105
  const isLit = simWorld.is_lit(15, 1, 0); // Check if lamp is lit
106
106
  ```
107
107
 
108
+ **Custom IO signal injection/monitoring:**
109
+
110
+ ```js
111
+ // Configure custom IO nodes for precise signal control
112
+ const options = new SimulationOptions();
113
+ options.addCustomIo(5, 1, 0); // Mark position as custom IO node
114
+
115
+ const simWorld = schematic.create_simulation_world_with_options(options);
116
+
117
+ // Inject custom signal strength
118
+ simWorld.setSignalStrength(5, 1, 0, 12); // Set signal to 12
119
+ simWorld.tick(5);
120
+ simWorld.flush();
121
+
122
+ // Read signal strength
123
+ const strength = simWorld.getSignalStrength(5, 1, 0);
124
+ console.log(`Signal strength: ${strength}`);
125
+ ```
126
+
108
127
  [More in `examples/wasm.md`](examples/wasm.md)
109
128
 
110
129
  ---
@@ -225,21 +225,16 @@ function getArrayJsValueFromWasm0(ptr, len) {
225
225
  wasm.__externref_drop_slice(ptr, len);
226
226
  return result;
227
227
  }
228
-
229
- export function start() {
230
- wasm.start();
231
- }
232
-
233
228
  /**
234
229
  * @param {SchematicWrapper} schematic
235
230
  * @returns {string}
236
231
  */
237
- export function debug_json_schematic(schematic) {
232
+ export function debug_schematic(schematic) {
238
233
  let deferred1_0;
239
234
  let deferred1_1;
240
235
  try {
241
236
  _assertClass(schematic, SchematicWrapper);
242
- const ret = wasm.debug_json_schematic(schematic.__wbg_ptr);
237
+ const ret = wasm.debug_schematic(schematic.__wbg_ptr);
243
238
  deferred1_0 = ret[0];
244
239
  deferred1_1 = ret[1];
245
240
  return getStringFromWasm0(ret[0], ret[1]);
@@ -248,16 +243,20 @@ export function debug_json_schematic(schematic) {
248
243
  }
249
244
  }
250
245
 
246
+ export function start() {
247
+ wasm.start();
248
+ }
249
+
251
250
  /**
252
251
  * @param {SchematicWrapper} schematic
253
252
  * @returns {string}
254
253
  */
255
- export function debug_schematic(schematic) {
254
+ export function debug_json_schematic(schematic) {
256
255
  let deferred1_0;
257
256
  let deferred1_1;
258
257
  try {
259
258
  _assertClass(schematic, SchematicWrapper);
260
- const ret = wasm.debug_schematic(schematic.__wbg_ptr);
259
+ const ret = wasm.debug_json_schematic(schematic.__wbg_ptr);
261
260
  deferred1_0 = ret[0];
262
261
  deferred1_1 = ret[1];
263
262
  return getStringFromWasm0(ret[0], ret[1]);
@@ -584,6 +583,27 @@ export class MchprsWorldWrapper {
584
583
  const ret = wasm.mchprsworldwrapper_get_redstone_power(this.__wbg_ptr, x, y, z);
585
584
  return ret;
586
585
  }
586
+ /**
587
+ * Gets the signal strength at a specific block position (for custom IO nodes)
588
+ * @param {number} x
589
+ * @param {number} y
590
+ * @param {number} z
591
+ * @returns {number}
592
+ */
593
+ getSignalStrength(x, y, z) {
594
+ const ret = wasm.mchprsworldwrapper_getSignalStrength(this.__wbg_ptr, x, y, z);
595
+ return ret;
596
+ }
597
+ /**
598
+ * Sets the signal strength at a specific block position (for custom IO nodes)
599
+ * @param {number} x
600
+ * @param {number} y
601
+ * @param {number} z
602
+ * @param {number} strength
603
+ */
604
+ setSignalStrength(x, y, z, strength) {
605
+ wasm.mchprsworldwrapper_setSignalStrength(this.__wbg_ptr, x, y, z, strength);
606
+ }
587
607
  /**
588
608
  * @param {SchematicWrapper} schematic
589
609
  */
@@ -722,6 +742,42 @@ export class SchematicWrapper {
722
742
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
723
743
  return v1;
724
744
  }
745
+ /**
746
+ * Flip a specific region along the X axis
747
+ * @param {string} region_name
748
+ */
749
+ flip_region_x(region_name) {
750
+ const ptr0 = passStringToWasm0(region_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
751
+ const len0 = WASM_VECTOR_LEN;
752
+ const ret = wasm.schematicwrapper_flip_region_x(this.__wbg_ptr, ptr0, len0);
753
+ if (ret[1]) {
754
+ throw takeFromExternrefTable0(ret[0]);
755
+ }
756
+ }
757
+ /**
758
+ * Flip a specific region along the Y axis
759
+ * @param {string} region_name
760
+ */
761
+ flip_region_y(region_name) {
762
+ const ptr0 = passStringToWasm0(region_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
763
+ const len0 = WASM_VECTOR_LEN;
764
+ const ret = wasm.schematicwrapper_flip_region_y(this.__wbg_ptr, ptr0, len0);
765
+ if (ret[1]) {
766
+ throw takeFromExternrefTable0(ret[0]);
767
+ }
768
+ }
769
+ /**
770
+ * Flip a specific region along the Z axis
771
+ * @param {string} region_name
772
+ */
773
+ flip_region_z(region_name) {
774
+ const ptr0 = passStringToWasm0(region_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
775
+ const len0 = WASM_VECTOR_LEN;
776
+ const ret = wasm.schematicwrapper_flip_region_z(this.__wbg_ptr, ptr0, len0);
777
+ if (ret[1]) {
778
+ throw takeFromExternrefTable0(ret[0]);
779
+ }
780
+ }
725
781
  /**
726
782
  * All blocks as palette indices - for when you need everything at once but efficiently
727
783
  * Returns array of [x, y, z, palette_index]
@@ -796,6 +852,45 @@ export class SchematicWrapper {
796
852
  wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
797
853
  }
798
854
  }
855
+ /**
856
+ * Rotate a specific region around the X axis
857
+ * @param {string} region_name
858
+ * @param {number} degrees
859
+ */
860
+ rotate_region_x(region_name, degrees) {
861
+ const ptr0 = passStringToWasm0(region_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
862
+ const len0 = WASM_VECTOR_LEN;
863
+ const ret = wasm.schematicwrapper_rotate_region_x(this.__wbg_ptr, ptr0, len0, degrees);
864
+ if (ret[1]) {
865
+ throw takeFromExternrefTable0(ret[0]);
866
+ }
867
+ }
868
+ /**
869
+ * Rotate a specific region around the Y axis
870
+ * @param {string} region_name
871
+ * @param {number} degrees
872
+ */
873
+ rotate_region_y(region_name, degrees) {
874
+ const ptr0 = passStringToWasm0(region_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
875
+ const len0 = WASM_VECTOR_LEN;
876
+ const ret = wasm.schematicwrapper_rotate_region_y(this.__wbg_ptr, ptr0, len0, degrees);
877
+ if (ret[1]) {
878
+ throw takeFromExternrefTable0(ret[0]);
879
+ }
880
+ }
881
+ /**
882
+ * Rotate a specific region around the Z axis
883
+ * @param {string} region_name
884
+ * @param {number} degrees
885
+ */
886
+ rotate_region_z(region_name, degrees) {
887
+ const ptr0 = passStringToWasm0(region_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
888
+ const len0 = WASM_VECTOR_LEN;
889
+ const ret = wasm.schematicwrapper_rotate_region_z(this.__wbg_ptr, ptr0, len0, degrees);
890
+ if (ret[1]) {
891
+ throw takeFromExternrefTable0(ret[0]);
892
+ }
893
+ }
799
894
  /**
800
895
  * Get all palettes once - eliminates repeated string transfers
801
896
  * Returns: { default: [BlockState], regions: { regionName: [BlockState] } }
@@ -1064,6 +1159,48 @@ export class SchematicWrapper {
1064
1159
  const ret = wasm.schematicwrapper_chunks(this.__wbg_ptr, chunk_width, chunk_height, chunk_length);
1065
1160
  return ret;
1066
1161
  }
1162
+ /**
1163
+ * Flip the schematic along the X axis
1164
+ */
1165
+ flip_x() {
1166
+ wasm.schematicwrapper_flip_x(this.__wbg_ptr);
1167
+ }
1168
+ /**
1169
+ * Flip the schematic along the Y axis
1170
+ */
1171
+ flip_y() {
1172
+ wasm.schematicwrapper_flip_y(this.__wbg_ptr);
1173
+ }
1174
+ /**
1175
+ * Flip the schematic along the Z axis
1176
+ */
1177
+ flip_z() {
1178
+ wasm.schematicwrapper_flip_z(this.__wbg_ptr);
1179
+ }
1180
+ /**
1181
+ * Rotate the schematic around the X axis
1182
+ * Degrees must be 90, 180, or 270
1183
+ * @param {number} degrees
1184
+ */
1185
+ rotate_x(degrees) {
1186
+ wasm.schematicwrapper_rotate_x(this.__wbg_ptr, degrees);
1187
+ }
1188
+ /**
1189
+ * Rotate the schematic around the Y axis (horizontal plane)
1190
+ * Degrees must be 90, 180, or 270
1191
+ * @param {number} degrees
1192
+ */
1193
+ rotate_y(degrees) {
1194
+ wasm.schematicwrapper_rotate_y(this.__wbg_ptr, degrees);
1195
+ }
1196
+ /**
1197
+ * Rotate the schematic around the Z axis
1198
+ * Degrees must be 90, 180, or 270
1199
+ * @param {number} degrees
1200
+ */
1201
+ rotate_z(degrees) {
1202
+ wasm.schematicwrapper_rotate_z(this.__wbg_ptr, degrees);
1203
+ }
1067
1204
  /**
1068
1205
  * @param {Uint8Array} data
1069
1206
  */
@@ -1133,6 +1270,21 @@ export class SimulationOptionsWrapper {
1133
1270
  set optimize(value) {
1134
1271
  wasm.simulationoptionswrapper_set_optimize(this.__wbg_ptr, value);
1135
1272
  }
1273
+ /**
1274
+ * Adds a position to the custom IO list
1275
+ * @param {number} x
1276
+ * @param {number} y
1277
+ * @param {number} z
1278
+ */
1279
+ addCustomIo(x, y, z) {
1280
+ wasm.simulationoptionswrapper_addCustomIo(this.__wbg_ptr, x, y, z);
1281
+ }
1282
+ /**
1283
+ * Clears the custom IO list
1284
+ */
1285
+ clearCustomIo() {
1286
+ wasm.simulationoptionswrapper_clearCustomIo(this.__wbg_ptr);
1287
+ }
1136
1288
  constructor() {
1137
1289
  const ret = wasm.simulationoptionswrapper_new();
1138
1290
  this.__wbg_ptr = ret >>> 0;
package/nucleation.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
+ export function debug_schematic(schematic: SchematicWrapper): string;
3
4
  export function start(): void;
4
5
  export function debug_json_schematic(schematic: SchematicWrapper): string;
5
- export function debug_schematic(schematic: SchematicWrapper): string;
6
6
  export class BlockPosition {
7
7
  free(): void;
8
8
  [Symbol.dispose](): void;
@@ -76,6 +76,14 @@ export class MchprsWorldWrapper {
76
76
  * Gets the redstone power level at a position
77
77
  */
78
78
  get_redstone_power(x: number, y: number, z: number): number;
79
+ /**
80
+ * Gets the signal strength at a specific block position (for custom IO nodes)
81
+ */
82
+ getSignalStrength(x: number, y: number, z: number): number;
83
+ /**
84
+ * Sets the signal strength at a specific block position (for custom IO nodes)
85
+ */
86
+ setSignalStrength(x: number, y: number, z: number, strength: number): void;
79
87
  constructor(schematic: SchematicWrapper);
80
88
  /**
81
89
  * Advances the simulation by the specified number of ticks
@@ -99,6 +107,18 @@ export class SchematicWrapper {
99
107
  get_palette(): any;
100
108
  to_litematic(): Uint8Array;
101
109
  to_schematic(): Uint8Array;
110
+ /**
111
+ * Flip a specific region along the X axis
112
+ */
113
+ flip_region_x(region_name: string): void;
114
+ /**
115
+ * Flip a specific region along the Y axis
116
+ */
117
+ flip_region_y(region_name: string): void;
118
+ /**
119
+ * Flip a specific region along the Z axis
120
+ */
121
+ flip_region_z(region_name: string): void;
102
122
  /**
103
123
  * All blocks as palette indices - for when you need everything at once but efficiently
104
124
  * Returns array of [x, y, z, palette_index]
@@ -114,6 +134,18 @@ export class SchematicWrapper {
114
134
  get_dimensions(): Int32Array;
115
135
  get_block_count(): number;
116
136
  print_schematic(): string;
137
+ /**
138
+ * Rotate a specific region around the X axis
139
+ */
140
+ rotate_region_x(region_name: string, degrees: number): void;
141
+ /**
142
+ * Rotate a specific region around the Y axis
143
+ */
144
+ rotate_region_y(region_name: string, degrees: number): void;
145
+ /**
146
+ * Rotate a specific region around the Z axis
147
+ */
148
+ rotate_region_z(region_name: string, degrees: number): void;
117
149
  /**
118
150
  * Get all palettes once - eliminates repeated string transfers
119
151
  * Returns: { default: [BlockState], regions: { regionName: [BlockState] } }
@@ -165,6 +197,33 @@ export class SchematicWrapper {
165
197
  constructor();
166
198
  blocks(): Array<any>;
167
199
  chunks(chunk_width: number, chunk_height: number, chunk_length: number): Array<any>;
200
+ /**
201
+ * Flip the schematic along the X axis
202
+ */
203
+ flip_x(): void;
204
+ /**
205
+ * Flip the schematic along the Y axis
206
+ */
207
+ flip_y(): void;
208
+ /**
209
+ * Flip the schematic along the Z axis
210
+ */
211
+ flip_z(): void;
212
+ /**
213
+ * Rotate the schematic around the X axis
214
+ * Degrees must be 90, 180, or 270
215
+ */
216
+ rotate_x(degrees: number): void;
217
+ /**
218
+ * Rotate the schematic around the Y axis (horizontal plane)
219
+ * Degrees must be 90, 180, or 270
220
+ */
221
+ rotate_y(degrees: number): void;
222
+ /**
223
+ * Rotate the schematic around the Z axis
224
+ * Degrees must be 90, 180, or 270
225
+ */
226
+ rotate_z(degrees: number): void;
168
227
  from_data(data: Uint8Array): void;
169
228
  get_block(x: number, y: number, z: number): string | undefined;
170
229
  set_block(x: number, y: number, z: number, block_name: string): void;
@@ -172,6 +231,14 @@ export class SchematicWrapper {
172
231
  export class SimulationOptionsWrapper {
173
232
  free(): void;
174
233
  [Symbol.dispose](): void;
234
+ /**
235
+ * Adds a position to the custom IO list
236
+ */
237
+ addCustomIo(x: number, y: number, z: number): void;
238
+ /**
239
+ * Clears the custom IO list
240
+ */
241
+ clearCustomIo(): void;
175
242
  constructor();
176
243
  io_only: boolean;
177
244
  optimize: boolean;
@@ -207,6 +274,7 @@ export interface InitOutput {
207
274
  readonly lazychunkiterator_skip_to: (a: number, b: number) => void;
208
275
  readonly lazychunkiterator_total_chunks: (a: number) => number;
209
276
  readonly mchprsworldwrapper_flush: (a: number) => void;
277
+ readonly mchprsworldwrapper_getSignalStrength: (a: number, b: number, c: number, d: number) => number;
210
278
  readonly mchprsworldwrapper_get_lever_power: (a: number, b: number, c: number, d: number) => number;
211
279
  readonly mchprsworldwrapper_get_redstone_power: (a: number, b: number, c: number, d: number) => number;
212
280
  readonly mchprsworldwrapper_get_schematic: (a: number) => number;
@@ -215,6 +283,7 @@ export interface InitOutput {
215
283
  readonly mchprsworldwrapper_is_lit: (a: number, b: number, c: number, d: number) => number;
216
284
  readonly mchprsworldwrapper_new: (a: number) => [number, number, number];
217
285
  readonly mchprsworldwrapper_on_use_block: (a: number, b: number, c: number, d: number) => void;
286
+ readonly mchprsworldwrapper_setSignalStrength: (a: number, b: number, c: number, d: number, e: number) => void;
218
287
  readonly mchprsworldwrapper_sync_to_schematic: (a: number) => void;
219
288
  readonly mchprsworldwrapper_tick: (a: number, b: number) => void;
220
289
  readonly mchprsworldwrapper_with_options: (a: number, b: number) => [number, number, number];
@@ -227,6 +296,12 @@ export interface InitOutput {
227
296
  readonly schematicwrapper_copy_region: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: any) => [number, number];
228
297
  readonly schematicwrapper_create_lazy_chunk_iterator: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => number;
229
298
  readonly schematicwrapper_debug_info: (a: number) => [number, number];
299
+ readonly schematicwrapper_flip_region_x: (a: number, b: number, c: number) => [number, number];
300
+ readonly schematicwrapper_flip_region_y: (a: number, b: number, c: number) => [number, number];
301
+ readonly schematicwrapper_flip_region_z: (a: number, b: number, c: number) => [number, number];
302
+ readonly schematicwrapper_flip_x: (a: number) => void;
303
+ readonly schematicwrapper_flip_y: (a: number) => void;
304
+ readonly schematicwrapper_flip_z: (a: number) => void;
230
305
  readonly schematicwrapper_from_data: (a: number, b: number, c: number) => [number, number];
231
306
  readonly schematicwrapper_from_litematic: (a: number, b: number, c: number) => [number, number];
232
307
  readonly schematicwrapper_from_schematic: (a: number, b: number, c: number) => [number, number];
@@ -251,11 +326,19 @@ export interface InitOutput {
251
326
  readonly schematicwrapper_get_volume: (a: number) => number;
252
327
  readonly schematicwrapper_new: () => number;
253
328
  readonly schematicwrapper_print_schematic: (a: number) => [number, number];
329
+ readonly schematicwrapper_rotate_region_x: (a: number, b: number, c: number, d: number) => [number, number];
330
+ readonly schematicwrapper_rotate_region_y: (a: number, b: number, c: number, d: number) => [number, number];
331
+ readonly schematicwrapper_rotate_region_z: (a: number, b: number, c: number, d: number) => [number, number];
332
+ readonly schematicwrapper_rotate_x: (a: number, b: number) => void;
333
+ readonly schematicwrapper_rotate_y: (a: number, b: number) => void;
334
+ readonly schematicwrapper_rotate_z: (a: number, b: number) => void;
254
335
  readonly schematicwrapper_set_block: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
255
336
  readonly schematicwrapper_set_block_with_properties: (a: number, b: number, c: number, d: number, e: number, f: number, g: any) => [number, number];
256
337
  readonly schematicwrapper_to_litematic: (a: number) => [number, number, number, number];
257
338
  readonly schematicwrapper_to_schematic: (a: number) => [number, number, number, number];
258
339
  readonly schematicwrapper_to_schematic_version: (a: number, b: number, c: number) => [number, number, number, number];
340
+ readonly simulationoptionswrapper_addCustomIo: (a: number, b: number, c: number, d: number) => void;
341
+ readonly simulationoptionswrapper_clearCustomIo: (a: number) => void;
259
342
  readonly simulationoptionswrapper_io_only: (a: number) => number;
260
343
  readonly simulationoptionswrapper_new: () => number;
261
344
  readonly simulationoptionswrapper_optimize: (a: number) => number;
Binary file
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "Nano nano@schem.at"
6
6
  ],
7
7
  "description": "A high-performance Minecraft schematic parser and utility library",
8
- "version": "0.1.79",
8
+ "version": "0.1.81",
9
9
  "license": "AGPL-3.0-only",
10
10
  "repository": {
11
11
  "type": "git",