Skip to main content
Entity classes provide abstractions for working with Source Engine entities, their key-values, and input/output connections.

Entity

The main entity representation that works similarly to Hammer’s entity system.

Constructor

Entity(String className)
Creates a new empty entity with the given class name. Parameters:
  • className - Entity class name (must not be null or empty)
Entity(List<KeyValue> kvList)
Creates a new entity from a list of raw key-values. Parameters:
  • kvList - Raw key-value list

Key Methods

Example Usage

// Create a new entity
Entity light = new Entity("light");
light.setOrigin(new Vector3f(0, 0, 64));
light.setValue("_light", "255 255 255 200");
light.setValue("brightness", 1.0);

// Read entity properties
String className = light.getClassName(); // "light"
Vector3f pos = light.getOrigin(); // Vector3f(0, 0, 64)
boolean hasTarget = light.hasKey("targetname"); // false

KeyValue

Represents a single key-value pair (similar to Source Engine’s epair_t structure).

Constructor

KeyValue(String key, String value)
Parameters:
  • key - The key name (immutable)
  • value - The value string

Methods

getKey

String getKey()
Returns the key name.

getValue

String getValue()
Returns the value.

setValue

String setValue(String value)
Sets a new value and returns the old value.

String Format

The toString() method returns the key-value in Source Engine format:
KeyValue kv = new KeyValue("targetname", "door1");
System.out.println(kv); // "targetname" "door1"

EntityIO

Handles entity input/output connections for the Source Engine I/O system.

String Separators

static final char SEP_CHR_OLD = ',';        // Legacy separator
static final char SEP_CHR_NEW = (char) 0x1b; // Modern separator (ESC)

Constructor

EntityIO(String entityIO)
Parses an entity I/O string. The format is:
targetEntity<sep>input<sep>parameter<sep>delay<sep>timesToFire
Example:
"door1,Open,,0,1"

Methods

Example Usage

// Parse an I/O connection
KeyValue ioKv = new KeyValue("OnTrigger", "door1,Open,,0.5,1");

if (EntityIO.isEntityIO(ioKv)) {
    EntityIO io = new EntityIO(ioKv.getValue());
    
    String target = io.getTargetEntity(); // "door1"
    String input = io.getInput();         // "Open"
    float delay = io.getDelay();          // 0.5
    int times = io.getTimesToFire();      // 1
}

Lumps

BSP lump types and data structures

Structs

BSP file structures and data types

Build docs developers (and LLMs) love