From 71fce2c0ca9a25f86597cd316f06fa937d399ad4 Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 21 Apr 2026 17:30:42 -0600 Subject: [PATCH] Update the preCreate hook to create the attribute items if there are no items in the actor --- module/data/Actor/player.mjs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/module/data/Actor/player.mjs b/module/data/Actor/player.mjs index c525c9c..16308c3 100644 --- a/module/data/Actor/player.mjs +++ b/module/data/Actor/player.mjs @@ -1,3 +1,5 @@ +import { __ID__ } from "../../consts.mjs"; + export class PlayerData extends foundry.abstract.TypeDataModel { static defineSchema() { const fields = foundry.data.fields; @@ -38,12 +40,11 @@ export class PlayerData extends foundry.abstract.TypeDataModel { */ async _preCreate(data, options, user) { - // Assign the defaults from the world setting if they exist - const defaults = game.settings.get(__ID__, `actorDefaultAttributes`) ?? {}; - if (!hasProperty(data, `system.attr`)) { - // Remove with issue: Foundry/taf#55 - const value = game.release.generation > 13 ? _replace(defaults) : defaults; - this.updateSource({ "system.==attr": value }); + // Assign the default items from the world setting if required + const items = this.parent._source.items; + if (items == null || items.length === 0) { + const defaults = game.settings.get(__ID__, `actorDefaultAttributes`) ?? []; + this.parent.updateSource({ items: defaults }); }; return super._preCreate(data, options, user);