lihzahrd.fileutils

class lihzahrd.fileutils.Coordinates(x, y)

A pair of coordinates.

x
y
class lihzahrd.fileutils.FilePacker(data: bytearray)

Helper class for serializing and deserializing a Terraria world file.

_boolean = Struct('?')
_fdouble = Struct('d')
_fsingle = Struct('f')
_int2 = Struct('h')
_int4 = Struct('i')
_int8 = Struct('q')
_read_string_base(size: int) str
_rect = Struct('iiii')
_uint1 = Struct('B')
_uint2 = Struct('H')
_uint4 = Struct('i')
_uint8 = Struct('Q')
_write_string_base(value: bytes) None
cursor

The byte currently being edited.

data: bytearray

The world data.

read(structure: Struct) Any
read_bits() tuple[bool, bool, bool, bool, bool, bool, bool, bool]
read_boolean() bool
read_bytearray_to_address(address: int) bytearray
read_datetime() bytearray
read_fdouble() float
read_fsingle() float
read_int2() int
read_int4() int
read_int8() int
read_rect() Rect
read_string_fixed(size: int)
read_string_variable() str
read_uint1() int
read_uint2() int
read_uint4() int
read_uint8() int
read_uleb128() int
read_uuid() UUID
write(structure: Struct, value: Any) None
write_bits(value: tuple[bool, bool, bool, bool, bool, bool, bool, bool]) None
write_boolean(value: bool) None
write_datetime(value: bytearray) None
write_fdouble(value: float) None
write_fsingle(value: float) None
write_int2(value: int) None
write_int4(value: int) None
write_int8(value: int) None
write_rect(value: Rect) None
write_string_fixed(value: str, expected_size: int) None
write_string_variable(value: str) None
write_uint1(value: int) None
write_uint2(value: int) None
write_uint4(value: int) None
write_uint8(value: int) None
write_uleb128(value: int) None
write_uuid(value: UUID) None
class lihzahrd.fileutils.Packable

An object which can be serialized and deserialized via a lihzahrd.fileutils.FilePacker.

classmethod read(f: FilePacker, v: Version) Self
write(f: FilePacker, v: Version)
class lihzahrd.fileutils.Pointers(world_header: int, world_tiles: int, chests: int, signs: int, npcs: int, tile_entities: int, pressure_plates: int, town_manager: int, bestiary: int, journey_powers: int, footer: int, *unknown)

Pointers to the various sections of the Terraria save file.

All values are in number of bytes from the start.

bestiary: int
chests: int
file_format: int
footer: int
journey_powers: int
npcs: int
pressure_plates: int
signs: int
tile_entities: int
town_manager: int
unknown: list[int]
world_header: int
world_tiles: int
class lihzahrd.fileutils.Rect(left: int, right: int, top: int, bottom: int)

Class delimining the bounds of a rectangle.

bottom: int
left: int
right: int
to_tuple() tuple[int, int, int, int]
top: int