world

Module containing subclasses of Pack which together can parse a complete Terraria world save file.

Other than PackWorld, it contains a submodule for each section of the world file:

  1. lihzahrd.terraria.world.sections

  2. lihzahrd.terraria.world.frame_important

  3. lihzahrd.terraria.world.header

  4. lihzahrd.terraria.world.tiles

  5. lihzahrd.terraria.world.chests

  6. lihzahrd.terraria.world.signs

  7. lihzahrd.terraria.world.characters

  8. lihzahrd.terraria.world.tile_entities

  9. lihzahrd.terraria.world.pressure_plates

  10. lihzahrd.terraria.world.rooms

  11. lihzahrd.terraria.world.bestiary

  12. lihzahrd.terraria.world.journey

  13. lihzahrd.terraria.world.footer

world

Submodule containing the class PackWorld itself.

class lihzahrd.terraria.world.world.PackWorld(file_metadata: FileMetadata, section_addresses: WorldSections, frame_important: WorldFrameImportant, unknown_file_metadata_bytes: PackUnknown, header: WorldHeader, unknown_header_bytes: PackUnknown, tiles: WorldTiles, unknown_tiles_bytes: PackUnknown, chests: WorldChestsCollection, unknown_chests_bytes: PackUnknown, signs: WorldSignsCollection, unknown_signs_bytes: PackUnknown, characters: WorldCharacters, unknown_npcs_bytes: PackUnknown, tile_entities: TileEntitiesCollection, unknown_tile_entities_bytes: PackUnknown, pressure_plates: WorldWeightedPressurePlatesCollection, unknown_pressure_plates_bytes: PackUnknown, rooms: RoomsCollection, unknown_rooms_bytes: PackUnknown, bestiary: Bestiary, unknown_bestiary_bytes: PackUnknown, journey: JourneySettingsCollection, unknown_journey_bytes: PackUnknown, footer: WorldFooter, unknown_footer_bytes: PackUnknown)

Pack which represents a Terraria world save file in its totality.

World save files are split in sections; this class represents each section with a separate Pack.

Warning

Very, very slow to read and write because of the compression Terraria uses to store tiles.

Danger

Denial-of-service vector: Maliciously structured world files may cause read and write to block for a very, very long time. Only load world files you trust!

Parameters:
  • debug_skip_tiles – Skip reading or writing tiles, and read the whole section to unknown_tiles_bytes instead.

  • tile_cache_path – Instead of reading tiles, if a file at the given path exists, load them from there, and read the section to unknown_tiles_bytes instead. Otherwise, read tiles as normal, but additionally save the read data in an efficient (but large) format as a file at the given path.

file_metadata: FileMetadata

The file metadata header, stopping right before the list of pointers to the various sections.

sections: WorldSections

Pointers to the byte offsets where the various sections of the save file start.

Warning

Automatically overwritten with the correct values once write() is called.

frame_important: WorldFrameImportant

Array describing which block IDs have been written as FrameImportant.

unknown_file_metadata_bytes: PackUnknown

Bytes between frame_important and header.

header: WorldHeader

The world metadata header.

Contains most important information about the game’s progress, like which NPCs have been rescued and which bosses have been defeated.

unknown_header_bytes: PackUnknown

Bytes between header and tiles.

tiles: WorldTiles

The world’s tile matrix.

unknown_tiles_bytes: PackUnknown

Bytes between tiles and chests.

chests: WorldChestsCollection

Collection of all the chests in the world and their contents.

unknown_chests_bytes: PackUnknown

Bytes between chests and signs.

signs: WorldSignsCollection

Collection of all the signs in the world and their text.

unknown_signs_bytes: PackUnknown

Bytes between signs and characters.

characters: WorldCharacters

Collection of all the characters (monsters, critters, and NPCs) in the world and their locations.

unknown_characters_bytes: PackUnknown

Bytes between characters and tile_entities.

tile_entities: TileEntitiesCollection

Collection of all the tile entities (mannequins, hat racks, …) in the world and their locations and metadata.

unknown_tile_entities_bytes: PackUnknown

Bytes between tile_entities and pressure_plates.

pressure_plates: WorldWeightedPressurePlatesCollection

Collection of all the weighted pressure plates in the world and their positions.

unknown_pressure_plates_bytes: PackUnknown

Bytes between pressure_plates and rooms.

rooms: RoomsCollection

Collection of all the assignments of rooms to NPCs.

unknown_rooms_bytes: PackUnknown

Bytes between rooms and bestiary.

bestiary: Bestiary

Status of the bestiary in the world.

unknown_bestiary_bytes: PackUnknown

Bytes between bestiary and journey.

journey: JourneySettingsCollection

Current configuration of Journey mode powers.

unknown_journey_bytes: PackUnknown

Bytes between journey and footer.

footer: WorldFooter

Extra validation data for the world.

Bytes after footer, but before the end of the file.