data

Module containing Terraria game data not included in save files, but useful to represent their contents.

It contains some enumerations in the enums submodule, but most data is represented in the form of Class enumerations.

Class enumerations

This module makes heavy use of class enumerations.

Class enumerations are similar to enum.Enum, but while in those the enumeration is a class and its variants are its instances, in class enumerations the enumeration is a metaclass, while its variants are themselves classes instances of that metaclass.

This allows variants to have multiple properties of their own, and be themselves instantiated.

Class hierarchy

The names and hierarchy of the classes involved in this abstraction are as follows:

ClassEnumType

Abstract metaclass from which new ClassEnum should inherit normally.

It represents the type of collections of kinds of things.

Stored in the classenumtype submodule.

ClassEnum

The individual metaclasses which keep track of the classes that are created using them.

They represent collections of kinds of things:

  • BlockEnum is the metaclass tracking (placed) block types;

  • WallEnum is the metaclass tracking (placed) wall types;

  • ItemEnum is the metaclass tracking (in-inventory) item types;

  • NPCEnum is the metaclass tracking non-player character types;

  • PrefixEnum is the metaclass tracking item prefix types;

  • LiquidEnum is the metaclass tracking (placed) liquid types.

Stored in the classenums submodule.

ClassMember

The individual classes created using ClassEnum as metaclass, tracked by them as members.

They represent kinds of things:

  • Blocks are kinds of (placed) blocks;

  • Walls are kinds of (placed) walls;

  • Items are kinds of (in-inventory) items;

  • Npcs are kinds of non-player characters;

  • Prefixes are kinds of item prefixes;

  • Liquids are kinds of (placed) liquids.

Stored in the classmembers submodule.

ClassInstance

The objects instantiated normally from ClassMember.

They represent things themselves:

  • A block instance corresponds to an actual block placed in a world;

  • A wall instance corresponds to an actual wall placed in a world;

  • An item instance corresponds to an actual item stack in an inventory in a world;

  • A npc instance corresponds to an actual NPC physically present in a world;

  • Prefix instances cannot be instantiated, as that would not make sense;

  • A liquid instance corresponds to an actual tile of liquid in a world.

Base classes

Some base classes are also defined, to provide various defaults to the classes in the above hierarchy:

ClassEnumTypeBase

Class which implement ways to index the registered ClassMembers:

Stored in the classenumtype submodule.

ClassMemberBase

Class which defines ClassMember methods and properties and annotates them:

Stored in the classmembers submodule.