def build_structure(self, commands, x, z):
		commands.append(fill(Position(x+1,0,z+0), Position(x+1,0,z+1), base_block()))
		commands.append(fill(Position(x+1,1,z+0), Position(x+1,1,z+1), redstone_dust()))
		commands.append(setblock(Position(x+0,1,z+0), base_block()))
		commands.append(fill(Position(x+0,2,z+0), Position(x+1,2,z+0), base_block()))
		commands.append(fill(Position(x+0,3,z+0), Position(x+1,3,z+0), redstone_dust()))
		commands.append(setblock(Position(x+1,2,z+1), redstone_torch('+z')))
Exemple #2
0
 def _build_module_0(self, x, y):
     X = x * 2
     Y = y * 2
     self.commands.append(
         fill(Position(X, -2, Y), Position(X, -2, Y + 1), base_block()))
     self.commands.append(
         fill(Position(X, -1, Y), Position(X, -1, Y + 1), redstone_dust()))
	def place_output_repeater(self, commands, x, z, direction, left, left_downline):
		if left == None or left_downline == None:
			commands.append(setblock(Position(x+1,1,z+0), repeater(direction)))
		elif type(left.build_handler) == LeftDoubleOff or type(left_downline.build_handler) == LeftDoubleOff:
			commands.append(setblock(Position(x+1,1,z-1), repeater(direction)))
		else:
			commands.append(setblock(Position(x+1,1,z+0), repeater(direction)))
			
Exemple #4
0
 def _copy_module(self, xsrc, ysrc, xdest, ydest):
     Xsrc = xsrc * 2
     Ysrc = ysrc * 2
     Xdest = xdest * 2
     Ydest = ydest * 2
     self.commands.append(
         clone(Position(Xsrc, -4, Ysrc), Position(Xsrc + 1, 1, Ysrc + 1),
               Position(Xdest, -4, Ydest)))
Exemple #5
0
 def _build_module_1(self, x, y):
     self.commands.append(
         fill(Position(x * 2, -2, y * 2), Position(x * 2, -2, y * 2 + 1),
              base_block()))
     self.commands.append(
         fill(Position(x * 2, -1, y * 2), Position(x * 2, -1, y * 2 + 1),
              redstone_dust()))
     self.commands.append(
         setblock(Position(x * 2 + 1, -2, y * 2 + 1), redstone_torch('+x')))
 def _build_inputs(self):
     commands = []
     for x in range(self.length + 1):
         if x % 2 == 0:
             continue
         elif x == 1:
             commands.append(
                 fill(Position(x, 2, 0), Position(x, 2, self.width),
                      base_block()))
             commands.append(
                 fill(Position(x, 3, 0), Position(x, 3, self.width),
                      redstone_dust()))
             if self.input_side == 'left':
                 for z in range(0, self.width, 16):
                     commands.append(
                         setblock(Position(x, 3, z), repeater(facing='+z')))
             if self.input_side == 'right':
                 for z in range(self.width, 0, -16):
                     commands.append(
                         setblock(Position(x, 3, z), repeater(facing='-z')))
         else:
             commands.append(
                 clone(Position(1, 2, 0), Position(1, 3, self.width),
                       Position(x, 2, 0)))
     return commands
Exemple #7
0
 def _build_output_lane(self, Y):
     length = len(self.modules[0]) * 2
     self.commands.append(
         fill(Position(length + 2, -4, Y + 1), Position(2, -4, Y + 1),
              base_block()))
     self.commands.append(
         fill(Position(length + 2, -3, Y + 1), Position(2, -3, Y + 1),
              redstone_dust()))
     torchX = length + 3
     if self.right: torchX = 1
     torchDir = '+x'
     if self.right: torchDir = '-x'
Exemple #8
0
    def _build_module_6(self, x, y):
        X = x * 2
        Y = y * 2
        self.commands.append(
            fill(Position(X, -3, Y), Position(X, -1, Y), base_block()))
        self.commands.append(setblock(Position(X, -2, Y), repeater('-z')))
        self.commands.append(setblock(Position(X, 0, Y), redstone_dust()))

        self.commands.append(setblock(Position(X, -2, Y + 1), base_block()))
        self.commands.append(setblock(Position(X, -1, Y + 1), redstone_dust()))
        self.commands.append(setblock(Position(X + 1, -3, Y), base_block()))
        self.commands.append(setblock(Position(X + 1, -2, Y), redstone_dust()))
