diff --git a/module/data/Item/Weapon.mjs b/module/data/Item/Weapon.mjs index 8d50f78..3fa1e68 100644 --- a/module/data/Item/Weapon.mjs +++ b/module/data/Item/Weapon.mjs @@ -67,19 +67,21 @@ export class WeaponData extends CommonItemData { */ async _preUpdate(changes, options, user) { if (options.force && game.settings.get(`ripcrypt`, `devMode`)) { return }; + + const diff = diffObject(this.parent._source, changes); let valid = super._preUpdate(changes, options, user); - if (hasProperty(changes, `system.equipped`) && !this.parent.isEmbedded) { + if (getProperty(diff, `system.equipped`) && !this._canEquip()) { ui.notifications.error(localizer( - `RipCrypt.notifs.error.cannot-equip-not-embedded`, + `RipCrypt.notifs.error.cannot-equip`, { itemType: `@TYPES.Item.${this.parent.type}` }, )); - mergeObject( - changes, - { "-=system.equipped": null }, - { inplace: true, performDeletions: true }, - ); - return false; + + // Don't stop the update, but don't allow changing the equipped status + setProperty(changes, `system.equipped`, false); + + // Set a flag so that we can tell the sheet that it needs to rerender + this.forceRerender = true; }; return valid; };