From 9d6c26e8c48d95570b1a4117d6912d82274a3f5c Mon Sep 17 00:00:00 2001 From: Carlos Fernandez Date: Sat, 14 Mar 2026 06:22:33 -0400 Subject: [PATCH] Fix retrieving resource attribute bars in token (#1730) --- module/data/fields/actorField.mjs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/module/data/fields/actorField.mjs b/module/data/fields/actorField.mjs index 1399fb32..76c24319 100644 --- a/module/data/fields/actorField.mjs +++ b/module/data/fields/actorField.mjs @@ -82,6 +82,24 @@ class ResourcesField extends fields.TypedObjectField { } return data; } + + /** + * Foundry bar attributes are unable to handle finding the schema field nor the label normally. + * This returns the element if its a valid resource key and overwrites the element's label for that retrieval. + */ + _getField(path) { + if ( path.length === 0 ) return this; + const first = path.shift(); + if (first === this.element.name) return this.element_getField(path); + + const resources = CONFIG.DH.RESOURCE[this.actorType].all; + if (first in resources) { + this.element.label = resources[first].label; + return this.element._getField(path); + } + + return undefined; + } } export { attributeField, ResourcesField, stressDamageReductionRule, bonusField };