public static IBlockState[][][] getStateMap(
      EnumFacing dir,
      String mapName,
      IBlockState wallBlock,
      IBlockState wallBlock_external,
      IBlockState floorBlock,
      IBlockState ceilBlock,
      IBlockState fenceBlock,
      IBlockState carpetBlock,
      IBlockState glass1,
      IBlockState glass2,
      IBlockState glass3,
      IBlockState window,
      IBlockState mineral,
      int dyeColorIndex) {
    final boolean hasShop = fenceBlock != null;
    final boolean hasBeacon = !hasShop && mineral != null;
    final int mapIndex = EnumStateMap.valueOf(mapName).ordinal();
    final Map<EnumFacing, IBlockState[][][]> map = maps.get(wallBlock_external)[mapIndex];
    final IBlockState[][][] stateMap;
    final IBlockState air2 = Blocks.AIR.getDefaultState(),
        lever = !hasBeacon ? Blocks.LEVER.getStateFromMeta(7) : glass2 != null ? glass2 : air2,
        glass = Blocks.GLASS.getDefaultState(),
        lamp = !hasBeacon ? Blocks.REDSTONE_LAMP.getDefaultState() : glass1,
        wire = !hasBeacon ? Blocks.REDSTONE_WIRE.getDefaultState() : air2;
    if (mapName.startsWith("MINI_TOWER_TOP")) {
      EnumFacing pressurePlateDir = null;
      if (floorBlock.getBlock() instanceof BlockTrapDoor) {
        pressurePlateDir = floorBlock.getValue(BlockTrapDoor.FACING);
        floorBlock = MazeTowers.BlockMazeTowerThreshold.getDefaultState();
      }
      map.put(
          dir,
          !hasShop
              ? getTopMap(
                  air2,
                  wallBlock_external,
                  carpetBlock,
                  window,
                  floorBlock,
                  lever,
                  mineral,
                  pressurePlateDir)
              : getTopMapShop(air2, wallBlock_external, carpetBlock, window, fenceBlock, mineral));
    } else if (mapName.startsWith("MINI_TOWER_ROOF")) {
      if (mapName.equals("MINI_TOWER_ROOF_WIRE"))
        map.put(dir, getRoofWire(air2, wallBlock_external, wire, glass3));
      else map.put(dir, getRoof(fenceBlock, glass, glass1, glass2, glass3));
    } else if (mapName.startsWith("MINI_TOWER_CEILING_"))
      map.put(dir, getCeiling(air2, wallBlock_external, wallBlock, ceilBlock, glass1, lamp));
    else if (mapName.equals("MINI_TOWER_BASE")) {
      map.get(dir)[0][4][4] = floorBlock;
    }

    return map.get(dir);
  }
  @Override
  public void onUpdate() {
    super.onUpdate();

    if (supertile.getWorld().isRemote || redstoneSignal > 0) return;

    if (ticksExisted % 10 == 0) {
      IBlockState filter = getUnderlyingBlock();

      boolean scanned = false;
      List<BlockPos> validPositions = new ArrayList<>();

      int rangePlace = getRange();
      int rangePlaceY = getRangeY();

      BlockPos pos = supertile.getPos();

      List<EntityItem> items =
          supertile
              .getWorld()
              .getEntitiesWithinAABB(
                  EntityItem.class,
                  new AxisAlignedBB(
                      supertile.getPos().add(-RANGE, -RANGE_Y, -RANGE),
                      supertile.getPos().add(RANGE + 1, RANGE_Y + 1, RANGE + 1)));
      int slowdown = getSlowdownFactor();
      for (EntityItem item : items) {
        int age;
        try {
          age = (int) MethodHandles.itemAge_getter.invokeExact(item);
        } catch (Throwable t) {
          continue;
        }

        if (age < (60 + slowdown) || item.isDead) continue;

        ItemStack stack = item.getEntityItem();
        Item stackItem = stack.getItem();
        if (stackItem instanceof ItemBlock
            || stackItem instanceof ItemBlockSpecial
            || stackItem instanceof ItemRedstone
            || stackItem instanceof IFlowerPlaceable) {
          if (!scanned) {
            for (BlockPos pos_ :
                BlockPos.getAllInBox(
                    pos.add(-rangePlace, -rangePlaceY, -rangePlace),
                    pos.add(rangePlace, rangePlaceY, rangePlace))) {
              IBlockState stateAbove = supertile.getWorld().getBlockState(pos_.up());
              Block blockAbove = stateAbove.getBlock();
              BlockPos up = pos_.up();
              if (filter == supertile.getWorld().getBlockState(pos_)
                  && (blockAbove.isAir(stateAbove, supertile.getWorld(), up)
                      || blockAbove.isReplaceable(supertile.getWorld(), up)))
                validPositions.add(up);
            }

            scanned = true;
          }

          if (!validPositions.isEmpty()) {
            BlockPos coords =
                validPositions.get(supertile.getWorld().rand.nextInt(validPositions.size()));

            IBlockState stateToPlace = null;
            if (stackItem instanceof IFlowerPlaceable)
              stateToPlace =
                  ((IFlowerPlaceable) stackItem).getBlockToPlaceByFlower(stack, this, coords);
            if (stackItem instanceof ItemBlock)
              stateToPlace =
                  ((ItemBlock) stackItem)
                      .block.getStateFromMeta(stackItem.getMetadata(stack.getItemDamage()));
            else if (stackItem instanceof ItemBlockSpecial)
              stateToPlace =
                  ((Block)
                          ReflectionHelper.getPrivateValue(
                              ItemBlockSpecial.class,
                              (ItemBlockSpecial) stackItem,
                              LibObfuscation.REED_ITEM))
                      .getDefaultState();
            else if (stackItem instanceof ItemRedstone)
              stateToPlace = Blocks.REDSTONE_WIRE.getDefaultState();

            if (stateToPlace != null) {
              if (stateToPlace.getBlock().canPlaceBlockAt(supertile.getWorld(), coords)) {
                supertile.getWorld().setBlockState(coords, stateToPlace, 1 | 2);
                if (ConfigHandler.blockBreakParticles)
                  supertile.getWorld().playEvent(2001, coords, Block.getStateId(stateToPlace));
                validPositions.remove(coords);

                TileEntity tile = supertile.getWorld().getTileEntity(coords);
                if (tile != null && tile instanceof ISubTileContainer) {
                  ISubTileContainer container = (ISubTileContainer) tile;
                  String subtileName = ItemBlockSpecialFlower.getType(stack);
                  container.setSubTile(subtileName);
                  SubTileEntity subtile = container.getSubTile();
                  subtile.onBlockPlacedBy(
                      supertile.getWorld(),
                      coords,
                      supertile.getWorld().getBlockState(coords),
                      null,
                      stack);
                }

                if (stackItem instanceof IFlowerPlaceable)
                  ((IFlowerPlaceable) stackItem).onBlockPlacedByFlower(stack, this, coords);

                stack.stackSize--;
                if (stack.stackSize <= 0) item.setDead();

                if (mana > 1) mana--;
                return;
              }
            }
          }
        }
      }
    }
  }
  public static void initStateMaps(MazeTower tower) {
    if (rawMaps != null && rawMaps.containsKey(tower.wallBlock_external)) {
      final EnumDyeColor[] dyeColors = tower.getDyeColors();
      final IBlockState air2 = Blocks.AIR.getDefaultState();
      final IBlockState wall = tower.wallBlock_external;
      final IBlockState wall2 = tower.wallBlock;
      final IBlockState c = tower.floorBlock;
      final IBlockState window = Blocks.GLASS_PANE.getDefaultState();
      final IBlockState[] carpet =
          new IBlockState[] {
            tower.getColourBlockState(Blocks.CARPET, dyeColors[0]),
            tower.getColourBlockState(Blocks.CARPET, dyeColors[1]),
            tower.getColourBlockState(Blocks.CARPET, dyeColors[2])
          };
      final IBlockState[] g =
          new IBlockState[] {
            tower.getColourBlockState(Blocks.STAINED_GLASS, dyeColors[0]),
            tower.getColourBlockState(Blocks.STAINED_GLASS, dyeColors[1]),
            tower.getColourBlockState(Blocks.STAINED_GLASS, dyeColors[2])
          };
      final IBlockState lamp = Blocks.REDSTONE_LAMP.getDefaultState();
      final IBlockState wire = Blocks.REDSTONE_WIRE.getDefaultState();

      for (EnumFacing dir : dirs) {
        maps.get(tower.wallBlock_external)[EnumStateMap.MINI_TOWER_CEILING_1.ordinal()].put(
            dir, getCeiling(air2, wall, wall2, c, g[0], lamp));
        maps.get(tower.wallBlock_external)[EnumStateMap.MINI_TOWER_CEILING_2.ordinal()].put(
            dir, getCeiling(air2, wall, wall2, c, g[1], lamp));
        maps.get(tower.wallBlock_external)[EnumStateMap.MINI_TOWER_CEILING_3.ordinal()].put(
            dir, getCeiling(air2, wall, wall2, c, g[2], lamp));
      }
    } else {
      final IBlockState[][][][] towerRawMaps;
      final Map<EnumFacing, IBlockState[][][]>[] towerMaps;

      if (rawMaps == null) {
        rawMaps = new HashMap<IBlockState, IBlockState[][][][]>();
        maps = new HashMap<IBlockState, Map<EnumFacing, IBlockState[][][]>[]>();
      }
      towerRawMaps = getRawMapsForTower(tower);
      rawMaps.put(tower.wallBlock_external, towerRawMaps);
      towerMaps = new Map[EnumStateMap.values().length];

      for (EnumStateMap map : EnumStateMap.values()) {
        final int mapIndex = map.ordinal();
        towerMaps[mapIndex] = new HashMap<EnumFacing, IBlockState[][][]>();
        for (EnumFacing dir : dirs) {
          final EnumFacing checkDir = EnumFacing.NORTH;
          if (dir == EnumFacing.SOUTH) towerMaps[mapIndex].put(dir, towerRawMaps[mapIndex]);
          else {
            if (mapIndex != 1)
              towerMaps[mapIndex].put(
                  dir, MTHelper.getRotatedStateMap(towerRawMaps[mapIndex], checkDir, dir, true));
            else
              towerMaps[mapIndex].put(
                  dir,
                  MTHelper.getRotatedStateMap(
                      MTHelper.getStairRotatedStairsMap(
                          towerRawMaps[mapIndex], EnumFacing.SOUTH, dir, tower.stairsBlock, torch),
                      checkDir,
                      dir,
                      true));
          }
        }
      }

      maps.put(tower.wallBlock_external, towerMaps);
    }
  }
  public static IBlockState[][][][] getRawMapsForTower(MazeTower tower) {
    final EnumDyeColor[] dyeColors = tower.getDyeColors();
    final IBlockState air = tower.air,
        air2 = Blocks.AIR.getDefaultState(),
        wall = tower.wallBlock_external,
        wall2 = tower.wallBlock,
        floor = tower.floorBlock,
        c = tower.ceilBlock,
        fence = tower.fenceBlock,
        floor2 =
            !(wall.getBlock() instanceof BlockPrismarine)
                ? floor
                : Blocks.SEA_LANTERN.getDefaultState();
    final IBlockState[]
        carpet =
            new IBlockState[] {
              tower.getColourBlockState(Blocks.CARPET, dyeColors[0]),
              tower.getColourBlockState(Blocks.CARPET, dyeColors[1]),
              tower.getColourBlockState(Blocks.CARPET, dyeColors[2])
            },
        g =
            new IBlockState[] {
              tower.getColourBlockState(Blocks.STAINED_GLASS, dyeColors[0]),
              tower.getColourBlockState(Blocks.STAINED_GLASS, dyeColors[1]),
              tower.getColourBlockState(Blocks.STAINED_GLASS, dyeColors[2])
            },
        window =
            new IBlockState[] {
              tower.getColourBlockState(Blocks.STAINED_GLASS_PANE, dyeColors[0]),
              tower.getColourBlockState(Blocks.STAINED_GLASS_PANE, dyeColors[1]),
              tower.getColourBlockState(Blocks.STAINED_GLASS_PANE, dyeColors[2])
            };
    final IBlockState lever = Blocks.LEVER.getStateFromMeta(7),
        lamp = Blocks.REDSTONE_LAMP.getDefaultState(),
        wire = Blocks.REDSTONE_WIRE.getDefaultState();
    final IBlockState[] stairs = tower.stairsBlock;
    final IBlockState[][][][] rawMaps =
        new IBlockState[][][][] {
          {
            {
              {null, null, null, wall, wall, wall, null, null, null},
              {null, null, wall, wall2, wall2, wall2, wall, null, null},
              {null, wall, floor, floor, floor, floor, floor, wall, null},
              {wall, wall2, floor, floor, floor, floor, floor, wall2, wall},
              {wall, wall2, floor, floor, floor2, floor, floor, wall2, wall},
              {wall, wall2, floor, floor, floor, floor, floor, wall2, wall},
              {null, wall, floor, floor, floor, floor, floor, wall, null},
              {null, null, wall, wall2, wall2, wall2, wall, null, null},
              {null, null, null, wall, wall, wall, null, null, null}
            }
          },
          {
            {
              {null, null, null, wall, wall, wall, null, null, null},
              {null, null, wall, wall2, wall2, wall2, wall, null, null},
              {null, wall, wall, air, air, air, air, wall, null},
              {wall, wall2, wall, air, air, air, air, wall2, wall},
              {wall, wall2, wall, air, air, air, air, wall2, wall},
              {wall, wall2, stairs[2], air, air, air, air, wall2, wall},
              {null, wall, air, air, air, air, air, wall, null},
              {null, null, wall, wall2, wall2, wall2, wall, null, null},
              {null, null, null, wall, wall, wall, null, null, null}
            },
            {
              {null, null, null, wall, wall, wall, null, null, null},
              {null, null, wall, wall2, wall2, wall2, wall, null, null},
              {null, wall, wall, air, air, air, air, wall, null},
              {wall, wall2, wall, air, air, air, air, wall2, wall},
              {wall, wall2, stairs[2], air, air, air, air, wall2, wall},
              {wall, wall2, air, air, air, air, air, wall2, wall},
              {null, wall, torch[3], air, air, air, air, wall, null},
              {null, null, wall, wall2, wall2, wall2, wall, null, null},
              {null, null, null, wall, wall, wall, null, null, null}
            },
            {
              {null, null, null, wall, wall, wall, null, null, null},
              {null, null, wall, wall2, wall2, wall2, wall, null, null},
              {null, wall, floor, floor, floor, floor, floor, wall, null},
              {wall, wall2, stairs[2], floor, floor, floor, floor, wall2, wall},
              {wall, wall2, air, floor, floor2, floor, floor, wall2, wall},
              {wall, wall2, air, floor, floor, floor, floor, wall2, wall},
              {null, wall, air, floor, floor, floor, floor, wall, null},
              {null, null, wall, wall2, wall2, wall2, wall, null, null},
              {null, null, null, wall, wall, wall, null, null, null}
            },
            {
              {null, null, null, wall, wall, wall, null, null, null},
              {null, null, wall, wall2, wall2, wall2, wall, null, null},
              {null, wall, air, stairs[3], wall, wall, wall, wall, null},
              {wall, wall2, air, air, air, air, air, wall2, wall},
              {wall, wall2, air, air, air, air, air, wall2, wall},
              {wall, wall2, air, air, air, air, air, wall2, wall},
              {null, wall, air, air, air, air, air, wall, null},
              {null, null, wall, wall2, wall2, wall2, wall, null, null},
              {null, null, null, wall, wall, wall, null, null, null}
            },
            {
              {null, null, null, wall, wall, wall, null, null, null},
              {null, null, wall, wall2, wall2, wall2, wall, null, null},
              {null, wall, torch[0], air, stairs[3], wall, wall, wall, null},
              {wall, wall2, air, air, air, air, air, wall2, wall},
              {wall, wall2, air, air, air, air, air, wall2, wall},
              {wall, wall2, air, air, air, air, air, wall2, wall},
              {null, wall, air, air, air, air, air, wall, null},
              {null, null, wall, wall2, wall2, wall2, wall, null, null},
              {null, null, null, wall, wall, wall, null, null, null}
            },
            {
              {null, null, null, wall, wall, wall, null, null, null},
              {null, null, wall, wall2, wall2, wall2, wall, null, null},
              {null, wall, air, air, air, stairs[3], floor, wall, null},
              {wall, wall2, floor, floor, floor, floor, floor, wall2, wall},
              {wall, wall2, floor, floor, floor2, floor, floor, wall2, wall},
              {wall, wall2, floor, floor, floor, floor, floor, wall2, wall},
              {null, wall, floor, floor, floor, floor, floor, wall, null},
              {null, null, wall, wall2, wall2, wall2, wall, null, null},
              {null, null, null, wall, wall, wall, null, null, null}
            },
            {
              {null, null, null, wall, wall, wall, null, null, null},
              {null, null, wall, wall2, wall2, wall2, wall, null, null},
              {null, wall, air, air, air, air, air, wall, null},
              {wall, wall2, air, air, air, air, stairs[0], wall2, wall},
              {wall, wall2, air, air, air, air, wall, wall2, wall},
              {wall, wall2, air, air, air, air, wall, wall2, wall},
              {null, wall, air, air, air, air, wall, wall, null},
              {null, null, wall, wall2, wall2, wall2, wall, null, null},
              {null, null, null, wall, wall, wall, null, null, null}
            },
            {
              {null, null, null, wall, wall, wall, null, null, null},
              {null, null, wall, wall2, wall2, wall2, wall, null, null},
              {null, wall, air, air, air, air, torch[1], wall, null},
              {wall, wall2, air, air, air, air, air, wall2, wall},
              {wall, wall2, air, air, air, air, stairs[0], wall2, wall},
              {wall, wall2, air, air, air, air, wall, wall2, wall},
              {null, wall, air, air, air, air, wall, wall, null},
              {null, null, wall, wall2, wall2, wall2, wall, null, null},
              {null, null, null, wall, wall, wall, null, null, null}
            },
            {
              {null, null, null, wall, wall, wall, null, null, null},
              {null, null, wall, wall2, wall2, wall2, wall, null, null},
              {null, wall, floor, floor, floor, floor, air, wall, null},
              {wall, wall2, floor, floor, floor, floor, air, wall2, wall},
              {wall, wall2, floor, floor, floor2, floor, air, wall2, wall},
              {wall, wall2, floor, floor, floor, floor, stairs[0], wall2, wall},
              {null, wall, floor, floor, floor, floor, floor, wall, null},
              {null, null, wall, wall2, wall2, wall2, wall, null, null},
              {null, null, null, wall, wall, wall, null, null, null}
            },
            {
              {null, null, null, wall, wall, wall, null, null, null},
              {null, null, wall, wall2, wall2, wall2, wall, null, null},
              {null, wall, air, air, air, air, air, wall, null},
              {wall, wall2, air, air, air, air, air, wall2, wall},
              {wall, wall2, air, air, air, air, air, wall2, wall},
              {wall, wall2, air, air, air, air, air, wall2, wall},
              {null, wall, wall, wall, wall, stairs[1], air, wall, null},
              {null, null, wall, wall2, wall2, wall2, wall, null, null},
              {null, null, null, wall, wall, wall, null, null, null}
            },
            {
              {null, null, null, wall, wall, wall, null, null, null},
              {null, null, wall, wall2, wall2, wall2, wall, null, null},
              {null, wall, air, air, air, air, air, wall, null},
              {wall, wall2, air, air, air, air, air, wall2, wall},
              {wall, wall2, air, air, air, air, air, wall2, wall},
              {wall, wall2, air, air, air, air, air, wall2, wall},
              {null, wall, wall, wall, stairs[1], air, torch[2], wall, null},
              {null, null, wall, wall2, wall2, wall2, wall, null, null},
              {null, null, null, wall, wall, wall, null, null, null}
            },
            {
              {null, null, null, wall, wall, wall, null, null, null},
              {null, null, wall, wall2, wall2, wall2, wall, null, null},
              {null, wall, floor, floor, floor, floor, floor, wall, null},
              {wall, wall2, floor, floor, floor, floor, floor, wall2, wall},
              {wall, wall2, floor, floor, floor2, floor, floor, wall2, wall},
              {wall, wall2, floor, floor, floor, floor, floor, wall2, wall},
              {null, wall, floor, stairs[1], air, air, air, wall, null},
              {null, null, wall, wall2, wall2, wall2, wall, null, null},
              {null, null, null, wall, wall, wall, null, null, null}
            }
          },
          getRoofWire(air2, wall, wire, wire),
          getRoof(fence, Blocks.GLASS.getDefaultState(), g[0], g[1], g[2]),
          getTopMap(air2, wall2, carpet[0], floor, window[0], lever, null, null),
          getTopMap(air2, wall2, carpet[1], floor, window[1], lever, null, null),
          getTopMap(air2, wall2, carpet[2], floor, window[2], lever, null, null),
          getCeiling(air2, wall, wall2, c, g[0], lamp),
          getCeiling(air2, wall, wall2, c, g[1], lamp),
          getCeiling(air2, wall, wall2, c, g[2], lamp), /*,
			{
			  {
				  { c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c },
				  { c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c },
				  { c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c },
				  { c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c },
				  { c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c },
				  { c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c },
				  { c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c },
				  { c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c },
				  { c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c },
				  { c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c },
				  { c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c },
				  { c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c },
				  { c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c },
				  { c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c },
				  { c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c },
				  { c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c }
			  }, {
				  { c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c },
				  { c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c },
				  { c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c },
				  { c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c },
				  { c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c },
				  { c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c },
				  { c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c },
				  { c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c },
				  { c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c },
				  { c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c },
				  { c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c },
				  { c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c },
				  { c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c },
				  { c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c },
				  { c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c },
				  { c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c }
				}
			}*/
        };

    rawMaps[EnumStateMap.MINI_TOWER_TOP_2.ordinal()][2] =
        rawMaps[EnumStateMap.MINI_TOWER_TOP_1.ordinal()][2];
    rawMaps[EnumStateMap.MINI_TOWER_TOP_3.ordinal()][2] =
        rawMaps[EnumStateMap.MINI_TOWER_TOP_1.ordinal()][2];

    return rawMaps;
  }
  public static IBlockState[][][][] getStateMaps(
      EnumFacing dir,
      IBlockState wallBlock,
      IBlockState wallBlock_external,
      IBlockState floorBlock,
      IBlockState ceilBlock,
      IBlockState fenceBlock,
      IBlockState carpetBlock,
      IBlockState commonGlass,
      IBlockState topGlass2,
      IBlockState topGlass3,
      IBlockState beaconGlass2,
      IBlockState beaconGlass3,
      IBlockState window,
      IBlockState mineral,
      int dyeColorIndex,
      boolean hasShop) {
    final boolean hasBeacon = !hasShop && mineral != null;
    IBlockState[][][][] stateMap = new IBlockState[6][][][];
    EnumFacing pressurePlateDir = null;
    int index = 0;
    for (EnumStateMap s : EnumStateMap.values()) {
      final String mapName = s.name(), lastChar = mapName.substring(mapName.length() - 1);
      if (StringUtils.isNumeric(lastChar)) {
        if (Integer.parseInt(lastChar) != dyeColorIndex + 1) continue;
      }
      final int mapIndex = EnumStateMap.valueOf(mapName).ordinal();
      final Map<EnumFacing, IBlockState[][][]> map = maps.get(wallBlock_external)[mapIndex];
      final IBlockState air = Blocks.AIR.getDefaultState(),
          lever =
              !hasBeacon
                  ? Blocks.LEVER.getStateFromMeta(7)
                  : beaconGlass2 != null ? beaconGlass2 : air,
          glass = Blocks.GLASS.getDefaultState(),
          lamp = !hasBeacon ? Blocks.REDSTONE_LAMP.getDefaultState() : commonGlass,
          wire = !hasBeacon ? Blocks.REDSTONE_WIRE.getDefaultState() : air;
      if (mapName.startsWith("MINI_TOWER_TOP"))
        map.put(
            dir,
            !hasShop
                ? getTopMap(
                    air,
                    wallBlock_external,
                    carpetBlock,
                    window,
                    floorBlock,
                    lever,
                    mineral,
                    pressurePlateDir)
                : getTopMapShop(air, wallBlock_external, carpetBlock, window, fenceBlock, mineral));
      else if (mapName.startsWith("MINI_TOWER_ROOF")) {
        if (mapName.equals("MINI_TOWER_ROOF_WIRE"))
          map.put(dir, getRoofWire(air, wallBlock_external, wire, beaconGlass3));
        else map.put(dir, getRoof(fenceBlock, glass, commonGlass, topGlass2, topGlass3));
      } else if (mapName.startsWith("MINI_TOWER_CEILING_"))
        map.put(dir, getCeiling(air, wallBlock_external, wallBlock, ceilBlock, commonGlass, lamp));
      else if (mapName.equals("MINI_TOWER_BASE")) {
        map.get(dir)[0][4][4] = floorBlock;
        if (floorBlock.getBlock() instanceof BlockTrapDoor) {
          pressurePlateDir = floorBlock.getValue(BlockTrapDoor.FACING);
          floorBlock = MazeTowers.BlockMazeTowerThreshold.getDefaultState();
        }
      }
      stateMap[index++] = map.get(dir);
    }

    return stateMap;
  }