Exemple #9
0
 def _place_repeaters(self):
     # Input Lanes
     for x in range(len(self.modules[0])):
         X = x * 2 + 2
         for y in range(7, len(self.modules), 7):
             module = self.modules[y][x]
             if module == 4 or module == 5: y -= 1
             module = self.modules[y][x]
             Y = y * 2 + 2
             if module == 0 or module == 1:
                 self.commands.append(
                     setblock(Position(X, -1, Y), repeater('+z')))
             elif module == 2:
                 self.commands.append(
                     fill(Position(X, 0, Y), Position(X, -1, Y + 1), air()))
                 self.commands.append(
                     setblock(Position(X, -1, Y + 1), redstone_dust()))
             elif module == 3:
                 self.commands.append(
                     setblock(Position(X, -1, Y - 1), repeater('+z')))
                 self.commands.append(
                     setblock(Position(X, -1, Y), base_block()))
             elif module == 6 or module == 7:
                 self.commands.append(
                     setblock(Position(X, 0, Y), repeater('+z')))
                 self.commands.append(
                     setblock(Position(X, 0, Y + 1), base_block()))
     # Output Lanes
     repeaterDir = '+x'
     if self.right: repeaterDir = '-x'
     for x in range(7, len(self.modules[0]), 7):
         X = x * 2 + 2
         for y in range(len(self.modules)):
             Y = y * 2 + 2
             module = self.modules[y][x]
             if module == 1 or module == 6:
                 self.commands.append(
                     setblock(Position(X, -3, Y + 1),
                              repeater(repeaterDir)))
             else:
                 self.commands.append(
                     setblock(Position(X + 1, -3, Y + 1),
                              repeater(repeaterDir)))
Exemple #10
0
    def _build_modules(self):
        self.moduleLocationX = [0] * 8
        self.moduleLocationY = [0] * 8
        for y in range(len(self.modules)):
            for x in range(len(self.modules[y])):
                besty = 0
                bestcount = 0
                for py in range(y - 1, -1,
                                -1):  # for every module below this one
                    if self.modules[y][x] == self.modules[py][
                            x]:  # if the module below matches
                        px = x
                        while px < len(self.modules[y]) and self.modules[y][
                                px] == self.modules[py][px]:
                            px += 1  # find the first pair of self.modules to the right that doesn't match
                        count = px - x - 1
                        #get the difference between the two
                        if count > bestcount:
                            bestcount = count
                            besty = py  #take the greatest count and lock in that line
                    # in other words, this algorithm finds the longest pair of matching lines
                        # this of course happens every iteration
                if bestcount > 1:  #clone the line to save on some commands
                    self._copy_module_line(x + 1, besty + 1, bestcount, x + 1,
                                           y + 1)
                    x += bestcount
                    if x >= len(
                            self.modules[y]
                    ):  # skip the line if it was successfully able to copy it in it's entirty
                        break

                module = self.modules[y][x]
                builder_function = [
                    self._build_module_0, self._build_module_1,
                    self._build_module_2, self._build_module_3,
                    self._build_module_4, self._build_module_5,
                    self._build_module_6, self._build_module_7
                ]
                if self.moduleLocationX[module] == 0 and self.moduleLocationY[
                        module] == 0:
                    builder_function[module](x + 1, y + 1)
                    self.moduleLocationX[module] = x + 1
                    self.moduleLocationY[module] = y + 1
                else:
                    self._copy_module(
                        self.moduleLocationX[module],
                        self.moduleLocationY[module], x + 1,
                        y + 1)  #these copy the module if it was built before
                    if module == 3:
                        self.commands.append(
                            setblock(Position(x * 2 + 4, -3, y * 2 + 2),
                                     base_block()))
        self._build_inputs()
Exemple #11
0
 def _build_module_2(self, x, y):
     self.commands.append(
         setblock(Position(x * 2, -2, y * 2 + 1), base_block()))
     self.commands.append(setblock(Position(x * 2, -3, y * 2),
                                   base_block()))
     self.commands.append(
         setblock(Position(x * 2, -2, y * 2), repeater('+z')))
     self.commands.append(
         fill(Position(x * 2, -1, y * 2), Position(x * 2, -1, y * 2 + 1),
              base_block()))
     self.commands.append(
         fill(Position(x * 2, 0, y * 2), Position(x * 2, 0, y * 2 + 1),
              redstone_dust()))
 def _place_torches(self):
     commands = []
     for x in range(self.length):
         if x % 2 == 1:
             continue
         for z in range(self.width):
             if z % 2 == 1:
                 continue
             if self.table[int(x / 2)][int(z / 2)] == '1':
                 commands.append(
                     setblock(Position(x, 2, z),
                              redstone_torch(facing='-x')))
     if self.input_side == 'left':
         for command in commands:
             command.translate(0, 0, 1)
     return commands
