feat(datadriven): make animation_bones optional — absent means permissive
This commit is contained in:
@@ -103,7 +103,8 @@ public record DataDrivenItemDefinition(
|
|||||||
* is not present in this map (or null), the item falls back to its full
|
* is not present in this map (or null), the item falls back to its full
|
||||||
* {@code ownedParts}.</p>
|
* {@code ownedParts}.</p>
|
||||||
*
|
*
|
||||||
* <p>This field is required in the JSON definition. Never null, never empty.</p>
|
* <p>Optional in JSON. When absent, defaults to empty map (= all owned bones
|
||||||
|
* enabled for all animations, no filtering).</p>
|
||||||
*/
|
*/
|
||||||
Map<String, Set<String>> animationBones,
|
Map<String, Set<String>> animationBones,
|
||||||
|
|
||||||
@@ -111,9 +112,10 @@ public record DataDrivenItemDefinition(
|
|||||||
Map<ComponentType, JsonObject> componentConfigs
|
Map<ComponentType, JsonObject> componentConfigs
|
||||||
) {
|
) {
|
||||||
|
|
||||||
/** Compact constructor: default null componentConfigs to empty immutable map. */
|
/** Compact constructor: default null maps to empty immutable maps. */
|
||||||
public DataDrivenItemDefinition {
|
public DataDrivenItemDefinition {
|
||||||
if (componentConfigs == null) componentConfigs = Map.of();
|
if (componentConfigs == null) componentConfigs = Map.of();
|
||||||
|
if (animationBones == null) animationBones = Map.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Check whether this definition declares a given component type. */
|
/** Check whether this definition declares a given component type. */
|
||||||
|
|||||||
@@ -261,18 +261,28 @@ public final class DataDrivenItemParser {
|
|||||||
// Optional: creator (author name for tooltip)
|
// Optional: creator (author name for tooltip)
|
||||||
String creator = getStringOrNull(root, "creator");
|
String creator = getStringOrNull(root, "creator");
|
||||||
|
|
||||||
// Required: animation_bones (per-animation bone whitelist)
|
// Optional: animation_bones (per-animation bone whitelist)
|
||||||
Map<String, Set<String>> animationBones = parseAnimationBones(
|
// When absent, all owned bones are enabled for all animations.
|
||||||
root,
|
Map<String, Set<String>> animationBones;
|
||||||
|
if (!root.has("animation_bones")) {
|
||||||
|
// Not an error — absent means "permissive" (all owned bones, all animations)
|
||||||
|
animationBones = null;
|
||||||
|
LOGGER.info(
|
||||||
|
"[DataDrivenItems] {}: animation_bones not declared — all owned bones enabled for all animations",
|
||||||
fileId
|
fileId
|
||||||
);
|
);
|
||||||
|
// null is fine — the record constructor defaults it to Map.of()
|
||||||
|
} else {
|
||||||
|
animationBones = parseAnimationBones(root, fileId);
|
||||||
if (animationBones == null) {
|
if (animationBones == null) {
|
||||||
|
// Field was present but malformed — parseAnimationBones already logged details
|
||||||
LOGGER.error(
|
LOGGER.error(
|
||||||
"[DataDrivenItems] Skipping {}: missing or invalid 'animation_bones'",
|
"[DataDrivenItems] Skipping {}: 'animation_bones' is present but invalid",
|
||||||
fileId
|
fileId
|
||||||
);
|
);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Optional: components (per-component JSON configs)
|
// Optional: components (per-component JSON configs)
|
||||||
Map<ComponentType, JsonObject> componentConfigs =
|
Map<ComponentType, JsonObject> componentConfigs =
|
||||||
|
|||||||
Reference in New Issue
Block a user