Skip to content

Instantly share code, notes, and snippets.

@Tirpitz93
Last active December 28, 2021 21:42
Show Gist options
  • Save Tirpitz93/74748e4e7e14c55bbfefcf014024d681 to your computer and use it in GitHub Desktop.
Save Tirpitz93/74748e4e7e14c55bbfefcf014024d681 to your computer and use it in GitHub Desktop.
extracts from config file for overviewer with ender chest and shulker box support
def barrelFilter(poi):
import ast, collections
if poi['id'].lower().find("barrel") != -1:
if poi.get("LootTable"):
return
print("processing barrel")
from pprint import pprint
pprint(poi)
_items = 0
_string_value = "Empty Barrel"
if poi.get('Items'):
_string_value = " "
compact_dict = collections.OrderedDict()
for i in poi['Items']:
try:
__name = "<em> {0} </em>".format(ast.literal_eval(i["tag"]["display"]["Name"])["text"])
except:
__name = i["id"].replace("_", " ").title()[i["id"].find(":") + 1:]
print(__name)
if str(i["id"].lower()).find("shulker_box") != -1:
print("found shulker in Barrel")
packed_shulter_string = " with {1} items </br> {2}"
string_value = ""
_s_compact_dict = collections.OrderedDict()
_chest_shulker_item_name = ""
try:
i.get("tag").get("BlockEntityTag").get("Items") # box has items
for j in i["tag"]["BlockEntityTag"]['Items']:
try:
_chest_shulker_item_name = "<em> {0} </em>".format(ast.literal_eval(j.get("tag").get(
"display").get("Name"))["text"])
except:
_chest_shulker_item_name = j["id"].replace("_", " ").title()[j["id"].find(":") + 1:]
print(_chest_shulker_item_name)
# print(_chest_shulker_item_name)
if _chest_shulker_item_name not in _s_compact_dict:
_s_compact_dict[_chest_shulker_item_name] = j['Count']
else:
_s_compact_dict[_chest_shulker_item_name] += j['Count']
for k, v in _s_compact_dict.items():
string_value = string_value + "&nbsp &nbsp {0} {1} {2}".format(
k, v, "</br>")
except:
pass
shulker_string = packed_shulter_string.format(_chest_shulker_item_name, len(_s_compact_dict.items()),
string_value)
print(shulker_string)
if _s_compact_dict.get(_chest_shulker_item_name):
_n = 1
while _s_compact_dict.get(_chest_shulker_item_name):
kp = _s_compact_dict.popitem(_chest_shulker_item_name)
_n += kp[1]
pprint(_s_compact_dict)
print(len(_s_compact_dict))
print(_chest_shulker_item_name, _n)
_chest_shulker_item_name = _chest_shulker_item_name + " " + str(_n)
compact_dict[__name] = shulker_string
elif __name not in compact_dict:
compact_dict[__name] = i['Count']
else:
compact_dict[__name] += i['Count']
for k, v in compact_dict.items():
_string_value = _string_value + ("{0} {1}{2}".format(v, k, "</br>\n"))
_items = len(compact_dict.items())
else:
_items = 0
print("Done processing Barrel")
return ( "Barrel with %d items" % len(poi.get('Items', [])), _string_value)
def chestFilter(poi):
import ast, collections
if poi['id'].lower().find("chest") != -1:
if poi.get("LootTable"):
return
print("processing chest")
from pprint import pprint
pprint(poi)
_items = 0
_string_value = "Empty Chest"
if poi.get('Items'):
_string_value = " "
compact_dict = collections.OrderedDict()
for i in poi['Items']:
try:
__name = "<em> {0} </em>".format(ast.literal_eval(i["tag"]["display"]["Name"])["text"])
except:
__name = i["id"].replace("_", " ").title()[i["id"].find(":") + 1:]
print(__name)
if str(i["id"].lower()).find("shulker_box") != -1:
print("found shulker in chest")
packed_shulter_string = " with {1} items </br> {2}"
string_value = ""
_s_compact_dict = collections.OrderedDict()
_chest_shulker_item_name = ""
try:
i.get("tag").get("BlockEntityTag").get("Items") # box has items
for j in i["tag"]["BlockEntityTag"]['Items']:
try:
_chest_shulker_item_name = "<em> {0} </em>".format(ast.literal_eval(j.get("tag").get(
"display").get("Name"))["text"])
except:
_chest_shulker_item_name = j["id"].replace("_", " ").title()[j["id"].find(":") + 1:]
print(_chest_shulker_item_name)
# print(_chest_shulker_item_name)
if _chest_shulker_item_name not in _s_compact_dict:
_s_compact_dict[_chest_shulker_item_name] = j['Count']
else:
_s_compact_dict[_chest_shulker_item_name] += j['Count']
for k, v in _s_compact_dict.items():
string_value = string_value + "&nbsp &nbsp {0} {1} {2}".format(
k, v, "</br>")
except:
pass
shulker_string = packed_shulter_string.format(_chest_shulker_item_name, len(_s_compact_dict.items()),
string_value)
print(shulker_string)
if _s_compact_dict.get(_chest_shulker_item_name):
_n = 1
while _s_compact_dict.get(_chest_shulker_item_name):
kp = _s_compact_dict.popitem(_chest_shulker_item_name)
_n += kp[1]
pprint(_s_compact_dict)
print(len(_s_compact_dict))
print(_chest_shulker_item_name, _n)
_chest_shulker_item_name = _chest_shulker_item_name + " " + str(_n)
compact_dict[__name] = shulker_string
elif __name not in compact_dict:
compact_dict[__name] = i['Count']
else:
compact_dict[__name] += i['Count']
for k, v in compact_dict.items():
_string_value = _string_value + ("{0} {1}{2}".format(v, k, "</br>\n"))
_items = len(compact_dict.items())
else:
_items = 0
print("Done processing Chest")
return ( "Chest with %d items" % len(poi.get('Items', [])), _string_value)
.leaflet-popup-content {
max-height: 200pt;
overflow-y: auto;
}
def enderChestFilter(poi):
if poi['id'] == "ender_chest" or poi['id'] == 'minecraft:ender_chest':
return ("Ender Chest", "Ender Chest")
global_markers = [dict(name="All signs", filterFunction=signFilter, icon="signpost_icon.png"),
dict(name="Players", filterFunction=playerIcons),
dict(name="Ender Chests", filterFunction=enderChestFilter,icon="/sprites/2132.png"),
dict(name="Chests", filterFunction=chestFilter,icon="/sprites/2134.png"),
dict(name="Shulker Box", filterFunction=shulkerFilter,icon="/sprites/1098.png"),
]
def playerIcons(poi):
from pprint import pprint
import ast, collections
packed_shulter_string = " with {1} items </br> {2}"
# print(poi)
if poi['id'] == 'Player':
# print(poi)
# pprint(poi)
print("processing player")
ender_items_str = ""
inv_item_string = ""
_ender_item_dict = collections.OrderedDict()
_inv_item_dict = collections.OrderedDict()
if poi.get("EnderItems"):
print("precessing EnderItems")
for i in poi["EnderItems"]:
#pprint.pprint(i)
try:
# print(i.get("tag").get("display").get("Name"))
_ender_item_name ="<em> {0} </em>".format( ast.literal_eval(i.get("tag").get("display").get(
"Name"))["text"])
except:
_ender_item_name = i["id"].replace("_", " ").title()[i["id"].find(":") + 1:]
# print(_ender_item_name)
if str(i["id"].lower()).find("shulker_box") != -1:
string_value = ""
# processShulkerBox(i)
print("Found shulker box in ender items")
# print(i["id"])
_s_compact_dict = collections.OrderedDict()
# print(i)
# try:
try:
i.get("tag").get("BlockEntityTag").get("Items") # box has items
for j in i["tag"]["BlockEntityTag"]['Items']:
try:
_ender_shulker_item_name = "<em> {0} </em>".format(ast.literal_eval(j.get("tag").get(
"display").get("Name"))["text"])
except:
_ender_shulker_item_name = j["id"].replace("_", " ").title()[j["id"].find(":") + 1:]
print(_ender_shulker_item_name)
if _ender_shulker_item_name not in _s_compact_dict:
_s_compact_dict[_ender_shulker_item_name] = j['Count']
else:
_s_compact_dict[_ender_shulker_item_name] += j['Count']
for k, v in _s_compact_dict.items():
string_value = string_value + "&nbsp &nbsp {0} {1} {2}".format(
k, v, "</br>")
except:
pass
shulker_string = packed_shulter_string.format(_ender_item_name, len(_s_compact_dict.items()),
string_value)
# print(shulker_string)
if _ender_item_dict.get(_ender_item_name):
_n = 1
while _ender_item_dict.get(_ender_item_name + " " + str(_n)):
_n += 1
_ender_item_name = _ender_item_name + " " + str(_n)
_ender_item_dict[_ender_item_name] = shulker_string # print("shulker string") # print(shulker_string)
elif _ender_item_name not in _ender_item_dict:
_ender_item_dict[_ender_item_name] = i['Count']
else:
_ender_item_dict[_ender_item_name] += i['Count']
"""
"""
print("hello")
if poi.get("Inventory"):
print("loading inventory")
for i in poi["Inventory"]:
print("Inventory Item...")
try:
_inv_item_name ="<em> {0} </em>".format( ast.literal_eval(i.get("tag").get("display").get(
"Name"))["text"])
except:
_inv_item_name = i["id"].replace("_", " ").title()[i["id"].find(":") + 1:]
print(_inv_item_name)
if str(i["id"].lower()).find("shulker_box") != -1:
string_value = ""
# processShulkerBox(i)
print("Found shulker box in inventory")
# print(i["id"])
_s_compact_dict = collections.OrderedDict()
# print(i)
# try:
try:
i.get("tag").get("BlockEntityTag").get("Items") # box has items
for j in i["tag"]["BlockEntityTag"]['Items']:
try:
_i_shulker_item_name = "<em> {0} </em>".format(ast.literal_eval(j.get("tag").get(
"display").get("Name"))["text"])
except:
_i_shulker_item_name = j["id"].replace("_", " ").title()[j["id"].find(":") + 1:]
if _i_shulker_item_name not in _s_compact_dict:
_s_compact_dict[_i_shulker_item_name] = j['Count']
else:
_s_compact_dict[_i_shulker_item_name] += j['Count']
for k, v in _s_compact_dict.items():
string_value = string_value + "&nbsp &nbsp {0} {1} {2}".format(
k, v, "</br>")
except:
pass
shulker_string = packed_shulter_string.format(_inv_item_name, len(_s_compact_dict.items()),
string_value)
print(shulker_string)
if _inv_item_dict.get(_inv_item_name):
_n = 1
while _inv_item_dict.get(_inv_item_name + " " + str(_n)):
_n += 1
_inv_item_name = _inv_item_name + " " + str(_n)
_inv_item_dict[_inv_item_name] = shulker_string # print("shulker string") # print(shulker_string)
elif _inv_item_name not in _inv_item_dict:
_inv_item_dict[_inv_item_name] = i['Count']
else:
_inv_item_dict[_inv_item_name] += i['Count']
# pprint.pprint(_ender_item_dict)
for k, v in _ender_item_dict.items():
ender_items_str = ender_items_str + " {0} {1} {2}".format(str(k)[str(k).find(":") + 1:], v, "</br>")
# print(ender_items_str)
for k, v in _inv_item_dict.items():
inv_item_string = inv_item_string + " {0} {1} {2}".format(str(k)[str(k).find(":") + 1:], v, "</br>")
poi['icon'] = "https://overviewer.org/avatar/%s" % poi['EntityId']
player_string = (
"<h3>Last known location for {0}</h3><br/> <b> Inventory: </b></br> {2}</br> <b> Ender Items: </b> </br>{1} "
"".format(
poi['EntityId'],
ender_items_str,inv_item_string ))
# print(player_string)
return player_string
def playerIcons(poi):
from pprint import pprint
import ast, collections
packed_shulter_string = " with {1} items </br> {2}"
# print(poi)
if poi['id'] == 'Player':
# print(poi)
# pprint(poi)
print("processing player")
ender_items_str = ""
inv_item_string = ""
_ender_item_dict = collections.OrderedDict()
_inv_item_dict = collections.OrderedDict()
"""
"""
if poi.get("EnderItems"):
print("precessing EnderItems")
for i in poi["EnderItems"]:
#pprint.pprint(i)
try:
# print(i.get("tag").get("display").get("Name"))
_ender_item_name ="<em> {0} </em>".format( ast.literal_eval(i.get("tag").get("display").get(
"Name"))["text"])
except:
_ender_item_name = i["id"].replace("_", " ").title()[i["id"].find(":") + 1:]
# print(_ender_item_name)
if str(i["id"].lower()).find("shulker_box") != -1:
string_value = ""
# processShulkerBox(i)
print("Found shulker box in ender items")
# print(i["id"])
_s_compact_dict = collections.OrderedDict()
# print(i)
# try:
try:
i.get("tag").get("BlockEntityTag").get("Items") # box has items
for j in i["tag"]["BlockEntityTag"]['Items']:
try:
_ender_shulker_item_name = "<em> {0} </em>".format(ast.literal_eval(j.get("tag").get(
"display").get("Name"))["text"])
except:
_ender_shulker_item_name = j["id"].replace("_", " ").title()[j["id"].find(":") + 1:]
print(_ender_shulker_item_name)
if _ender_shulker_item_name not in _s_compact_dict:
_s_compact_dict[_ender_shulker_item_name] = j['Count']
else:
_s_compact_dict[_ender_shulker_item_name] += j['Count']
for k, v in _s_compact_dict.items():
string_value = string_value + "&nbsp &nbsp {0} {1} {2}".format(
k, v, "</br>")
except:
pass
shulker_string = packed_shulter_string.format(_ender_item_name, len(_s_compact_dict.items()),
string_value)
# print(shulker_string)
if _ender_item_dict.get(_ender_item_name):
_n = 1
while _ender_item_dict.get(_ender_item_name + " " + str(_n)):
_n += 1
_ender_item_name = _ender_item_name + " " + str(_n)
_ender_item_dict[_ender_item_name] = shulker_string # print("shulker string") # print(shulker_string)
elif _ender_item_name not in _ender_item_dict:
_ender_item_dict[_ender_item_name] = i['Count']
else:
_ender_item_dict[_ender_item_name] += i['Count']
"""
"""
print("hello")
if poi.get("Inventory"):
print("loading inventory")
for i in poi["Inventory"]:
print("Inventory Item...")
try:
_inv_item_name ="<em> {0} </em>".format( ast.literal_eval(i.get("tag").get("display").get(
"Name"))["text"])
except:
_inv_item_name = i["id"].replace("_", " ").title()[i["id"].find(":") + 1:]
print(_inv_item_name)
if str(i["id"].lower()).find("shulker_box") != -1:
string_value = ""
# processShulkerBox(i)
print("Found shulker box in inventory")
# print(i["id"])
_s_compact_dict = collections.OrderedDict()
# print(i)
# try:
try:
i.get("tag").get("BlockEntityTag").get("Items") # box has items
for j in i["tag"]["BlockEntityTag"]['Items']:
try:
_i_shulker_item_name = "<em> {0} </em>".format(ast.literal_eval(j.get("tag").get(
"display").get("Name"))["text"])
except:
_i_shulker_item_name = j["id"].replace("_", " ").title()[j["id"].find(":") + 1:]
if _i_shulker_item_name not in _s_compact_dict:
_s_compact_dict[_i_shulker_item_name] = j['Count']
else:
_s_compact_dict[_i_shulker_item_name] += j['Count']
for k, v in _s_compact_dict.items():
string_value = string_value + "&nbsp &nbsp {0} {1} {2}".format(
k, v, "</br>")
except:
pass
shulker_string = packed_shulter_string.format(_inv_item_name, len(_s_compact_dict.items()),
string_value)
print(shulker_string)
if _inv_item_dict.get(_inv_item_name):
_n = 1
while _inv_item_dict.get(_inv_item_name + " " + str(_n)):
_n += 1
_inv_item_name = _inv_item_name + " " + str(_n)
_inv_item_dict[_inv_item_name] = shulker_string # print("shulker string") # print(shulker_string)
elif _inv_item_name not in _inv_item_dict:
_inv_item_dict[_inv_item_name] = i['Count']
else:
_inv_item_dict[_inv_item_name] += i['Count']
# pprint.pprint(_ender_item_dict)
for k, v in _ender_item_dict.items():
ender_items_str = ender_items_str + " {0} {1} {2}".format(str(k)[str(k).find(":") + 1:], v, "</br>")
# print(ender_items_str)
for k, v in _inv_item_dict.items():
inv_item_string = inv_item_string + " {0} {1} {2}".format(str(k)[str(k).find(":") + 1:], v, "</br>")
poi['icon'] = "https://overviewer.org/avatar/%s" % poi['EntityId']
player_string = (
"<h3>Last known location for {0}</h3><br/> <b> Inventory: </b></br> {2}</br> <b> Ender Items: </b> </br>{1} "
"".format(
poi['EntityId'],
ender_items_str,inv_item_string ))
# print(player_string)
return player_string
def bed(poi):
if poi["id"] == "PlayerSpawn":
poi['icon'] = "bed.png"
return "[%s] \n %s \n" % ("Bed", poi["EntityId"])
def shulkerFilter(poi: dict):
import ast, collections
shulker_string = "<em>{0} </em> with {1} items </br> {2}" # name or id, number of unique items, list of items
if poi['id'].lower().find("shulker_box") != -1:
_name = poi["id"].replace("_", " ").title()[poi["id"].find(":") + 1:]
if poi.get("CustomName"):
import ast
_name = ast.literal_eval(poi["CustomName"])["text"]
_items = 0
_string_value = "Empty Shulker Box"
if poi.get('Items'):
_string_value = " "
compact_dict = collections.OrderedDict()
for i in poi['Items']:
try:
__name = "<em> {0} </em>".format(ast.literal_eval(i["tag"]["display"]["Name"])["text"])
except:
__name = i["id"].replace("_", " ").title()[i["id"].find(":") + 1:]
if __name not in compact_dict:
compact_dict[__name] = i['Count']
else:
compact_dict[__name] += i['Count']
for k, v in compact_dict.items():
_string_value = _string_value + ("{0} {1}{2}".format(v, k, "</br>\n"))
_items = len(compact_dict.items())
return shulker_string.format(_name, _items, _string_value)
pass
def signFilter(poi):
if poi['id'] == 'Sign' or poi['id'] == 'minecraft:sign':
return "\n".join([poi['Text1'], poi['Text2'], poi['Text3'], poi['Text4']])
@Fiuse
Copy link

