Carpet

Carpet

2M Downloads

add 'attribute' to the API

gnembon opened this issue ยท 2 comments

commented

both query(entity, 'attribute', 'generic.max_health') as well as modify(entity 'attribute', 'generic.max_health', value)
providing if possible appropriate validation (to prevent writing crap back to the NBTs

commented

I could do that, but after looking at the attribute command, im not sure how it would work with modifiers. I guess it would modify the base, but is adding/removing/querying modifiers also neccesary?

commented

I've come up with the following draft for an Attributes API. The API's main endpoint would be located at query(e, 'attribute') and modify(e, 'attribute') and would have the following functions:

Note: All functions and the API are subject to change and refactoring. There may or may not be an issue or discussion about this already

query(e, 'attribute', attribute)

Gets the value of attribute for the given entity e.
Replaces /attribute <target> <attribute> get

query(e, 'attribute', attribute, 'base')

Gets the base value of attribute for the given entity e.
Replaces /attribute <target> <attribute> base get

query(e, 'attribute', attribute, 'modifiers')

Lists the UUIDs of all modifiers that attribute currently has applied.

query(e, 'attribute', attribute, 'modifier_value', modifier_uuid)

Gets the value of the given modifier on the given attribute for the given entity e.
Replaces /attribute <target> <attribute> modifier value get <uuid>

query(e, 'attribute', attribute, 'modifier_name', modifier_uuid)

Gets the name of the given modifier on the given attribute for the given entity e.

query(e, 'attribute', attribute, 'modifier_operation', modifier_uuid)

Gets the operation of the given modifier on the given attribute for the given entity e.
Returns 0 for add, 1 for multiply, or 2 for multiply_base.

modify(e, 'attribute', attribute, 'base', value)

Sets the base value of attribute to the given value.
Replaces /attribute <target> <attribute> base set <value>

modify(e, 'attribute', attribute, 'modifier_add', modifier_uuid, name, value, operation)

Applies a modifier to the given attribute with the given uuid, name, value, and operation.
Replaces /attribute <target> <attribute> modifier add <uuid> <name> <value> (add|multiply|multiply_base)
For operation: Use 0 for add, 1 for multiply, or 2 for multiply_base.

modify(e, 'attribute', attribute, 'modifier_value', modifier_uuid, value)

Overwrites the value of the modifier on attribute located at modifier_uuid with the given value.

modify(e, 'attribute', attribute, 'modifier_name', modifier_uuid, name)

Overwrites the name of the modifier on attribute located at modifier_uuid with the given name.

modify(e, 'attribute', attribute, 'modifier_operation', modifier_uuid, operation)

Overwrites the operation of the modifier on attribute located at modifier_uuid with the given operation.
For operation: Use 0 for add, 1 for multiply, or 2 for multiply_base.

modify(e, 'attribute', attribute', 'modifier_remove', modifier_uuid)

Removes the modifier on the given attribute with the given modifier_uuid.
Replaces /attribute <target> <attribute> modifier remove <uuid>