API reference Obsidian.API.Inventory.DataComponents
DataComponentsStorage class
public abstract class DataComponentsStorage
In Obsidian.API.
Constructors
protected DataComponentsStorage();Properties
protected Dictionary<DataComponentType, int> HashedStorage { get; }protected Dictionary<DataComponentType, DataComponent> InternalStorage { get; }Patch
public IEnumerable<DataComponent> Patch { get; }The components that were set on this storage, as opposed to placeholders for the item's defaults. Like vanilla's DataComponentPatch, this is what goes over the network.
Placeholders
protected Dictionary<DataComponentType, DataComponent> Placeholders { get; }Components that only stand in for the item's own defaults (see ComponentBuilder.DefaultItemComponents), as they were when added. Immutable placeholders aren't part of DataComponentsStorage.Patch; setting or removing a component of the type drops its placeholder.
public List<DataComponentType> RemoveComponents { get; }public DataComponent this[DataComponentType type] { get; set; }public int TotalComponents { get; }Methods
public bool Add(DataComponent component);AddHashedComponent(DataComponentType, int)
public bool AddHashedComponent(DataComponentType type, int hash);Adds a hashed components to the item.
Parameters
type- The component type.
hash- The Crc32 hash of that component
Returns
True if it was added otherwise false.
Remarks
The hashes are sent from the client. The server does not generate/send hashed components. The only time the server will generate these hashes is to compare already existing items. i.e to compare if the item the client sent back is the same as the one on the server.
public bool CompareComponentHash(DataComponentType type, int hash);public bool ContainsKey(DataComponentType type);public TComponent GetComponent<TComponent>(DataComponentType type) where TComponent : DataComponent;public IEnumerator<DataComponent> GetEnumerator();public bool Remove(DataComponentType type);public bool TryGetComponent(DataComponentType componentType, out DataComponent component);public bool TryGetComponent<TComponent>(DataComponentType componentType, out DataComponent component) where TComponent : DataComponent;