import random

print("Enter snow number: ")
n = int(input())

print("Enter the boundries: <x1> <z1> <x2> <z2>")
inp = input().split(" ")
x1 = int(inp[0])
z1 = int(inp[1])
x2 = int(inp[2])
z2 = int(inp[3])

if (x1 > x2):
    x1, x2 = x2, x1

if (z1 > z2):
    z1, z2 = z2, z1

print("Enter the Y level (it'll be 0.15 blocks lower)")
y = float(input())

print("Enter blocks to skip <x> <z> (enter \"-\" if done)")
exclude = "555"
exclude_list = []

while True:
    exclude = input()
    if exclude == "-":
        break
    exclude = tuple([int(s) for s in exclude.split(" ")])
    exclude_list.append(exclude)

print(f"Setting Snow for {(x2 - x1 + 1) * (z2 - z1 + 1) - len(exclude_list)} blocks")
print("Set Line Limit / Files (0 if no limit): ")
limit = int(input())

line_count = 0
page_count = 1
f = open('snow_gen_code.mcfunction', 'w')

for x in range(x1, x2 + 1, 2):
    for z in range(z1, z2 + 1, 2):
        line_count += 1
        if (x, z) in exclude_list:
            f.write(f"#Skipping {x} {int(y)} {z}\n")
        else:
            possible_layers = [1, 2, 3]
            weight = [70, 20, 10]
            chosen = random.choices(possible_layers, weight, k = 1)
            f.write(f'summon block_display {x}.00 {y - 0.15} {z}.00 {{block_state:{{Name:"snow",Properties:{{layers:"{chosen[0]}"}}}},Tags:["snow{n}"],transformation:{{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[0f,0f,0f],scale:[2f,1f,2f]}}}}\n')
        
        if line_count > limit and limit != 0:
            page_count += 1
            f.write(f"\nfunction system:course/arctic/snow_gen_code_{page_count}")
            f.close()
            f = open(f'snow_gen_code_{page_count}.mcfunction', 'w')
            line_count = 0
    f.write("\n")

f.close()
print("Done!")

'''
1
-150 -501 -104 -521
68
-

'''

'''
-149 -509
-149 -513
-142 -513
-134 -513
-126 -513
-118 -513
-110 -513
-142 -519
-134 -519
-126 -519
-118 -519
-110 -519
-105 -509
-105 -513
-118 -508
'''