Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ata4/bspsrc/llms.txt
Use this file to discover all available pages before exploring further.
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
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
getValue
String getValue(String key)
Gets the value for a specific key.setValue
void setValue(String key, Object value)
void setValue(KeyValue kv)
Sets a key-value pair. The value is converted to a string.hasKey
boolean hasKey(String key)
Checks if a key exists in the entity.removeValue
void removeValue(String key)
Removes a key-value pair.
Show Entity Identification
getClassName
Returns the entity’s class name.setClassName
void setClassName(String value)
Sets the entity’s class name.getTargetName
Returns the entity’s targetname property.setTargetName
void setTargetName(String value)
Sets the entity’s targetname property.
getVector3f
Vector3f getVector3f(String key)
Parses a key’s value as a 3D vector. Returns null if the key doesn’t exist or parsing fails.setVector3f
void setVector3f(String key, Vector3f value)
Sets a key to a 3D vector value in the format “x y z”.getOrigin
Gets the entity’s origin position.setOrigin
void setOrigin(Vector3f origin)
Sets the entity’s origin position.getAngles
Gets the entity’s rotation angles. Converts from Source Engine’s (Pitch, Yaw, Roll) format to (Roll, Pitch, Yaw) for standard 3D space axes.setAngles
void setAngles(Vector3f a)
Sets the entity’s rotation angles, converting from standard format to Source Engine format.
getModelNum
Returns the model number for this entity.Returns:
- The model number (e.g., for
*3 returns 3)
-1 if no model is assigned
-2 if this is a prop with a studio model
0 for worldspawn
setModelNum
void setModelNum(int modelnum)
Sets the model number in the format *N.
getIO
Returns the list of entity I/O connections.getKeys
Returns all keys in the entity.getValues
Collection<String> getValues()
Returns all values in the entity.getEntrySet
Set<Entry<String, String>> getEntrySet()
Returns all key-value pairs as entries.
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
Returns the key name.
getValue
Returns the value.
setValue
String setValue(String value)
Sets a new value and returns the old value.
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:
Methods
isEntityIO
static boolean isEntityIO(KeyValue kv)
Checks if a KeyValue represents an entity I/O connection by counting separators.Returns:
true if the value contains 4 separators (standard format)
true if the value contains 6 separators (VTMB/Messiah format)
false otherwise
getTargetEntity / setTargetEntity
String getTargetEntity()
void setTargetEntity(String targetEntity)
The name of the target entity to send the input to.String getInput()
void setInput(String input)
The input name to fire on the target entity.getParam / setParam
String getParam()
void setParam(String param)
The parameter value to pass with the input.getDelay / setDelay
float getDelay()
void setDelay(float delay)
The delay in seconds before firing the input.getTimesToFire / setTimesToFire
int getTimesToFire()
void setTimesToFire(int timesToFire)
How many times to fire the input (-1 for infinite).
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