From c0ba57b52b2d657c9f7bd05b5f46857eae2f652b Mon Sep 17 00:00:00 2001 From: cosmeak Date: Wed, 14 Jan 2026 10:31:29 +0100 Subject: [PATCH] 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. --- structure/emitter.go | 24 ++++++++++++++++++++++++ structure/structure.go | 19 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 structure/emitter.go create mode 100644 structure/structure.go diff --git a/structure/emitter.go b/structure/emitter.go new file mode 100644 index 0000000..d553b86 --- /dev/null +++ b/structure/emitter.go @@ -0,0 +1,24 @@ +package structure + +import ( + "os" + "path/filepath" + "tangled.org/cosmeak.tngl.sh/weave/internal/generator" +) + +// The idea here is just to get the data from the file, the filename +// and then move all this information to the datapack. Nothing fancy +// or complicated here. +func (s Structure) Emit() (generator.File, error) { + path := "data/%namespace%/structure/" + filepath.Base(s.filePath) + + content, err := os.ReadFile(s.filePath) + if err != nil { + return generator.File{}, err + } + + return generator.File{ + Path: path, + Content: content, + }, nil +} diff --git a/structure/structure.go b/structure/structure.go new file mode 100644 index 0000000..66f3e98 --- /dev/null +++ b/structure/structure.go @@ -0,0 +1,19 @@ +package structure + +type Structure struct { + filePath string +} + +func MkStructure(name, filePath string) Structure { + return Structure{ + filePath: filePath, + } +} + +func (s Structure) Type() string { + return "structure" +} + +func (s Structure) FilePath() string { + return s.filePath +} -- 2.51.2