fix: save litematic - can't convert BigInt to number
This commit is contained in:
parent
20cf42180e
commit
41b937659d
1 changed files with 3 additions and 3 deletions
|
|
@ -84,15 +84,15 @@ function SaveLitematic({ close, registerSubmit, dialogKeyHandler }: DialogProps)
|
||||||
});
|
});
|
||||||
const blockId = BigInt(blockIndex);
|
const blockId = BigInt(blockIndex);
|
||||||
|
|
||||||
const reversedY = height - 1 - block.y;
|
const reversedY = height - 1 - (block.y - canvasSize.minY);
|
||||||
const index = reversedY * width + block.x;
|
const index = reversedY * width + (block.x - canvasSize.minX);
|
||||||
|
|
||||||
// setAt() implementation - LitematicaBitArray.java
|
// setAt() implementation - LitematicaBitArray.java
|
||||||
const startOffset = index * requiredBits;
|
const startOffset = index * requiredBits;
|
||||||
const startArrayIndex = Math.floor(startOffset / 64);
|
const startArrayIndex = Math.floor(startOffset / 64);
|
||||||
const endArrayIndex = ((index + 1) * requiredBits - 1) >> 6;
|
const endArrayIndex = ((index + 1) * requiredBits - 1) >> 6;
|
||||||
const bitOffset = BigInt(startOffset % 64);
|
const bitOffset = BigInt(startOffset % 64);
|
||||||
const mask = BigInt((1 << requiredBits) - 1);
|
const mask = (1n << BigInt(requiredBits)) - 1n;
|
||||||
|
|
||||||
blockStates[startArrayIndex] = (blockStates[startArrayIndex] & ~(mask << bitOffset)) | ((blockId & mask) << bitOffset);
|
blockStates[startArrayIndex] = (blockStates[startArrayIndex] & ~(mask << bitOffset)) | ((blockId & mask) << bitOffset);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue