Code Monkey home page Code Monkey logo

prismarine-chunk's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

prismarine-chunk's Issues

An in-range update of minecraft-data is breaking the build 🚨

The devDependency minecraft-data was updated from 2.39.1 to 2.40.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

minecraft-data is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ ci/circleci: Your CircleCI tests were canceled (Details).

Commits

The new version differs by 2 commits ahead by 2, behind by 1.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Support for command block data

Idea:
Instead of having the output

Block {
  type: 277,
  metadata: 10,
  light: 0,
  skyLight: 0,
  biome: {
    id: 3,
    name: 'mountains',
    name_legacy: 'mountains',
    category: 'extreme_hills',
    temperature: 0.2,
    precipitation: 'rain',
    depth: 1,
    dimension: 'overworld',
    displayName: 'Extreme Hills',
    color: 6316128,
    rainfall: 0.3
  },
  position: null,
  stateId: 5654,
  name: 'command_block',
  hardness: 0,
  displayName: 'Command Block',
  shapes: [ [ 0, 0, 0, 1, 1, 1 ] ],
  boundingBox: 'block',
  transparent: false,
  diggable: false,
  material: undefined,
  harvestTools: undefined,
  drops: []
}

We should have the extra

command: 'say ack'

It would help a lot!

An in-range update of protodef is breaking the build 🚨

Version 1.6.0 of protodef was just published.

Branch Build failing 🚨
Dependency protodef
Current Version 1.5.1
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

protodef is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • ❌ ci/circleci Your CircleCI tests were canceled Details

Commits

The new version differs by 4 commits.

  • f8989fe Release 1.6.0
  • 5555dd2 Merge pull request #60 from rom1504/full_packet_parser
  • f7dc8b2 add correct error handling to full parser
  • c9873c0 add a full packet parser

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Wrong StateId from magma_block

1.13
There are blocks that stateId is over 8192, but getBlockStateId() returns under 8192.
So magma_block looks stone block.
return this.data.readUInt16LE(cursor) % 8192
I removed % 8192 to try but it seems to work well.

Have tests

That actually test something.

Simple way to do this :

  1. get example chunk for each chunk version
  2. check all kind of data get/set at all kind of position

Create a chunk dumper

cli : dumpChunk <minecraft version> <bufferFile> <metainfoFile>

how :

  • use minecraft-wrap to get and run the server
  • connect with a minecraft-protocol client
  • listen to chunk event
  • save to buffer file and metainfo file

This can then be used to create tests for prismarine-chunk for any version.

Have a faster 1.9 chunk implementation

#18 is needed first, to check the actual times
Then there are several ways to do it :

  • convert the buffer in a faster format
  • just store the buffer as is and access it

Something very easy to do and a bit of a hack might be a "lazy" option : just store the buffer as is and only actually convert it if a get* or set* gets called.
It might be useful for mineflayer for example, where only the chunk where the bot is, is actually really needed.

fix offset bug in 1.9 detected by node 10

If you run the test in node 10 you get :

RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 6652. Received 6654
    at boundsError (internal/buffer.js:55:9)
    at Buffer.readUInt32BE (internal/buffer.js:198:5)
    at Chunk.eatPackedBlockLongs (src/pc/1.9/chunk.js:414:40)
    at Chunk.unpackChunkData (src/pc/1.9/chunk.js:354:31)
    at Chunk.load (src/pc/1.9/chunk.js:325:29)
    at Context.<anonymous> (test/test.js:78:14)

I don't really understand the 1.9 implementation. If someone that does (@allain @Flynnn) could have a look, it would be appreciated.

I bet it means that sometimes things don't fully work.

An in-range update of minecraft-data is breaking the build 🚨

Version 2.21.0 of minecraft-data just got published.

Branch Build failing 🚨
Dependency minecraft-data
Current Version 2.20.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As minecraft-data is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ

Status Details
  • ❌ ci/circleci There was an infrastructure problem while running your tests Details

Commits

The new version differs by 2 commits.

  • 4bf957e Release 2.21.0
  • 6a589af bump mcdata to 2.21.0 : mcpc 1.12.2 support

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Use vec3

having x,y and z everywhere is a pain

An in-range update of minecraft-data is breaking the build 🚨


☝️ Important announcement: Greenkeeper will be saying goodbye πŸ‘‹ and passing the torch to Snyk on June 3rd, 2020! Find out how to migrate to Snyk and more at greenkeeper.io


The devDependency minecraft-data was updated from 2.47.0 to 2.48.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

minecraft-data is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ ci/circleci: build: Your tests failed on CircleCI (Details).

Commits

The new version differs by 2 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Implement the 0x21 map_chunk bitmap

Minecraft network packet 0x21 map_chunk allows for a bitmap to specify which 16x16x16 minichunks are included and which are left out to be filled with air. Currently there is no way of using this, and the entirety of the chunk must be sent over the wire.

TypeError: this.sections.initialize is not a function

When using 1.8.0 and using the .initialize() function:

const chunk = new Chunk()

chunk.initialize((x, y, z, n) => {
  // Perform magic
  return block
})

then

TypeError: this.sections.initialize is not a function
    at Chunk.initialize (prismarine-chunk/src/pc/1.8/chunk.js:62:21)

is thrown.

It appears that prismarine-chunk is calling a function on an array: https://github.com/PrismarineJS/prismarine-chunk/blob/master/src/pc/1.8/chunk.js#L62 rather than cycling through it.

Better testing

Testing needs to be improved to cover more edge cases.

Regression testing for #99 can be implemented in the following ways:

  • Nether chunks should be added to the test chunk dumps to test for correct skylight handling (bug 1)
  • Improve cycle tests to make sure the raw dumped block and light (skylight and blocklight) buffers match and check the biomes match (bug 2 & 3)
  • Chunks with more than 256 (2^8) different block states (aka, different block type or different block data) should be added to the test chunk dumps to test for correct global palette handling (bug 4)

1.13 support

Update notes

There are some updates on the chunk data definition including the removal for direct palette and the change of biome data type.

fromJson is not defined

(node:15636) UnhandledPromiseRejectionWarning: TypeError: j.fromJson is not a function

Documentation:
"Chunk.fromJson(j)
Load chunk from json"

My code:

async function go() {
    var Anvil = require('prismarine-provider-anvil').Anvil('1.16')
    var v = require('vec3');
    const Chunk = require('prismarine-chunk')('1.8')
    var anv = new Anvil('/home/USER/.minecraft/saves/ack/region')
    console.log(anv)
    ack = await anv.getRegion(0, 0)
    console.log(ack)
    j = new Chunk()
    j.fromJson(ack)
    j.getBlock(v(0, 0, 0))
    
}
go()

Output:

(node:15636) UnhandledPromiseRejectionWarning: TypeError: j.fromJson is not a function
    at go (/home/lachie/Documents/mcworld/index.js:10:7)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:15636) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:15636) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

What is wrong here???

Investigate performance for generation

const Chunk = require('prismarine-chunk')("1.16.4")
const { Vec3 } = require('vec3')

const generator = (x, y, z) => {
    if (y < 60) return 1
    return 0
}
const slowChunkGenerator = (chunkX, chunkZ) => {
    const chunk = new Chunk()
    for (let y = 0; y < 256; y++) {
        for (let x = 0; x < 16; x++) {
        for (let z = 0; z < 16; z++) {
            chunk.setBlockStateId(new Vec3(x, y, z), generator(chunkX * 16 + x, y, chunkZ * 16 + z))
        }
        }
    }
    return chunk
}

const fastChunkGenerator = (chunkX, chunkZ) => {
    const chunk = new Chunk()
    const p = new Vec3(0, 0, 0)
    for (p.y = 59; p.y < 60; p.y++) {
        for (p.x = 0; p.x < 16; p.x++) {
        for (p.z = 0; p.z < 16; p.z++) {
            chunk.setBlockStateId(p, 1)
        }
        }
    }
    return chunk
}

const {
  performance
} = require('perf_hooks');


