summaryrefslogtreecommitdiff
path: root/mcmap/examples/addchunk
diff options
context:
space:
mode:
authorKevin Chabowski <kevin@kch42.de>2013-09-20 20:29:22 +0200
committerKevin Chabowski <kevin@kch42.de>2013-09-20 20:29:22 +0200
commit659a7f1c7b6f1d63505887604029888324b9a21b (patch)
treec8eaf9fe9827f96dc5deb1ecef70b48e5c50209b /mcmap/examples/addchunk
parentadbb5e30cb07360c2f11694cc5bea69ddeb7529b (diff)
downloadgomcmap-659a7f1c7b6f1d63505887604029888324b9a21b.tar.gz
gomcmap-659a7f1c7b6f1d63505887604029888324b9a21b.tar.bz2
gomcmap-659a7f1c7b6f1d63505887604029888324b9a21b.zip
Adding new chunks kinda works...
They are definetely added but seem to be corrupted.
Diffstat (limited to 'mcmap/examples/addchunk')
-rw-r--r--mcmap/examples/addchunk/main.go45
1 files changed, 45 insertions, 0 deletions
diff --git a/mcmap/examples/addchunk/main.go b/mcmap/examples/addchunk/main.go
new file mode 100644
index 0000000..0ca763f
--- /dev/null
+++ b/mcmap/examples/addchunk/main.go
@@ -0,0 +1,45 @@
+package main
+
+import (
+ "flag"
+ "fmt"
+ "github.com/kch42/gomcmap/mcmap"
+ "os"
+)
+
+func main() {
+ path := flag.String("path", "", "Path to region directory")
+ flag.Parse()
+
+ if *path == "" {
+ flag.Usage()
+ os.Exit(1)
+ }
+
+ region, err := mcmap.OpenRegion(*path, false)
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "Could not open region: %s\n", err)
+ os.Exit(1)
+ }
+
+ chunk, err := region.NewChunk(200, 200)
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "Could not create a Chunk at 200,200: %s\n", err)
+ os.Exit(1)
+ }
+
+ chunk.Iter(func(x, y, z int, blk *mcmap.Block) {
+ blk.ID = mcmap.BlkSandstone
+ })
+
+ chunk.RecalcHeightMap()
+ if err := chunk.MarkUnused(); err != nil {
+ fmt.Fprintf(os.Stderr, "Could not MarkUnused(): %s\n", err)
+ os.Exit(1)
+ }
+
+ if err := region.Save(); err != nil {
+ fmt.Fprintf(os.Stderr, "Could not save region: %s\n", err)
+ os.Exit(1)
+ }
+}