A Minecraft datapack generator written in go.
at main 46 lines 869 B view raw
1package function 2 3type Function struct { 4 namespace string 5 name string 6 commands []string 7} 8 9func MkFunction(name string, commands ...string) Function { 10 return Function{ 11 name: name, 12 commands: commands, 13 } 14} 15 16func MkFunctionWithNamespace(namespace, name string, commands ...string) Function { 17 return Function{ 18 namespace: namespace, 19 name: name, 20 commands: commands, 21 } 22} 23 24func (f Function) Type() string { 25 return "function" 26} 27 28func (f Function) Name() string { 29 return f.name 30} 31 32func (f Function) Commands() []string { 33 commands := make([]string, len(f.commands)) 34 copy(commands, f.commands) 35 return commands 36} 37 38func (f Function) AddCommand(command string) Function { 39 f.commands = append(f.commands, command) 40 return f 41} 42 43func (f Function) AddCommands(commands ...string) Function { 44 f.commands = append(f.commands, commands...) 45 return f 46}