Code Monkey home page Code Monkey logo

prismarine-chunk's Introduction

prismarine-chunk

NPM version Build Status Join the chat at https://gitter.im/PrismarineJS/prismarine-chunk Greenkeeper badge

A class to hold chunk data for Minecraft: PC 1.8, 1.9, 1.10, 1.11 and 1.12 and Pocket Edition 0.14 and 1.0

Usage

const Chunk = require('prismarine-chunk')("1.8")
const Vec3 = require("vec3")

const chunk=new Chunk()

for (let x = 0; x < 16;x++) {
  for (let z = 0; z < 16; z++) {
    chunk.setBlockType(new Vec3(x, 50, z), 2)
    for (let y = 0; y < 256; y++) {
      chunk.setSkyLight(new Vec3(x, y, z), 15)
    }
  }
}

console.log(JSON.stringify(chunk.getBlock(new Vec3(3,50,3)),null,2))

Test data

Test data can be generated with minecraftChunkDumper.

Install it globally with npm install minecraft-chunk-dumper -g then run :

minecraftChunkDumper saveChunk 1.8.8 1.8/chunk.dump 1.8/chunk.meta

Benchmarking

Benchmarks may be run by using:

# run benchmarks once
npm run benchmark

# run benchmarks continuously, reloading changes as they are made
npm run benchmark -- --watch

The output of the benchmarking will be placed in the file benchmarks/results/chunk-1.9.csv

API

Chunk

Chunk()

Build a new chunk

Chunk.initialize(iniFunc)

Initialize a chunk.

  • iniFunc is a function(x,y,z) returning a prismarine-block.

That function is faster than iterating and calling the setBlock* manually. It is useful to generate a whole chunk and load a whole chunk.

Chunk.getBlock(pos)

Get the Block at pos

Chunk.setBlock(pos,block)

Set the Block at pos

Chunk.getBlockType(pos)

Get the block type at pos

Chunk.getBlockData(pos)

Get the block data (metadata) at pos

Chunk.getBlockLight(pos)

Get the block light at pos

Chunk.getSkyLight(pos)

Get the block sky light at pos

Chunk.getBiome(pos)

Get the block biome id at pos

Chunk.getBiomeColor(pos)

Get the block biome color at pos. Does nothing for PC.

Chunk.setBlockType(pos, id)

Set the block type id at pos

Chunk.setBlockData(pos, data)

Set the block data (metadata) at pos

Chunk.setBlockLight(pos, light)

Set the block light at pos

Chunk.setSkyLight(pos, light)

Set the block sky light at pos

Chunk.setBiome(pos, biome)

Set the block biome id at pos

Chunk.setBiomeColor(pos, biomeColor)

Set the block biomeColor at pos. Does nothing for PC.

Chunk.dump(bitmap=0xFFFF)

Returns the chunk raw data

Chunk.load(data,bitmap=0xFFFF,skyLightSent = true)

Load raw data into the chunk

prismarine-chunk's People

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.