A Minecraft datapack generator written in go.
at main 24 lines 447 B view raw
1package function 2 3import ( 4 "path" 5 "strings" 6 7 "tangled.org/cosmeak.tngl.sh/weave/internal/generator" 8) 9 10func (f Function) Emit() (generator.File, error) { 11 content := strings.Join(f.commands, "\n") 12 13 namespace := "" 14 if f.namespace != "" { 15 namespace = f.namespace 16 } else { 17 namespace = "%namespace%" 18 } 19 20 return generator.File{ 21 Path: path.Join("data", namespace, "function", f.name+".mcfunction"), 22 Content: []byte(content), 23 }, nil 24}