Add StructureManager and NBT template loader for large structures
This commit is contained in:
parent
e33370a049
commit
788983dc88
12 changed files with 1435 additions and 11 deletions
18
internal/worldgen/template_cache.go
Normal file
18
internal/worldgen/template_cache.go
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
package worldgen
|
||||
|
||||
import "sync"
|
||||
|
||||
var (
|
||||
templates = make(map[string]*Template)
|
||||
templatesOnce sync.Once
|
||||
)
|
||||
|
||||
// GetTemplate loads and caches an NBT template from disk.
|
||||
func GetTemplate(name string) *Template {
|
||||
templatesOnce.Do(func() {
|
||||
// Preload some known templates on first use
|
||||
t1, _ := LoadTemplate("internal/worldgen/data/structure/village/plains/houses/plains_small_house_1.nbt")
|
||||
templates["plains_small_house_1"] = t1
|
||||
})
|
||||
return templates[name]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue