check if bones have an inventory

This commit is contained in:
Thomas Rudin 2019-12-12 22:11:20 +01:00
parent 837055bc20
commit b777635c6a

View File

@ -11,14 +11,18 @@ type BonesBlock struct{}
func (this *BonesBlock) onMapObject(x, y, z int, block *mapblockparser.MapBlock) *mapobjectdb.MapObject { func (this *BonesBlock) onMapObject(x, y, z int, block *mapblockparser.MapBlock) *mapobjectdb.MapObject {
md := block.Metadata.GetMetadata(x, y, z) md := block.Metadata.GetMetadata(x, y, z)
invMap := block.Metadata.GetInventoryMapAtPos(x, y, z)
mainInv := invMap["main"]
if mainInv == nil {
return nil
}
o := mapobjectdb.NewMapObject(block.Pos, x, y, z, "bones") o := mapobjectdb.NewMapObject(block.Pos, x, y, z, "bones")
o.Attributes["time"] = md["time"] o.Attributes["time"] = md["time"]
o.Attributes["owner"] = md["owner"] o.Attributes["owner"] = md["owner"]
o.Attributes["info"] = md["infotext"] o.Attributes["info"] = md["infotext"]
invMap := block.Metadata.GetInventoryMapAtPos(x, y, z)
mainInv := invMap["main"]
itemCount := 0 itemCount := 0
for _, item := range mainInv.Items { for _, item := range mainInv.Items {
itemCount += item.Count itemCount += item.Count