prismarinejs / prismarine-chunk Goto Github PK
View Code? Open in Web Editor NEWA class to hold chunk data for Minecraft
License: MIT License
A class to hold chunk data for Minecraft
License: MIT License
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.
There is a collection of frequently asked questions. If those donβt help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot π΄
changes :
I think that's it
So I think what we need to do is :
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!
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.
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
There is a collection of frequently asked questions. If those donβt help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot π΄
Are there any plans on adding 1.14 support?
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.
This will make it possible to use https://github.com/josdejong/workerpool in mineflayer which will speed up chunk loading a lot
That actually test something.
Simple way to do this :
something changed
https://wiki.vg/Pre-release_protocol#Chunk_Data
The compacted array format has been adjusted so that individual entries no longer span across multiple longs, affecting the main data array and heightmaps.
cli : dumpChunk <minecraft version> <bufferFile> <metainfoFile>
how :
This can then be used to create tests for prismarine-chunk for any version.
#18 is needed first, to check the actual times
Then there are several ways to do 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.
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.
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 πͺ
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot π΄
will simplify API usage
Looking at http://wiki.vg/SMP_Map_Format a chunk is 16x16x16 and a chunk column is 16x256x16
This module is currently handling a chunk column, that probably shouldn't be the case.
Not sure actually, I guess it makes some sense to store a column, related to #8 anyway.
having x,y and z everywhere is a pain
βοΈ 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
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.
There is a collection of frequently asked questions. If those donβt help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot π΄
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.
with a few well placed if and the supportFeature pattern, it might work and remove lot of code duplication
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.
1.9 is used for 1.9 -> 1.12 which is used by many users
Testing needs to be improved to cover more edge cases.
Regression testing for #99 can be implemented in the following ways:
There are some updates on the chunk data definition including the removal for direct palette and the change of biome data type.
(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???
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, ...)
use bit-buffer, it works well
serious example of use at https://github.com/MephisTools/diablo2-protocol/blob/master/lib/utils/itemParser.js
just initialize from an existing chunk and then check equality.
should find the bug in 1.9
Right?
Now it's in devDependencies
which looks like a mistake to me. I'm happy to make PR as its only a 1 minute change but I wanted to confirm beforehand.
http://wiki.vg/SMP_Map_Format#Format
http://wiki.vg/Pre-release_protocol#Chunk_Section
PrismarineJS/node-minecraft-protocol#231 (comment)
This will help mineflayer and flying-squid update to cross-version (1.8 + 1.9)
Add type hints to enable better use of this lib and support with typescript
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
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
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.
https://github.com/prismarinejs/prismarine-block
That way we have a common block API usable by everybody
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)
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))
will fix #31 and PrismarineJS/mineflayer#565
It might be nice to somehow use prismarine-chunk inside mineflayer.
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?
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!
documenting the API of prismarine-chunk that users can use
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)
emptySkyLightMask
and emptyBlockLightMask
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)?
I guess something about the node version ?
It works fine on my machine
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.