summaryrefslogtreecommitdiff
path: root/mcmap/examples
diff options
context:
space:
mode:
authorKevin Chabowski <kevin@kch42.de>2013-08-12 15:44:06 +0200
committerKevin Chabowski <kevin@kch42.de>2013-08-12 15:44:06 +0200
commitf194b131e0cac55d1937e75c98edf62ba04e1df4 (patch)
treef2f762f1d5d7038bfe95b2a9e8a5bedbef5575cd /mcmap/examples
parentbb8ddfbc5574a7682594fd15178083f5308766e7 (diff)
downloadgomcmap-f194b131e0cac55d1937e75c98edf62ba04e1df4.tar.gz
gomcmap-f194b131e0cac55d1937e75c98edf62ba04e1df4.tar.bz2
gomcmap-f194b131e0cac55d1937e75c98edf62ba04e1df4.zip
Added Iter function to Chunk
Diffstat (limited to 'mcmap/examples')
-rw-r--r--mcmap/examples/emeraldfinder/main.go15
-rw-r--r--mcmap/examples/replace/main.go15
2 files changed, 10 insertions, 20 deletions
diff --git a/mcmap/examples/emeraldfinder/main.go b/mcmap/examples/emeraldfinder/main.go
index 3249a35..ea22624 100644
--- a/mcmap/examples/emeraldfinder/main.go
+++ b/mcmap/examples/emeraldfinder/main.go
@@ -36,17 +36,12 @@ chunkLoop:
os.Exit(1)
}
- for y := 0; y < mcmap.ChunkSizeY; y++ {
- for x := 0; x < mcmap.ChunkSizeXZ; x++ {
- for z := 0; z < mcmap.ChunkSizeXZ; z++ {
- blk := chunk.Block(x, y, z)
- if blk.ID == mcmap.BlkEmeraldOre {
- absx, absz := mcmap.ChunkToBlock(cx, cz, x, z)
- fmt.Printf("%d, %d, %d\n", absx, y, absz)
- }
- }
+ chunk.Iter(func(x, y, z int, blk *mcmap.Block) {
+ if blk.ID == mcmap.BlkEmeraldOre {
+ absx, absz := mcmap.ChunkToBlock(cx, cz, x, z)
+ fmt.Printf("%d, %d, %d\n", absx, y, absz)
}
- }
+ })
chunk.MarkUnused()
}
diff --git a/mcmap/examples/replace/main.go b/mcmap/examples/replace/main.go
index 87dd677..d289522 100644
--- a/mcmap/examples/replace/main.go
+++ b/mcmap/examples/replace/main.go
@@ -37,17 +37,12 @@ chunkLoop:
}
modified := false
- for y := 0; y < mcmap.ChunkSizeY; y++ {
- for x := 0; x < mcmap.ChunkSizeXZ; x++ {
- for z := 0; z < mcmap.ChunkSizeXZ; z++ {
- blk := chunk.Block(x, y, z)
- if blk.ID == mcmap.BlkBlockOfIron {
- blk.ID = mcmap.BlkBlockOfDiamond
- modified = true
- }
- }
+ chunk.Iter(func(x, y, z int, blk *mcmap.Block) {
+ if blk.ID == mcmap.BlkBlockOfIron {
+ blk.ID = mcmap.BlkBlockOfDiamond
+ modified = true
}
- }
+ })
if modified {
fmt.Printf("Modified chunk %d, %d.\n", cx, cz)