Table of Contents

Interface ITreeAttribute

Namespace
Vintagestory.API.Datastructures
Assembly
VintagestoryAPI.dll

Represents a List of nestable Attributes

public interface ITreeAttribute : IAttribute, IEnumerable<KeyValuePair<string, IAttribute>>, IEnumerable
Inherited Members
Extension Methods

Properties

Count

Amount of elements in this Tree attribute

int Count { get; }

Property Value

int

this[string]

Will return null if given attribute does not exist

IAttribute this[string key] { get; set; }

Parameters

key string

Property Value

IAttribute

Values

Returns all values inside this tree attributes

IAttribute[] Values { get; }

Property Value

IAttribute[]

Methods

Clone()

Creates a deep copy of the attribute tree

ITreeAttribute Clone()

Returns

ITreeAttribute

Equals(IWorldAccessor, IAttribute, params string[])

bool Equals(IWorldAccessor worldForResolve, IAttribute attr, params string[] ignoreSubTrees)

Parameters

worldForResolve IWorldAccessor
attr IAttribute
ignoreSubTrees string[]

Returns

bool

GetAsBool(string, bool)

Returns true/false, for whatever type of attribute is found for given key

bool GetAsBool(string key, bool defaultValue = false)

Parameters

key string
defaultValue bool

Returns

bool

GetAsInt(string, int)

int GetAsInt(string key, int defaultValue = 0)

Parameters

key string
defaultValue int

Returns

int

GetAsString(string, string)

Retrieves the value of given attribute, independent of attribute type

string GetAsString(string key, string defaultValue = null)

Parameters

key string
defaultValue string

Returns

string

GetBool(string, bool)

Retrieves a bool or default value if key is not found

bool GetBool(string key, bool defaultValue = false)

Parameters

key string
defaultValue bool

Returns

bool

GetBytes(string, byte[])

Retrieves a byte array or defaultValue if key is not found

byte[] GetBytes(string key, byte[] defaultValue = null)

Parameters

key string
defaultValue byte[]

Returns

byte[]

GetDecimal(string, double)

Retrieves an int, float, long or double value. Whatever attribute is found for given key

double GetDecimal(string key, double defaultValue = 0)

Parameters

key string
defaultValue double

Returns

double

GetDouble(string, double)

Retrieves a double or defaultValue if key is not found

double GetDouble(string key, double defaultValue = 0)

Parameters

key string
defaultValue double

Returns

double

GetFloat(string, float)

Retrieves a float or defaultvalue if key is not found

float GetFloat(string key, float defaultValue = 0)

Parameters

key string
defaultValue float

Returns

float

GetHashCode(string[])

int GetHashCode(string[] ignoredAttributes)

Parameters

ignoredAttributes string[]

Returns

int

GetInt(string, int)

Retrieves an int or default value if key is not found

int GetInt(string key, int defaultValue = 0)

Parameters

key string
defaultValue int

Returns

int

GetItemstack(string, ItemStack)

Retrieves an itemstack or defaultValue if key is not found. Be sure to call stack.ResolveBlockOrItem() after retrieving it.

ItemStack GetItemstack(string key, ItemStack defaultValue = null)

Parameters

key string
defaultValue ItemStack

Returns

ItemStack

GetLong(string, long)

Retrieves a long or default value if key is not found

long GetLong(string key, long defaultValue = 0)

Parameters

key string
defaultValue long

Returns

long

GetOrAddTreeAttribute(string)

Retrieves an attribute tree or adds it if key is not found. Throws an exception if the key does exist but is not a tree.

ITreeAttribute GetOrAddTreeAttribute(string key)

Parameters

key string

Returns

ITreeAttribute

GetString(string, string)

Retrieves a string or defaultValue if key is not found

string GetString(string key, string defaultValue = null)

Parameters

key string
defaultValue string

Returns

string

GetTreeAttribute(string)

Retrieves an attribute tree or null if key is not found

ITreeAttribute GetTreeAttribute(string key)

Parameters

key string

Returns

ITreeAttribute

HasAttribute(string)

True if this attribute exists

bool HasAttribute(string key)

Parameters

key string

Returns

bool

IsSubSetOf(IWorldAccessor, IAttribute)

bool IsSubSetOf(IWorldAccessor worldForResolve, IAttribute other)

Parameters

worldForResolve IWorldAccessor
other IAttribute

Returns

bool

MergeTree(ITreeAttribute)

Merges trees (it will overwrite existing values)

void MergeTree(ITreeAttribute tree)

Parameters

tree ITreeAttribute

RemoveAttribute(string)

Removes an attribute

void RemoveAttribute(string key)

Parameters

key string

SetBool(string, bool)

Creates a bool attribute with given key and value

void SetBool(string key, bool value)

Parameters

key string
value bool

SetBytes(string, byte[])

Creates a byte[] attribute with given key and value

void SetBytes(string key, byte[] value)

Parameters

key string
value byte[]

SetDouble(string, double)

Creates a double attribute with given key and value

void SetDouble(string key, double value)

Parameters

key string
value double

SetFloat(string, float)

Creates a float attribute with given key and value

void SetFloat(string key, float value)

Parameters

key string
value float

SetInt(string, int)

Creates an int attribute with given key and value

void SetInt(string key, int value)

Parameters

key string
value int

SetItemstack(string, ItemStack)

Sets given item stack with given key

void SetItemstack(string key, ItemStack itemstack)

Parameters

key string
itemstack ItemStack

SetLong(string, long)

Creates a long attribute with given key and value

void SetLong(string key, long value)

Parameters

key string
value long

SetString(string, string)

Creates a string attribute with given key and value

void SetString(string key, string value)

Parameters

key string
value string

SortedCopy(bool)

Returns a ITreeAttribute sorted alphabetically by key. Does not modify the existing ITreeAttribute

ITreeAttribute SortedCopy(bool recursive = false)

Parameters

recursive bool

Returns

ITreeAttribute

TryGetBool(string)

Retrieves a bool or null if the key is not found

bool? TryGetBool(string key)

Parameters

key string

Returns

bool?

TryGetDouble(string)

Retrieves a double or null if key is not found

double? TryGetDouble(string key)

Parameters

key string

Returns

double?

TryGetFloat(string)

Retrieves a float or null if the key is not found

float? TryGetFloat(string key)

Parameters

key string

Returns

float?

TryGetInt(string)

Retrieves an int or null if the key is not found

int? TryGetInt(string key)

Parameters

key string

Returns

int?

TryGetLong(string)

Retrieves a long or null value if key is not found

long? TryGetLong(string key)

Parameters

key string

Returns

long?