PrismarineJS / dazed-sheep

A Minecraft Classic server in JavaScript
MIT License
24 stars 5 forks source link

save/load the world #1

Closed rom1504 closed 8 years ago

rom1504 commented 8 years ago

Should be easy enough to do with https://github.com/mhsjlw/minecraft-classic-anvil

ghost commented 8 years ago

It gives us a buffer of blocks, how can we split that up so we can send it to the user?

rom1504 commented 8 years ago

@mhsjlw how big is the buffer ?

ghost commented 8 years ago

When running the read.js example in the repo based off of a world generated by the official minecraft server and running console.log(data.blocks.$.length);, it is 4194304

rom1504 commented 8 years ago

console.log(data["blocks"]["$"].length)

4194304

= 256_64_256

so it's exactly the same format

make a load in world.js that does this.data=data; and done.

rom1504 commented 8 years ago

hmm, not exactly this.data=data; actually load(data) { data.copy(this.data,4); }

rom1504 commented 8 years ago

well might as well include the require('minecraft-classic-anvil') and usage directly in world.js ;)

ghost commented 8 years ago

I need to publish it then... should we implement world writing first? Like setting blocks? Or should I just disable that for now, so you can only read?

rom1504 commented 8 years ago

@mhsjlw I think, just remove x,y, z and block in https://github.com/mhsjlw/minecraft-classic-anvil/blob/master/src/write.js and it's done.

I mean it'll be enough to use it.

rom1504 commented 8 years ago

ah nevermind, you just copy pasted this from read.js, there's some stuff to change indeed.

But just implement as "encode in that java.io format and let the user handle the format" I think, for now.

rom1504 commented 8 years ago

But anyway yeah, publishing it with just load working is okay.

ghost commented 8 years ago

Ok. before I push though I am adding a readSync function in case we need it

rom1504 commented 8 years ago

I don't think it's needed to have a readSync no.

ghost commented 8 years ago

it's done I just need to add a /save command