const old = performance.now()
for (let i=0; i < 1000; i++) {
    slowChunkGenerator(0, 0)
}
console.log(performance.now() - old)

as part of the schematic dataset project, we noticed it's slow to generate chunks. It's particularly slow to generate full chunks.
This benchmark shows that it takes 1s when generating 1000 full chunk, and about 100x less for just one layer.

Also it seems in a browser environment (with webpack), it's much slower.

This issue is there to track this, I think at some point it might be interesting to check if we can improve this (check what happens in the browser, check if we can batch the set state ids, ...)

Add type hints.

Add type hints to enable better use of this lib and support with typescript

PartialReadError: Read error for skyLight : undefined on Minecraft 1.10.2 when playing in the End

Hi,

I've gone into the End and boxed myself into an obsidian box, and when I try to start the bot I get this error:

PartialReadError: Read error for skyLight : undefined
    at new ExtendableError (C:\Users\micha\node_modules\protodef\src\utils.js:75:11)
    at new PartialReadError (C:\Users\micha\node_modules\protodef\src\utils.js:81:5)
    at ProtoDef.readBuffer (C:\Users\micha\node_modules\protodef\src\datatypes\utils.js:150:42)
    at ProtoDef.read (C:\Users\micha\node_modules\protodef\src\protodef.js:127:29)
    at tryDoc (C:\Users\micha\node_modules\protodef\src\datatypes\structures.js:46:32)
    at tryCatch (C:\Users\micha\node_modules\protodef\src\utils.js:63:16)
    at tryDoc (C:\Users\micha\node_modules\protodef\src\utils.js:67:10)
    at typeArgs.forEach (C:\Users\micha\node_modules\protodef\src\datatypes\structures.js:45:5)
    at Array.forEach (<anonymous>)
    at ProtoDef.readContainer (C:\Users\micha\node_modules\protodef\src\datatypes\structures.js:44:12)

Running Minecraft 1.10.2 with the latest version of Mineflayer

Data buffer not correct size

Using MineFlayer to connect to a Bungee server i'm getting this crash as soon as i try to change server with command:

You are using a pure-javascript implementation of RSA.
Your performance might be subpar. Please consider installing URSA
C:\Users\Utilizador\Desktop\mineflayer-master\mcbot\node_modules\mineflayer\node_modules\prismarine-chunk\src\pc\1.8\chunk.js:192
      throw(new Error(`Data buffer not correct size \(was ${data.length}, expected ${BUFFER_SIZE}\)`));
      ^

Error: Data buffer not correct size (was 164096, expected 196864)
    at Chunk.load (C:\Users\Utilizador\Desktop\mineflayer-master\mcbot\node_modules\mineflayer\node_modules\prismarine-chunk\src\pc\1.8\chunk.js:192:13)
    at addColumn (C:\Users\Utilizador\Desktop\mineflayer-master\mcbot\node_modules\mineflayer\lib\plugins\blocks.js:46:12)
    at Client.bot._client.on (C:\Users\Utilizador\Desktop\mineflayer-master\mcbot\node_modules\mineflayer\lib\plugins\blocks.js:187:7)
    at emitTwo (events.js:125:13)
    at Client.emit (events.js:213:7)
    at Parser.deserializer.on (C:\Users\Utilizador\Desktop\mineflayer-master\mcbot\node_modules\mineflayer\node_modules\minecraft-protocol\src\client.js:102:12)
    at emitOne (events.js:115:13)
    at Parser.emit (events.js:210:7)
    at addChunk (C:\Users\Utilizador\Desktop\mineflayer-master\mcbot\node_modules\readable-stream\lib\_stream_readable.js:284:12)
    at readableAddChunk (C:\Users\Utilizador\Desktop\mineflayer-master\mcbot\node_modules\readable-stream\lib\_stream_readable.js:271:11)

This is the code i'm using:

var mineflayer = require('mineflayer');
var bot = mineflayer.createBot({
  host: "server.ip",
  port: 25565,
  username: "email",
  password: "password",
  version: "1.8"
});
bot.on('spawn', function() {
    bot.chat("/server ruby");
});

