-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
executable file
·42 lines (34 loc) · 1.13 KB
/
main.py
File metadata and controls
executable file
·42 lines (34 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import anvil
import anvil.errors
import os
import datetime
import multiprocessing
DIR = "survival_nether/DIM-1/region"
def ticks_to_str(t:int) -> str:
return str(datetime.timedelta(seconds=round(t/20)))
def handle_file(file:str) -> None:
max_on_f = 0
region = anvil.Region.from_file(DIR + "/" + file)
for i in range(0,32):
for j in range(0,32):
try:
chunk = region.get_chunk(i,j)
inhabited = chunk.data["InhabitedTime"]
max_on_f += inhabited.value
#print(f"{chunk.data["InhabitedTime"]} on {file} {i} {j}")
except Exception as e:
#print(e)
pass
if max_on_f < 12000:
print(f"Terminating {file} {ticks_to_str(max_on_f)}")
os.remove(DIR+"/"+file)
try:
os.remove(DIR.replace("region","entities")+"/"+file)
os.remove(DIR.replace("region","poi")+"/"+file)
except:
pass
else:
print(f"Keeping {file} {ticks_to_str(max_on_f)}")
with multiprocessing.Pool() as pool:
files = os.listdir(DIR)
pool.map(handle_file,files)