mc-classic-js
Contains functionality for reading and writing Minecraft Classic JS worlds.
What is Minecraft Classic Javascript?
Minecraft Classic Javascript is an official Mojang port of Minecraft classic that runs inside a web browser. Instead of storing worlds as .min or .dat files, instead worlds are stored as json objects within a browser's localStorage in the following format:
savedGame:
Notably, this is very little data, and the keen among you may be able to tell that the tilemap for the world is not stored. Instead the tilemap is regenerated each time the world is loaded, and then an array of changed blocks are placed over. So this library not only reads from and writes into these json objects, but it also generates the tilemap from the seed. This uses rust code that was converted 1:1 from the deobfuscated javascript world generation code
Usage
Add this to your Cargo.toml:
[]
= "0.1.4"
Examples
There are a few functions that can read in a savedGame object, depending on whether it is stored inside a db file or just reading in a json string. To understand the db format, read here.
use mc-classic-js;
Similarly, there are multiple functions for writing a level back into the savedGame format. There is functionality for just getting the raw json, for writing it to a db file, and also for writing it to a localStorage.setItem() command.
use mc-classic-js;
Where is the world actually stored?
localStorage works differently between different browsers, and currently this library only natively supports Firefox.
Firefox
Firefox local storage is stored at
C:/Users/user/AppData/Roaming/Mozilla/Firefox/Profiles/########.default-release/storage/default/
Inside this default folder, there are folders that correspond to each website that is currently storing data. There are only 2 that are relevant to this code, those being
https+++classic.minecraft.net/ls/data.sqlite
https+++omniarchive.uk/ls/data.sqlite
These are the two websites that currently host Minecraft Classic JS. The actual localStorage objects are stored within these data.sqlite as key value pairs. Additionally, snappy compression is used on all values stored inside. This means to read a savedGame, first the sqlite database has to be opened, then the key savedGame has to be found, and then it needs to be decompressed.
All Browsers
To retreive localStorage manually, this can be done by inspect elementing the browser. From here, either navigate to Local Storage (location varies on browser - just use google at this point) and select the savedGame object manually, or navigate to the console, and run:
localStorage.