overviewer/Minecraft-Overviewer

Generation POI chests with shulker boxes

NakedSkull1991 opened this issue · 2 comments

Hi. I want to customize the display of chests that contain my shulker boxes. I do not know how to work in python, so I wrote by analogy with this Post

As a result, I have ALL chests displayed, and I only need those in which shulker boxes

(the chest icon is the installed shulker box, and the gray chest icon is for the chest containing the shulker box)
изображение
изображение

I would be very grateful if you help

def chestFilter(poi):
	if not "Items" in poi:
		return None
	if poi["id"] in  ["minecraft:chest", "minecraft:trapped_chest"]:
		info = "[%s] \n" % poi["id"]
		info += "%i slots \n" % len(poi["Items"])
		item_sum = 0
		for item in poi["Items"]:
			item_sum += item["Count"]
		info += "%i items \n" % item_sum
		itemText = ""
		for item in poi["Items"]:
			if item["id"] == 372:
				itemText += " %i minecraft:shulker_box " % item["Count"]
		info += itemText
		return info


renders["Day"] = {
        "title": "Day Lighting",
        "rendermode": lighting,
        "dimension": "overworld",
	"markers": [dict(name="marker", filterFunction=marker_Filter),
                    dict(name="marker", filterFunction=marker_Filter, icon="markers/marker_location.png"),
                    dict(name="home", filterFunction=home_Filter, icon="markers/marker_home.png"),
                    dict(name="farm", filterFunction=farm_Filter, icon="markers/marker_hoe_red.png"),
		    dict(name="shulker", filterFunction=shulkerFilter, icon="markers/shulker_box.png"),
	            dict(name="shulker in chest", filterFunction=chestFilter, icon="markers/gray_shulker_box.png"),
                    dict(name="town", filterFunction=town_Filter, icon="markers/marker_town.png")],

I also tried this code, but it doesn't work :/

def chestFilter(poi):
    	if poi['id'] == "Chest" or poi['id'] == "minecraft:chest":
		return "Chest with minecraft:shulker_box items" % len(poi['Items'])

Analogy from this post
изображение

def chestFilter(poi):
    if poi["id"] in ["minecraft:chest", "minecraft:trapped_chest"]:
        if not "Items" in poi:
            return None
        num_shulkers = 0
        for itm in poi["Items"]:
            if "shulker_box" in itm["id"]:
                num_shulkers += 1
        if num_shulkers > 0:
            return "Chest containing {0} Shulker Box{1}".format(num_shulkers,
                                                                "es" if num_shulkers != 1 else "")
        return None