SpyglassMC / Spyglass

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

Add syntax templating to mcdoc #1223

Open MulverineX opened 4 months ago

MulverineX commented 4 months ago

When defining types, autocomplete should immediately appear with predefined template/code snippet options.

Example:

dispatch minecraft:resource[pack] to struct Pack {
    pack: struct {
        #[pack_format]
        pack_format: (
            (int @ 1..) |
            (#[default] 47) |
        ),
        description: Text,
    },
    #[since=1.19]
    filter?: PackFilter,
    #[since="1.19.3"]
    features?: PackFeatures,
}
  1. User creates data folder
  2. Creates & opens pack.mcmeta
  3. Presented with template autocomplete
  4. Hits tab, is prompted to fill in required fields, can tab complete to #[default] values.
SPGoding commented 3 months ago

can we infer the template from the normal type definition? maybe even with #[default] attributes on individual fields for the placeholder values. i don't see the point of repeating so much information with a weird #[template] attribute.

MulverineX commented 3 months ago

I guess someone could still do something like this after inject is introduced, if #[default] was added:

use ::java::server::world::entity::display::DisplayBase

inject DisplayBase::transformation::__union to (#[default] [1f,0f,0f,0f,0f,1f,0f,0f,0f,0f,1f,0f,0f,0f,0f,1f])
MulverineX commented 3 months ago

Modified the initial suggestion