Exemple #13
0
 def _build_inputs(self):
     self.commands.append(
         fill(Position(2, -2, 0), Position(2, -2, 1), base_block()))
     self.commands.append(setblock(Position(2, -1, 0), repeater('+z')))
     self.commands.append(setblock(Position(2, -1, 1), redstone_dust()))
     availableLanes = 1
     leftToBuild = len(self.modules[0]) - 1
     x = 1
     while leftToBuild > 0:
         toCopy = min(availableLanes, leftToBuild)
         depth = toCopy * 2 - 1
         self.commands.append(
             clone(Position(2, -2, 0), Position(2 + depth, -1, 1),
                   Position(x * 2 + 2, -2, 0)))
         availableLanes += toCopy
         leftToBuild -= toCopy
         x += toCopy
 def _build_outputs(self):
     commands = []
     for z in range(self.width):
         if z % 2 == 1:
             continue
         elif z == 0:
             commands.append(
                 fill(Position(0, 0, z), Position(self.length, 0, z),
                      base_block()))
             commands.append(
                 fill(Position(0, 1, z), Position(self.length, 1, z),
                      redstone_dust()))
             for x in range(15, self.length, 16):
                 commands.append(
                     setblock(Position(x, 1, 0), repeater(facing='-x')))
         else:
             commands.append(
                 clone(Position(0, 0, 0), Position(self.length, 1, 0),
                       Position(0, 0, z)))
     if self.input_side == 'left':
         for command in commands:
             command.translate(0, 0, 1)
     return commands
Exemple #15
0
 def generate_build(self, pos_x, pos_y, pos_z, rotation):
     self._add_command(
         setblock(Position(pos_x, pos_y, pos_z),
                  redstone_torch('-x')))
     self._rotate(rotation)
Exemple #16
0
 def generate_build(self, ):
     self._add_command(
         clone(Position(0, 0, 0), Position(1, 1, 1),
               Position(2, 0, 2)))
     self._add_command(
         clone(Position(0, 0, 0), Position(1, 1, 1),
               Position(2, 0, 2)))
     self._add_command(
         clone(Position(0, 0, 0), Position(1, 1, 1),
               Position(2, 0, 2)))
     self._add_command(
         clone(Position(0, 0, 0), Position(1, 1, 1),
               Position(2, 0, 2)))
     self._add_command(
         clone(Position(0, 0, 0), Position(1, 1, 1),
               Position(2, 0, 2)))
     self._add_command(
         clone(Position(0, 0, 0), Position(1, 1, 1),
               Position(2, 0, 2)))
Exemple #17
0
 def generate_build(self, length, width, height, rotation):
     self._add_command(
         clone(Position(0, 0, 0), Position(width, height, length),
               Position(width + 1, 0, length + 1)))
     self._rotate(rotation)
Exemple #18
0
 def generate_build(self, length, width, height):
     self._add_command(
         clone(Position(0, 0, 0), Position(length, height, width),
               Position(length + 1, 0, width + 1)))
Exemple #19
0
 def generate_build(self, pos_x, pos_y, pos_z):
     self._add_command(setblock(Position(0, 0, 0), base_block()))
     self._translate(pos_x, pos_y, pos_z)
Exemple #20
0
 def _copy_output_lanes(self, count, Y):
     length = len(self.modules[0]) * 2
     depth = count * 2 - 1
     self.commands.append(
         clone(Position(1, -3, 2), Position(length + 3, -4, 2 + depth),
               Position(1, -4, Y)))
Exemple #21
0
 def generate_build(self, pos_x, pos_y, pos_z):
     self._add_command(
         clone(Position(0, 0, 0), Position(1, 1, 1),
               Position(2, 0, 2)))
     self._translate(pos_x, pos_y, pos_z)
	def place_input_repeater(self, commands, x, z):
		commands.append(setblock(Position(x+0,3,z+0), repeater('+x')))
Exemple #23
0
 def place_input_repeater(self, commands, x, z):
     commands.append(
         fill(Position(x + 0, 3, z + 0), Position(x + 1, 4, z + 0), air()))
     commands.append(setblock(Position(x + 1, 3, z + 0), redstone_dust()))
Exemple #24
0
 def generate_build(self, pos_x, pos_y, pos_z, rotation):
     self._add_command(
         setblock(Position(pos_x, pos_y, pos_z), base_block()))
     self._rotate(rotation)
Exemple #25
0
 def generate_build(self, length, width, height, rotation):
     self._add_command(
         fill(Position(0, 0, 0), Position(width, height, length),
              base_block()))
     self._rotate(rotation)
 def place_output_repeater(self, commands, x, z, direction, left,
                           left_downline):
     commands.append(
         setblock(Position(x + 1, 1, z + 1), repeater(direction)))
Exemple #27
0
 def generate_build(self, pos_x, pos_y, pos_z):
     self._add_command(
         setblock(Position(pos_x, pos_y, pos_z), redstone_dust()))
Exemple #28
0
 def generate_build(self, pos_x, pos_y, pos_z, rotation):
     self._add_command(
         setblock(Position(pos_x, pos_y, pos_z), repeater('+x')))
     self._rotate(rotation)