Crate mc_classic_js

Source

Structs§

ChangedBlocks
ChangedBlocks struct stores the json object of type: p0_0_0: {a: 0, bt: 0} This object is used inside the savedGame object to keep track of each changed block in the world: p0_0_0: position of block in world, where px_y_z a: 0 if block does match natural generation / 1 if block does not match natural generation bt: type of block
Data
Data struct stores the savedGame and settings of the world
JSLevel
JSLevel struct stores the object format of a classic js level of type: {“worldSeed”:0,“changedBlocks”:{},“worldSize”:128,“version”:1} References the ChangedBlocks struct worldSeed: This is the seed of the world changedBlocks: This is an array of all changedBlocks in the world worldSize: This is the width/length of the world, must be 128, 256, or 512 version: Yeah, I have no clue what this is, but it’s seemingly always 1 so…
LocalStorage
LocalStorage struct stores input from localStorage db files key: “savedGame” utf16_length: Length of uncompressed value conversion_type: 1 compression_type: 1 value: The actual savedGame, so the actual world
Settings
Settings struct stores the json object containing all settings for javascript worlds These settings include typical control and sound settings, but they also contain the username

Functions§

deserialize_data
Converts a savedGame json string and a settings json string into a Data struct
deserialize_saved_game
Converts a json string in the savedGame format into a JSLevel struct
deserialize_settings
Converts a json string in the settings format into a Settings struct
generate_saved_game_from_seed
Following function takes a seed and creates a JSLevel from this seed
get_tile_map
Following function accepts a world size and seed, and then passes them to the js world generation functionality, and then returns the output as a Vec<>
read_from_db
Following function opens an sqlite database at the provided path, then retreives the specified object, and then decompresses it before returning it
read_saved_game
Following function opens an sqlite database at the provided path, then retreives the specified object, and then decompresses it before returning it
read_settings
Following function opens an sqlite database at the provided path, then retreives the specified object, and then decompresses it before returning it
serialize_data
Follwing function accepts a Data struct and returns two serialized json strings
serialize_saved_game
Following function accepts a level in the JS form, a tile_map, and optimization and writes it into the classic javascript object format
serialize_saved_game_from_seedDeprecated
Following function takes a seed and creates a JSLevel from this seed, and then compares it agains the given tilemap to create a json formatted JS world save
serialize_settings
Following function accepts a settings object and returns a serialized json string
write_data
Following function accepts a path to a db file, and a json string. The json string is parsed as the value and compressed using snappy compression, and is then passed to the db and saved. Note this only applies to Firefox, as firefox is the only browser that I know of that uses this structure. Chromium support in the future…
write_local_storage_command
Following function excepts a file location and an array containing both a world save and settings formatted as json string. It then creates a localStorage.setItem() command for the key savedGame and settings, in order for it to be copy pasted into a browser console to insert the world save
write_saved_game
Following function accepts a path to a db file, and a json string. The json string is parsed as the value and compressed using snappy compression, and is then passed to the db and saved. Note this only applies to Firefox, as firefox is the only browser that I know of that uses this structure. Chromium support in the future…
write_saved_game_command
Following function excepts a file location and a world save formatted as a json string. It then creates a localStorage.setItem() command for the key savedGame, in order for it to be copy pasted into a browser console to insert the world save
write_settings_command
Following function excepts a file location and settings formatted as a json string. It then creates a localStorage.setItem() command for the key settings, in order for it to be copy pasted into a browser console to insert the world save