https://github.com/misode/deepslate
Library for rendering and emulating parts of Minecraft
https://github.com/misode/deepslate
minecraft nbt webgl
Last synced: about 1 year ago
JSON representation
Library for rendering and emulating parts of Minecraft
- Host: GitHub
- URL: https://github.com/misode/deepslate
- Owner: misode
- License: mit
- Created: 2021-01-03T04:13:04.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-04-22T18:56:37.000Z (about 2 years ago)
- Last Synced: 2024-05-07T11:21:39.074Z (about 2 years ago)
- Topics: minecraft, nbt, webgl
- Language: TypeScript
- Homepage: https://misode.github.io/deepslate/
- Size: 6.66 MB
- Stars: 114
- Watchers: 8
- Forks: 10
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Deepslate
> Library for rendering and emulating parts of Minecraft
## Install
```
npm install deepslate
```
```html
```
## Quick Examples
### Reading and writing binary NBT files
```ts
import { NbtFile, NbtString } from 'deepslate'
fetch('./example.nbt')
.then(res => res.arrayBuffer())
.then(data => {
const file = NbtFile.read(new Uint8Array(data))
file.root.set('Hello', new NbtString('World!'))
const newData = file.write()
console.log(newData)
})
```
### Rendering a structure
```ts
import { Structure, StructureRenderer } from 'deepslate'
import { mat4 } from 'gl-matrix'
const structure = new Structure([4, 3, 4])
structure.addBlock([0, 0, 3], "minecraft:stone")
structure.addBlock([0, 1, 3], "minecraft:cactus", { "age": "1" })
// Obtain the WebGL context of a canvas element
const gl = canvas.getContext('webgl')
// See the demo on how to create a resources object
const renderer = new StructureRenderer(gl, structure, resources)
const view = mat4.create()
mat4.translate(view, view, [0, 0, -5])
renderer.drawStructure(view)
```
## [Docs](https://misode.github.io/deepslate/)
A collection of examples showcasing the use cases of deepslate.
#### [Render](https://misode.github.io/deepslate/examples/structurerenderer/)
Rendering a simple structure to a canvas, read from an NBT file.
Includes mouse controls and loading of an arbitrary resource pack.

#### [Splines](https://misode.github.io/deepslate/examples/splines/)

#### [Noise](https://misode.github.io/deepslate/examples/noise/)

#### [MultiNoise](https://misode.github.io/deepslate/examples/multinoise/)

#### [Chunk Generator](https://misode.github.io/deepslate/examples/chunkgenerator/)
