/// <summary> /// Intializes a new <see cref="Attribute"/> /// </summary> /// <param name="type">The type of attribute</param> /// <param name="operation">The attribute operation to use</param> /// <param name="value">The value to use in the operation</param> /// <param name="slot">The slot the attribute effect works in</param> public Attribute(ID.AttributeType type, ID.AttributeOperation operation, MCRange value, ID.AttributeSlot slot) { Type = type; Operation = operation; Value = value; Slot = new ID.AttributeSlot[] { slot }; }
/// <summary> /// Intializes a new <see cref="AttributeModifier"/> /// </summary> /// <param name="name">The name of the modifier. Leave null to use UUID as name</param> /// <param name="amount">The amount to modify with</param> /// <param name="operation">The way to modify</param> /// <param name="uuid">The UUID of the modifier. Leave null to generate a UUID.</param> public AttributeModifier(double amount, ID.AttributeOperation operation, string?name = null, UUID?uuid = null) { Amount = amount; Operation = operation; UUID = uuid ?? new UUID(); Name = name ?? UUID.UUIDString; }
/// <summary> /// Intializes a new <see cref="ItemAttribute"/> /// </summary> /// <param name="attribute">The attribute the item should modify</param> /// <param name="slot">The slot the item has to be in for the modifier to work</param> /// <param name="name">The name of the modifier. Leave null to use UUID as name</param> /// <param name="amount">The amount to modify with</param> /// <param name="operation">The way to modify</param> /// <param name="uuid">The UUID of the modifier. Leave null to generate a UUID.</param> public ItemAttribute(ID.AttributeType attribute, ID.AttributeSlot slot, double amount, ID.AttributeOperation operation, string?name = null, UUID?uuid = null) { Attribute = attribute; Slot = slot; Amount = amount; Operation = operation; UUID = uuid ?? new UUID(); Name = name ?? UUID.UUIDString; }
/// <summary> /// Adds an attribute modifer to an entity /// </summary> /// <param name="selector">Selector which selects the entity to add the modifier to</param> /// <param name="attribute">The attribute to add the modifier to</param> /// <param name="uuid">The UUID of the modifier</param> /// <param name="name">The name of the modifier</param> /// <param name="value">The value of the modifier</param> /// <param name="operation">The modifier's operation</param> public void AddModifier(BaseSelector selector, ID.AttributeType attribute, UUID uuid, string name, double value, ID.AttributeOperation operation) { selector.LimitSelector(); Function.AddCommand(new AttributeAddModifierCommand(selector, attribute, uuid, name, value, operation)); }