From de15862caec5fd4db909c41a5c7f8880eea09b40 Mon Sep 17 00:00:00 2001 From: Thomas Rudin Date: Thu, 10 Jan 2019 16:04:20 +0100 Subject: [PATCH] mapblock functions --- mapblockparser/mapblock.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mapblockparser/mapblock.go b/mapblockparser/mapblock.go index e3c2e1e..d9a9515 100644 --- a/mapblockparser/mapblock.go +++ b/mapblockparser/mapblock.go @@ -8,6 +8,16 @@ type MapBlock struct { BlockMapping map[int]string } +func getNodePos(x,y,z int) int { + return x + (y * 16) + (z * 256) +} + +func (mb *MapBlock) GetNodeName(x,y,z int) string { + pos := getNodePos(x,y,z) + id := readU16(mb.Mapdata, pos * 2) + return mb.BlockMapping[id] +} + func NewMapblock() MapBlock { mb := MapBlock{} mb.Metadata = NewMetadata()