Fiuse commented May 26, 2020

Hey I saw in your most recent map it seems you made some changes to some of the filters. Would you mind updating them here?

@Tirpitz93
Copy link
Author

Hey I saw in your most recent map it seems you made some changes to some of the filters. Would you mind updating them here?

I can try, my map is also currently broken due to the server running snapshots and changes to the latest MCA data format.

@Tirpitz93
Copy link
Author

I think I have patched every section to the live version.
todo barrels

@Tirpitz93
Copy link
Author

I think I have patched every section to the live version.
todo barrels

  • fixed some errors encountered with specific shulker box configuration that caused endless loops.
  • added barrel config too

@Gamemap
Copy link

Gamemap commented Dec 5, 2020

Can you give me the Pictures (Chest , Enderchest, ...from your Website as a Download link,so I can make my own Overview-Map with trese pictures?

Thanks

@Tirpitz93
Copy link
Author

Can you give me the Pictures (Chest , Enderchest, ...from your Website : https://mcmap.lselter.co.uk/sprites/) as a Download link,so I can make my own Overview-Map with trese pictures?

Thanks

As they are minecraft sprites I would not feel comfortable distributing them per se.
but there is nothing stopping you ripping them from the URL you posted.

@Gamemap
Copy link

Gamemap commented Dec 7, 2020

Ok I will serch for something better.
Thank you

@tomasdev
Copy link

how is your global_markers used?

@Tirpitz93
Copy link
Author

it stores the markers that are applied to all maps (only relevant markers obvs) such as players, chests etc.
it is effectively a special variable name for overviewer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment