SpyglassMC / Spyglass

Development tools for vanilla Minecraft: Java Edition data pack developers.
https://spyglassmc.com
MIT License
315 stars 32 forks source link

Nested mcdoc spread operator failing to appear at runtime #1537

Open Alumopper opened 3 months ago

Alumopper commented 3 months ago

The complete code can be found at ui.mcdoc

struct UI {
    type: #[dispatcher_key="floating_ui:ui"] string,
    name?: string,
    tag?: string,
    ...floating_ui:ui[[type]]
}

struct Control {
    x?: double,
    y?: double,
    size?: [float]@2,
    rotation?: [float]@4,
    display?: enum(string){
        none = "none",
        thirdperson_lefthand = "thirdperson_lefthand",
        thirdperson_righthand = "thirdperson_righthand",
        firstperson_lefthand = "firstperson_lefthand",
        firstperson_righthand = "firstperson_righthand",
        head = "head",
        gui = "gui",
        ground = "ground",
        fixed = "fixed"
    },
    item?: Item,
    move_in?: string,
    move_out?: string,
    anim?: ControlAnimate,
    children?: [int[]@4]
}

dispatch floating_ui:ui[panel] to struct Panel {
    ...Control,
    child: [Control]
}

When I type data modify storage floating_ui:input data set value {“type”:"panel",}, there should be suggestion for members defined in struct Panel

{A9D6F85C-C2FE-4878-8D0A-49B91D1F167A}

There are only members defined in struct UI can be auto-complete:

{04F04278-6BB6-4966-974C-EEDB1CBDB2B2}

misode commented 3 months ago

Minimal reproduction steps::

dispatch minecraft:storage["floating_ui:input"] to struct {
    data: UI,
} 

struct UI {
    type: #[dispatcher_key="floating_ui:ui"] string,
    name?: string,
    ...floating_ui:ui[[type]],
}

dispatch floating_ui:ui[panel] to struct Panel {
    child: int,
}