Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import mcrcon
- import sys
- import time
- if len(sys.argv) < 7:
- print("Usage: python3 import.py <server> <port> <password> <start x> <start y> <start z>")
- sys.exit()
- address = sys.argv[1]
- port = int(sys.argv[2])
- password = sys.argv[3]
- current_x = int(sys.argv[4])
- current_y = int(sys.argv[5])
- current_z = int(sys.argv[6]) + 3
- relative_x = 0
- relative_y = 0
- relative_z = 3
- y_offset = 0
- max_y = 3
- highest_y = [0]
- cur_highest = 0
- dir = 5
- length = 31
- rlength = length - 1
- conditional = False
- rcon = mcrcon.MCRcon()
- rcon.connect(address,port)
- rcon.login(password)
- cmds = []
- with open("cmds.txt") as f:
- cmd_lines = f.readlines()
- cmds = [x.rstrip().replace('"','\\"') for x in cmd_lines]
- count = 0
- comment = False
- first_shift = True
- mode = "main"
- def shift():
- global cur_highest
- global highest_y
- global current_x
- global current_y
- global current_z
- global relative_x
- global relative_y
- global relative_z
- global dir
- global max_y
- global y_offset
- global first_shift
- highest_y.append(cur_highest)
- if mode == "op":
- print(str(count))
- setblock("minecraft:repeating_command_block", store_x, store_y, store_z, store_dir, "{auto:1b,Command:\"execute @e[type=armor_stand,tag=cursor] ~ ~ ~ testforblock ~ ~-1 ~ " + store_block + " -1\",TrackOutput:0b}")
- setblock("minecraft:chain_command_block", store_x+1, store_y, store_z, store_dir+8, "{auto:1b,Command:\"fill ~-1 ~ ~-1 ~" + str(rlength-2) + " ~" + str(cur_highest) + " ~-1 redstone_block 0 replace\",TrackOutput:0b}")
- setblock("minecraft:wall_sign", store_x-1, store_y, store_z, 4, '{Text1:"{\\"text\\":\\"@op\\"}",Text2:"{\\"text\\":\\"' + store_name + '\\"}",Text3:"{\\"text\\":\\"\\"}",Text4:"{\\"text\\":\\"\\"}"}')
- f_command = "fill ~" + str(store_x - current_x) + " ~" + str(store_y - current_y) + " ~-1 ~" + str((store_x + rlength) - current_x) + " ~" + str((store_y + cur_highest) - current_y) + " ~-1 quartz_block 0 replace"
- setblock("minecraft:chain_command_block", current_x, current_y, current_z, dir, "{auto:0b,Command:\"" + f_command + "\",TrackOutput:0b}")
- else:
- first_shift = False
- cur_highest = 0
- max_y = 2 + max(highest_y)
- current_z -= 3
- relative_z -= 3
- current_y -= relative_y
- relative_y = 0
- if relative_z < -rlength:
- current_z += (-rlength - relative_z) + rlength
- relative_z = 0
- y_offset += max_y
- current_y += y_offset
- relative_y += y_offset
- current_x -= relative_x
- relative_x = 0
- dir = 5
- return current_x, current_y, current_z
- def next():
- global current_x
- global current_y
- global current_z
- global relative_x
- global relative_y
- global relative_z
- global dir
- global cur_highest
- if dir == 5:
- current_x += 1
- relative_x += 1
- if relative_x == rlength:
- dir = 1
- elif dir == 4:
- current_x -= 1
- relative_x -= 1
- if relative_x == 0:
- dir = 1
- elif dir == 1:
- current_y += 1
- relative_y += 1
- cur_highest += 1
- if relative_x == 0:
- dir = 5
- elif relative_x == rlength:
- dir = 4
- def setblock(id, x, y, z, damage, nbt):
- global rcon
- global conditional
- success = False
- if conditional == True:
- damage += 8
- conditional = False
- if id == "minecraft:wall_sign":
- damage = 4
- while success != True:
- try:
- rcon.command("setblock %s %s %s %s %s replace %s" % (str(x),str(y),str(z),str(id),str(damage),str(nbt)))
- success = True
- except:
- print("Crashed... Waiting 10 seconds to retry.")
- time.sleep(10)
- rcon = mcrcon.MCRcon()
- rcon.connect(address,port)
- rcon.login(password)
- for cmd in cmds:
- count += 1
- if count % 50 == 0:
- print(str(count) + "/" + str(len(cmds)) + " completed.")
- if cmd[0:2] == "/*":
- comment = True
- if comment == False:
- if cmd[0:1] == "@":
- current_x, current_y, current_z = shift()
- if cmd[1:5] == "Main":
- setblock("minecraft:repeating_command_block",current_x,current_y,current_z, dir, "{auto:1b,Command:\"//@Main Loop\",TrackOutput:0b}")
- setblock("minecraft:wall_sign", current_x-1,current_y, current_z, 4, '{Text1:"{\\"text\\":\\"@Main\\"}",Text2:"{\\"text\\":\\"\\"}",Text3:"{\\"text\\":\\"\\"}",Text4:"{\\"text\\":\\"\\"}"}')
- mode = "main"
- elif cmd[1:3] == "op":
- block = "minecraft:" + cmd.split(" ")[1]
- store_x = current_x
- store_y = current_y
- store_z = current_z
- store_block = block
- store_dir = dir
- store_name = cmd.split(" ")[1]
- mode = "op"
- next()
- next()
- else:
- if len(cmd) < 2048:
- if mode == "op":
- setblock("minecraft:chain_command_block", current_x, current_y, current_z, dir, "{auto:0b,Command:\"" + cmd + "\",TrackOutput:0b}")
- elif mode == "main":
- setblock("minecraft:chain_command_block", current_x, current_y, current_z, dir, "{auto:1b,Command:\"" + cmd + "\",TrackOutput:0b}")
- else:
- print("- CMD TOO LONG- [" + str(count) + "]")
- print(cmd)
- print("- CMD TOO LONG- [" + str(count) + "]")
- setblock("minecraft:chain_command_block", current_x, current_y, current_z, dir, "{auto:1b,Command:\"PASTE HERE\",TrackOutput:0b}")
- setblock("minecraft:glass", current_x, current_y, current_z+1, 0, "")
- next()
- time.sleep(0.01)
- if cmd.find("*/") >= 0:
- comment = False
- shift()
Advertisement
Add Comment
Please, Sign In to add comment