Tried setting up a bungeecord locally with 2 servers and it worked.
Player logged in as bot has permissions to /server

Saving heightmap information from map_chunk

https://minecraft.gamepedia.com/Chunk_format

Reading through the chunk format I see there is important heightmap information. I do not think it is saved in versions prior to when you would have to manually parse it from the data. I sadly am not well equipped to do it, because I am not good with working with raw data as a javascript programmer.
Right now for one of my mineflayer projects I am shooting rays down from the sky (while loop until hit) and it is quite expensive. It would be extremely handy for me to have this heightmap information. Just a consideration.

this.sectionMask.toLongArray is not a function

TypeError: this.sectionMask.toLongArray is not a function
    at ChunkColumn.getMask (/root/flying-squid/node_modules/.pnpm/[email protected]/node_modules/prismarine-chunk/src/pc/1.17/ChunkColumn.js:242:31)
    at /root/flying-squid/src/lib/plugins/world.js:175:23
    at Entity.behavior (/root/flying-squid/src/lib/behavior.js:24:14)
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
    at async Entity.player.login (/root/flying-squid/src/lib/plugins/login.js:222:5)
    at async Server.<anonymous> (/root/flying-squid/src/lib/plugins/login.js:29:7)

Benchmark this package

I think this might actually be the cursor computing/buffer getting that's making prismarine-world a bit slower than it could be.
(for generation when a lot of setBlock are done, and for physics when a lot of getBlock are done)

Once benchmarked, it would be interesting to compare different approaches (see #16 (comment))

Load from .mca

Hi there!

I have a plan to make a program to make a one-command-block creation from a Minecraft world.
For that, I need to read the world that the original creation was made in.
This would be perfect for what I'm doing, but you can only create new chunks, not load any from a .mca file.
Can you add support for that?
image

How to read chunk for pe 0.14

Hi,
I am trying to init like this to read the pe 0.14

const Chunk = require('prismarine-chunk')("0.14")

But I have an error:

No chunk implementation for 0.14 found

What is the right way to init and read the chunk data of pe 0.14?
Thank you!

Add doc

documenting the API of prismarine-chunk that users can use

Broken for negative positions

buffer.js:580
    throw new RangeError('offset is not uint');
    ^
RangeError: offset is not uint
    at checkOffset (buffer.js:580:11)
    at Buffer.readUInt16LE (buffer.js:609:5)
    at Chunk.getBlockData (/media/documents/Documents/programmation/interlangage/minecraft/craftyjs/node_modules/prismarine-chunk/dist/chunk.js:82:34)
    at Chunk.setBlockType (/media/documents/Documents/programmation/interlangage/minecraft/craftyjs/node_modules/prismarine-chunk/dist/chunk.js:106:33)
    at inject (/media/documents/Documents/programmation/interlangage/minecraft/craftyjs/lib/serverPlugins/world.js:23:22)
    at MCServer.connect (/media/documents/Documents/programmation/interlangage/minecraft/craftyjs/index.js:31:30)
    at Object.createMCServer (/media/documents/Documents/programmation/interlangage/minecraft/craftyjs/index.js:16:12)
    at Object.<anonymous> (/media/documents/Documents/programmation/interlangage/minecraft/craftyjs/app.js:15:10)
    at Module._compile (module.js:456:26)
    at Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Module._load (module.js:312:12)

Empty Sky/Block Light Mask support

  • Add new properties: emptySkyLightMask and emptyBlockLightMask
  • Use them on load (API non-breaking change)
  • Automatically add bits to these properties and nullify empty light sections
  • Automatically remove bits when filling values in empty light sections

prettier support

StandardJS doesn't work with Prettier out of the box. I've had to disable semicolons and doublequotes in prettier options but there are still cases where "Missing space before function parentheses." isn't configurable with Prettier.

I've tried to used https://github.com/sheerun/prettier-standard but I failed to have it work with the "Format on save" feature in vscode.

Can we use Prettier instead for code formatting while keeping the other rules of standardjs(which in reality is the ones that really matter)?

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.