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/ItemScale.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
|
|
3
|
+
|
|
4
|
+
export type ItemScale_obj = {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
z: number;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Non-uniform model scale factors.
|
|
14
|
+
*/
|
|
15
|
+
export class ItemScale {
|
|
16
|
+
get x(): number;
|
|
17
|
+
set x(value: number);
|
|
18
|
+
get y(): number;
|
|
19
|
+
set y(value: number);
|
|
20
|
+
get z(): number;
|
|
21
|
+
set z(value: number);
|
|
22
|
+
/** @internal */
|
|
23
|
+
static fromFields(structObj : ItemScale_obj) : ItemScale;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Create `ItemScale` from an object that contains all of `ItemScale`s fields.
|
|
27
|
+
* Optional fields do not need to be included in the provided object.
|
|
28
|
+
*/
|
|
29
|
+
constructor(structObj: ItemScale_obj);
|
|
30
|
+
|
|
31
|
+
}
|
package/ItemScale.mjs
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import wasm from "./diplomat-wasm.mjs";
|
|
3
|
+
import * as diplomatRuntime from "./diplomat-runtime.mjs";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Non-uniform model scale factors.
|
|
9
|
+
*/
|
|
10
|
+
export class ItemScale {
|
|
11
|
+
#x;
|
|
12
|
+
get x() {
|
|
13
|
+
return this.#x;
|
|
14
|
+
}
|
|
15
|
+
set x(value){
|
|
16
|
+
this.#x = value;
|
|
17
|
+
}
|
|
18
|
+
#y;
|
|
19
|
+
get y() {
|
|
20
|
+
return this.#y;
|
|
21
|
+
}
|
|
22
|
+
set y(value){
|
|
23
|
+
this.#y = value;
|
|
24
|
+
}
|
|
25
|
+
#z;
|
|
26
|
+
get z() {
|
|
27
|
+
return this.#z;
|
|
28
|
+
}
|
|
29
|
+
set z(value){
|
|
30
|
+
this.#z = value;
|
|
31
|
+
}
|
|
32
|
+
/** @internal */
|
|
33
|
+
static fromFields(structObj) {
|
|
34
|
+
return new ItemScale(structObj);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
#internalConstructor(structObj) {
|
|
38
|
+
if (typeof structObj !== "object") {
|
|
39
|
+
throw new Error("ItemScale's constructor takes an object of ItemScale's fields.");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if ("x" in structObj) {
|
|
43
|
+
this.#x = structObj.x;
|
|
44
|
+
} else {
|
|
45
|
+
throw new Error("Missing required field x.");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if ("y" in structObj) {
|
|
49
|
+
this.#y = structObj.y;
|
|
50
|
+
} else {
|
|
51
|
+
throw new Error("Missing required field y.");
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if ("z" in structObj) {
|
|
55
|
+
this.#z = structObj.z;
|
|
56
|
+
} else {
|
|
57
|
+
throw new Error("Missing required field z.");
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Return this struct in FFI function friendly format.
|
|
64
|
+
// Returns an array that can be expanded with spread syntax (...)
|
|
65
|
+
_intoFFI(
|
|
66
|
+
dst,
|
|
67
|
+
functionCleanupArena,
|
|
68
|
+
appendArrayMap
|
|
69
|
+
) {
|
|
70
|
+
|
|
71
|
+
this._writeToArrayBuffer(wasm.memory.buffer, dst, functionCleanupArena, appendArrayMap);
|
|
72
|
+
|
|
73
|
+
return dst;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
static get _sizeBytes() {
|
|
77
|
+
return 12;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/// Currently unused, we may want to use later on though:
|
|
81
|
+
static get _sizeAlign() {
|
|
82
|
+
return 4;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
static _fromSuppliedValue(internalConstructor, obj) {
|
|
86
|
+
if (internalConstructor !== diplomatRuntime.internalConstructor) {
|
|
87
|
+
throw new Error("_fromSuppliedValue cannot be called externally.");
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (obj instanceof ItemScale) {
|
|
91
|
+
return obj;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return ItemScale.fromFields(obj);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
_writeToArrayBuffer(
|
|
98
|
+
arrayBuffer,
|
|
99
|
+
offset,
|
|
100
|
+
functionCleanupArena,
|
|
101
|
+
appendArrayMap
|
|
102
|
+
) {
|
|
103
|
+
diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, this.#x, Float32Array);
|
|
104
|
+
diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 4, this.#y, Float32Array);
|
|
105
|
+
diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 8, this.#z, Float32Array);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// This struct contains borrowed fields, so this takes in a list of
|
|
109
|
+
// "edges" corresponding to where each lifetime's data may have been borrowed from
|
|
110
|
+
// and passes it down to individual fields containing the borrow.
|
|
111
|
+
// This method does not attempt to handle any dependencies between lifetimes, the caller
|
|
112
|
+
// should handle this when constructing edge arrays.
|
|
113
|
+
static _fromFFI(internalConstructor, ptr) {
|
|
114
|
+
if (internalConstructor !== diplomatRuntime.internalConstructor) {
|
|
115
|
+
throw new Error("ItemScale._fromFFI is not meant to be called externally. Please use the default constructor.");
|
|
116
|
+
}
|
|
117
|
+
let structObj = {};
|
|
118
|
+
const xDeref = (new Float32Array(wasm.memory.buffer, ptr, 1))[0];
|
|
119
|
+
structObj.x = xDeref;
|
|
120
|
+
const yDeref = (new Float32Array(wasm.memory.buffer, ptr + 4, 1))[0];
|
|
121
|
+
structObj.y = yDeref;
|
|
122
|
+
const zDeref = (new Float32Array(wasm.memory.buffer, ptr + 8, 1))[0];
|
|
123
|
+
structObj.z = zDeref;
|
|
124
|
+
|
|
125
|
+
return new ItemScale(structObj);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
constructor(structObj) {
|
|
130
|
+
return this.#internalConstructor(...arguments)
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import type { NucleationError } from "./NucleationError"
|
|
3
|
+
import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Maps logical bits to physical positions (PORTING rule 10).
|
|
9
|
+
*/
|
|
10
|
+
export class LayoutFunction {
|
|
11
|
+
/** @internal */
|
|
12
|
+
get ffiValue(): pointer;
|
|
13
|
+
/** @internal */
|
|
14
|
+
constructor();
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* One bit per position: signal strength 0 = false, 15 = true.
|
|
19
|
+
* The most common layout for traditional redstone circuits.
|
|
20
|
+
*/
|
|
21
|
+
static oneToOne(): LayoutFunction;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Four bits per position, packed as a hex nibble (0-15) with the
|
|
25
|
+
* lowest bit first; uses `ceil(bits / 4)` positions (4x denser than
|
|
26
|
+
* one-to-one).
|
|
27
|
+
*/
|
|
28
|
+
static packed4(): LayoutFunction;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Custom bit-to-position mapping.
|
|
32
|
+
*/
|
|
33
|
+
static custom(mapping: Array<number>): LayoutFunction;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 2D matrix layout, elements laid out row by row; element bits are
|
|
37
|
+
* packed 4 per position (nibbles).
|
|
38
|
+
*/
|
|
39
|
+
static rowMajor(rows: number, cols: number, bitsPerElement: number): LayoutFunction;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 2D matrix layout, elements laid out column by column; element bits
|
|
43
|
+
* are packed 4 per position (nibbles).
|
|
44
|
+
*/
|
|
45
|
+
static columnMajor(rows: number, cols: number, bitsPerElement: number): LayoutFunction;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Screen layout: pixels laid out row by row, left to right; pixel
|
|
49
|
+
* bits are packed 4 per position (nibbles).
|
|
50
|
+
*/
|
|
51
|
+
static scanline(width: number, height: number, bitsPerPixel: number): LayoutFunction;
|
|
52
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import { NucleationError } from "./NucleationError.mjs"
|
|
3
|
+
import wasm from "./diplomat-wasm.mjs";
|
|
4
|
+
import * as diplomatRuntime from "./diplomat-runtime.mjs";
|
|
5
|
+
|
|
6
|
+
const LayoutFunction_box_destroy_registry = new FinalizationRegistry((ptr) => {
|
|
7
|
+
wasm.LayoutFunction_destroy(ptr);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Maps logical bits to physical positions (PORTING rule 10).
|
|
12
|
+
*/
|
|
13
|
+
export class LayoutFunction {
|
|
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("LayoutFunction 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
|
+
LayoutFunction_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
|
+
* One bit per position: signal strength 0 = false, 15 = true.
|
|
44
|
+
* The most common layout for traditional redstone circuits.
|
|
45
|
+
*/
|
|
46
|
+
static oneToOne() {
|
|
47
|
+
|
|
48
|
+
const result = wasm.LayoutFunction_one_to_one();
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
return new LayoutFunction(diplomatRuntime.internalConstructor, result, []);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
finally {
|
|
55
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Four bits per position, packed as a hex nibble (0-15) with the
|
|
61
|
+
* lowest bit first; uses `ceil(bits / 4)` positions (4x denser than
|
|
62
|
+
* one-to-one).
|
|
63
|
+
*/
|
|
64
|
+
static packed4() {
|
|
65
|
+
|
|
66
|
+
const result = wasm.LayoutFunction_packed4();
|
|
67
|
+
|
|
68
|
+
try {
|
|
69
|
+
return new LayoutFunction(diplomatRuntime.internalConstructor, result, []);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
finally {
|
|
73
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Custom bit-to-position mapping.
|
|
79
|
+
*/
|
|
80
|
+
static custom(mapping) {
|
|
81
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
82
|
+
|
|
83
|
+
const mappingSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.slice(wasm, mapping, "u32")));
|
|
84
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
const result = wasm.LayoutFunction_custom(diplomatReceive.buffer, mappingSlice.ptr);
|
|
88
|
+
|
|
89
|
+
try {
|
|
90
|
+
if (!diplomatReceive.resultFlag) {
|
|
91
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
92
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
93
|
+
}
|
|
94
|
+
return new LayoutFunction(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
finally {
|
|
98
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
99
|
+
functionCleanupArena.free();
|
|
100
|
+
|
|
101
|
+
diplomatReceive.free();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* 2D matrix layout, elements laid out row by row; element bits are
|
|
107
|
+
* packed 4 per position (nibbles).
|
|
108
|
+
*/
|
|
109
|
+
static rowMajor(rows, cols, bitsPerElement) {
|
|
110
|
+
|
|
111
|
+
const result = wasm.LayoutFunction_row_major(rows, cols, bitsPerElement);
|
|
112
|
+
|
|
113
|
+
try {
|
|
114
|
+
return new LayoutFunction(diplomatRuntime.internalConstructor, result, []);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
finally {
|
|
118
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* 2D matrix layout, elements laid out column by column; element bits
|
|
124
|
+
* are packed 4 per position (nibbles).
|
|
125
|
+
*/
|
|
126
|
+
static columnMajor(rows, cols, bitsPerElement) {
|
|
127
|
+
|
|
128
|
+
const result = wasm.LayoutFunction_column_major(rows, cols, bitsPerElement);
|
|
129
|
+
|
|
130
|
+
try {
|
|
131
|
+
return new LayoutFunction(diplomatRuntime.internalConstructor, result, []);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
finally {
|
|
135
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Screen layout: pixels laid out row by row, left to right; pixel
|
|
141
|
+
* bits are packed 4 per position (nibbles).
|
|
142
|
+
*/
|
|
143
|
+
static scanline(width, height, bitsPerPixel) {
|
|
144
|
+
|
|
145
|
+
const result = wasm.LayoutFunction_scanline(width, height, bitsPerPixel);
|
|
146
|
+
|
|
147
|
+
try {
|
|
148
|
+
return new LayoutFunction(diplomatRuntime.internalConstructor, result, []);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
finally {
|
|
152
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
constructor(symbol, ptr, selfEdge) {
|
|
157
|
+
return this.#internalConstructor(...arguments)
|
|
158
|
+
}
|
|
159
|
+
}
|
package/MchprsWorld.d.ts
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import type { NucleationError } from "./NucleationError"
|
|
3
|
+
import type { RedstoneGraph } from "./RedstoneGraph"
|
|
4
|
+
import type { Schematic } from "./Schematic"
|
|
5
|
+
import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A running MCHPRS redstone simulation. Wraps {@link crate::simulation::MchprsWorld}.
|
|
11
|
+
*/
|
|
12
|
+
export class MchprsWorld {
|
|
13
|
+
/** @internal */
|
|
14
|
+
get ffiValue(): pointer;
|
|
15
|
+
/** @internal */
|
|
16
|
+
constructor();
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Create a simulation world from a schematic with default options.
|
|
21
|
+
*/
|
|
22
|
+
static create(schematic: Schematic): MchprsWorld;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Create a simulation world with explicit options.
|
|
26
|
+
*/
|
|
27
|
+
static createWithOptions(schematic: Schematic, optimize: boolean, ioOnly: boolean): MchprsWorld;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Create a simulation world with custom IO positions
|
|
31
|
+
* (`custom_io_positions` is flat `[x,y,z, x,y,z, ...]`).
|
|
32
|
+
*/
|
|
33
|
+
static createWithCustomIo(schematic: Schematic, optimize: boolean, ioOnly: boolean, customIoPositions: Array<number>): MchprsWorld;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* One-shot convenience (old ABI: `schematic_simulate_use_block`):
|
|
37
|
+
* build a world from `schematic`, fire an `on_use_block` event per
|
|
38
|
+
* triple in `events_xyz`, run `ticks` ticks, and return the simulated
|
|
39
|
+
* schematic. Unlike the old ABI (which mutated in place), this returns
|
|
40
|
+
* a new `Schematic`.
|
|
41
|
+
*/
|
|
42
|
+
static simulateUseBlock(schematic: Schematic, ticks: number, eventsXyz: Array<number>): Schematic;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Advance the simulation by `ticks` ticks.
|
|
46
|
+
*/
|
|
47
|
+
tick(ticks: number): void;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Flush pending changes from the compiler to the world.
|
|
51
|
+
*/
|
|
52
|
+
flush(): void;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Set the power state of a lever.
|
|
56
|
+
*/
|
|
57
|
+
setLeverPower(x: number, y: number, z: number, powered: boolean): void;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Get the power state of a lever.
|
|
61
|
+
*/
|
|
62
|
+
getLeverPower(x: number, y: number, z: number): boolean;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Whether a redstone lamp is lit at the given position.
|
|
66
|
+
*/
|
|
67
|
+
isLit(x: number, y: number, z: number): boolean;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Set the signal strength (0-15) at a custom IO position.
|
|
71
|
+
*/
|
|
72
|
+
setSignalStrength(x: number, y: number, z: number, strength: number): void;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Get the signal strength (0-15) at a position.
|
|
76
|
+
*/
|
|
77
|
+
getSignalStrength(x: number, y: number, z: number): number;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Simulate a right-click on a block (typically a lever).
|
|
81
|
+
*/
|
|
82
|
+
onUseBlock(x: number, y: number, z: number): void;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Sync the simulation state back to the internal schematic.
|
|
86
|
+
*/
|
|
87
|
+
syncToSchematic(): void;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* A clone of the world's schematic.
|
|
91
|
+
*/
|
|
92
|
+
getSchematic(): Schematic;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The redstone power level (0-15) at a position.
|
|
96
|
+
*/
|
|
97
|
+
getRedstonePower(x: number, y: number, z: number): number;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Check for custom IO changes since the last check. Call before
|
|
101
|
+
* `poll_custom_io_changes_json`.
|
|
102
|
+
*/
|
|
103
|
+
checkCustomIoChanges(): void;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Queued custom IO changes as a JSON array
|
|
107
|
+
* (`[{"x":..,"y":..,"z":..,"old_power":..,"new_power":..}, ...]`),
|
|
108
|
+
* clearing the queue.
|
|
109
|
+
*/
|
|
110
|
+
pollCustomIoChangesJson(): string;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Queued custom IO changes as JSON without clearing the queue.
|
|
114
|
+
*/
|
|
115
|
+
peekCustomIoChangesJson(): string;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Clear all queued custom IO changes.
|
|
119
|
+
*/
|
|
120
|
+
clearCustomIoChanges(): void;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Extract the compiled (post-optimization) redstone logic graph.
|
|
124
|
+
*/
|
|
125
|
+
exportGraph(): RedstoneGraph;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Extract the structural (pre-fold, as-built) redstone logic graph.
|
|
129
|
+
*/
|
|
130
|
+
exportGraphStructural(): RedstoneGraph;
|
|
131
|
+
}
|