A Minecraft datapack generator written in go.

feat(structure): basic impletation

We are not managing the creation of the NBT file for this type because
it's take too much time comparing to move the file created in the game
with structure blocks.

Maybe it will be do in the future to help prevent unvalidated structure
with game updates.

+43
+24
structure/emitter.go
··· 1 + package structure 2 + 3 + import ( 4 + "os" 5 + "path/filepath" 6 + "tangled.org/cosmeak.tngl.sh/weave/internal/generator" 7 + ) 8 + 9 + // The idea here is just to get the data from the file, the filename 10 + // and then move all this information to the datapack. Nothing fancy 11 + // or complicated here. 12 + func (s Structure) Emit() (generator.File, error) { 13 + path := "data/%namespace%/structure/" + filepath.Base(s.filePath) 14 + 15 + content, err := os.ReadFile(s.filePath) 16 + if err != nil { 17 + return generator.File{}, err 18 + } 19 + 20 + return generator.File{ 21 + Path: path, 22 + Content: content, 23 + }, nil 24 + }
+19
structure/structure.go
··· 1 + package structure 2 + 3 + type Structure struct { 4 + filePath string 5 + } 6 + 7 + func MkStructure(name, filePath string) Structure { 8 + return Structure{ 9 + filePath: filePath, 10 + } 11 + } 12 + 13 + func (s Structure) Type() string { 14 + return "structure" 15 + } 16 + 17 + func (s Structure) FilePath() string { 18 + return s.filePath 19 + }