示例#1
0
文件: tally.go 项目: trichner/mctools
// TallyInRegion counts the number of times each of the given items occurs
// in the specified region.
//
// If the given item set is empty, all blocks will be counted.
func TallyInRegion(r *anvil.Region, items ...item.Id) TallyResult {
	var chunk anvil.Chunk
	out := make(TallyResult)

	for _, xz := range r.Chunks() {
		if !r.ReadChunk(xz[0], xz[1], &chunk) {
			continue
		}

		tallyInChunk(&chunk, items, out)
	}

	return out
}
示例#2
0
文件: find.go 项目: trichner/mctools
// FindInRegion locates all blocks in the specified region,
// matching the given query.
func FindInRegion(r *anvil.Region, q Query) BlockList {
	var out BlockList
	var chunk anvil.Chunk
	var loc Block

	loc.RX = int8(r.X)
	loc.RZ = int8(r.Z)

	for _, xz := range r.Chunks() {
		if !r.ReadChunk(xz[0], xz[1], &chunk) {
			continue
		}

		findInChunk(&chunk, q, loc, &out)
	}

	return out
}
示例#3
0
文件: find.go 项目: trichner/mctools
// FindDungeons finds all dungeons by locating and returning all mob spawners.
func FindDungeons(r *anvil.Region) []*anvil.TileEntity {
	var out []*anvil.TileEntity
	var chunk anvil.Chunk

	for _, xz := range r.Chunks() {
		if !r.ReadChunk(xz[0], xz[1], &chunk) {
			continue
		}

		for i := range chunk.TileEntities {
			if chunk.TileEntities[i].Id == "MobSpawner" {
				out = append(out, &chunk.TileEntities[i])
			}
		}
	}

	return out
}