-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I like the idea of being able to loop over the data using iterators, it seems like it could be a cool use case to find a certain chunk at a given index, things like that. You could do `BedrockRegion.find(x,y)` for a given Chunk, and it would give you either a Chunk object, or `null`. Something neat like that.
- Loading branch information
1 parent
9b39bd3
commit 9372efd
Showing
5 changed files
with
79 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
{ | ||
"dependencies": { | ||
"nbtify": "^1.20.1" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^18.16.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { readFile } from "node:fs/promises"; | ||
import { BedrockWorld } from "./index.js"; | ||
|
||
// Reads the world save as a single file from the file system. | ||
const buffer: Buffer = await readFile("./Survival-World.mcworld"); | ||
|
||
// Creates a 'world object' from that world file binary data. | ||
const world: BedrockWorld = new BedrockWorld(buffer); | ||
|
||
// Could be neat if you could just use a simple 'for' loop to iterate over all the Regions in the world. | ||
for (const region of world){ | ||
// You could then also go over each chunk in those regions, maybe. | ||
for (const chunk of region){ | ||
// 'Version' would be referencing one of the chunk's NBT header values. This is already something used by the game. | ||
console.log(chunk.Version); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"compilerOptions": { | ||
"rootDir": "./src", | ||
"outDir": "./dist", | ||
"module": "ESNext", | ||
"moduleResolution": "NodeNext", | ||
"target": "ESNext", | ||
"strict": true, | ||
"noImplicitOverride": true | ||
} | ||
} |