private void updateLecternInformation() {
    if (podiumLocation == null) return;
    TileEntityLectern lectern =
        (TileEntityLectern)
            worldObj.getTileEntity(
                xCoord + podiumLocation.getX(),
                yCoord + podiumLocation.getY(),
                zCoord + podiumLocation.getZ());
    if (lectern != null) {
      if (lectern.hasStack()) {
        ItemStack lecternStack = lectern.getStack();
        if (lecternStack.hasTagCompound()) {
          spellGuide = lecternStack.getTagCompound().getIntArray("spell_combo");
          outputCombo = lecternStack.getTagCompound().getIntArray("output_combo");
          currentSpellName = lecternStack.getDisplayName();

          int numShapeGroups = lecternStack.getTagCompound().getInteger("numShapeGroups");
          shapeGroupGuide = new int[numShapeGroups][];

          for (int i = 0; i < numShapeGroups; ++i) {
            shapeGroupGuide[i] = lecternStack.getTagCompound().getIntArray("shapeGroupCombo_" + i);
          }
        }

        if (isCrafting) {
          if (spellGuide != null) {
            lectern.setNeedsBook(false);
            lectern.setTooltipStack(getNextPlannedItem());
          } else {
            lectern.setNeedsBook(true);
          }
        } else {
          lectern.setTooltipStack(null);
        }
        if (spellGuideIsWithinStructurePower()) {
          lectern.setOverpowered(false);
        } else {
          lectern.setOverpowered(true);
        }
      } else {
        if (isCrafting) {
          lectern.setNeedsBook(true);
        }
        lectern.setTooltipStack(null);
      }
    }
  }
 public void flipSwitch() {
   if (switchLocation == null) return;
   Block block =
       worldObj.getBlock(
           xCoord + switchLocation.getX(),
           yCoord + switchLocation.getY(),
           zCoord + switchLocation.getZ());
   if (block == Blocks.lever) {
     Blocks.lever.onBlockActivated(
         worldObj,
         xCoord + switchLocation.getX(),
         yCoord + switchLocation.getY(),
         zCoord + switchLocation.getZ(),
         null,
         0,
         0,
         0,
         0);
   }
 }
 public boolean switchIsOn() {
   if (switchLocation == null) return false;
   Block block =
       worldObj.getBlock(
           xCoord + switchLocation.getX(),
           yCoord + switchLocation.getY(),
           zCoord + switchLocation.getZ());
   boolean b = false;
   if (block == Blocks.lever) {
     for (int i = 0; i < 6; ++i) {
       b |=
           (Blocks.lever.isProvidingStrongPower(
                   worldObj,
                   xCoord + switchLocation.getX(),
                   yCoord + switchLocation.getY(),
                   zCoord + switchLocation.getZ(),
                   i)
               > 0);
       if (b) break;
     }
   }
   return b;
 }
  private void checkStructure() {

    if ((isCrafting && checkCounter++ < 50) || (!isCrafting && checkCounter++ < 200)) {
      return;
    }
    checkCounter = 0;

    boolean primaryvalid = primary.checkStructure(worldObj, xCoord, yCoord, zCoord);
    boolean secondaryvalid = secondary.checkStructure(worldObj, xCoord, yCoord, zCoord);
    if (!primaryvalid && !secondaryvalid) {
      if (isCrafting) setCrafting(false);
    }

    // locate lectern and lever & material groups
    if (primaryvalid || secondaryvalid) {
      maxEffects = 0;
      ArrayList<StructureGroup> lecternGroups = null;
      ArrayList<StructureGroup> augmatlGroups = null;
      ArrayList<StructureGroup> mainmatlGroups = null;
      if (primaryvalid) {
        lecternGroups = primary.getMatchedGroups(lectern_mutex, worldObj, xCoord, yCoord, zCoord);
        augmatlGroups = primary.getMatchedGroups(augmatl_mutex, worldObj, xCoord, yCoord, zCoord);
        mainmatlGroups =
            primary.getMatchedGroups(
                MultiblockStructureDefinition.MAINGROUP_MUTEX, worldObj, xCoord, yCoord, zCoord);
      } else if (secondaryvalid) {
        lecternGroups = secondary.getMatchedGroups(lectern_mutex, worldObj, xCoord, yCoord, zCoord);
        augmatlGroups = secondary.getMatchedGroups(augmatl_mutex, worldObj, xCoord, yCoord, zCoord);
        mainmatlGroups =
            secondary.getMatchedGroups(
                MultiblockStructureDefinition.MAINGROUP_MUTEX, worldObj, xCoord, yCoord, zCoord);
      }
      if (lecternGroups != null && lecternGroups.size() > 0) {
        StructureGroup group = lecternGroups.get(0);
        HashMap<BlockCoord, ArrayList<BlockDec>> blocks = group.getAllowedBlocks();

        for (BlockCoord bc : blocks.keySet()) {
          Block block =
              worldObj.getBlock(xCoord + bc.getX(), yCoord + bc.getY(), zCoord + bc.getZ());
          if (block == BlocksCommonProxy.blockLectern) {
            podiumLocation = bc;
          } else if (block == Blocks.lever) {
            switchLocation = bc;
          }
        }
      }
      if (augmatlGroups != null && augmatlGroups.size() == 1) {
        StructureGroup group = augmatlGroups.get(0);
        int index = -1;
        for (StructureGroup augmatlGroup : primaryvalid ? augMatl_primary : augMatl_secondary) {
          index++;
          if (augmatlGroup == group) {
            break;
          }
        }
        maxEffects = index + 1;
      }
      if (mainmatlGroups != null && mainmatlGroups.size() == 1) {
        StructureGroup group = mainmatlGroups.get(0);
        if (group == wood_primary || group == wood_secondary) maxEffects += 1;
        else if (group == cobble_primary
            || group == cobble_secondary
            || group == sandstone_primary
            || group == sandstone_secondary) maxEffects += 1;
        else if (group == brick_primary
            || group == brick_secondary
            || group == witchwood_primary
            || group == witchwood_secondary) maxEffects += 2;
        else if (group == netherbrick_primary
            || group == netherbrick_secondary
            || group == quartz_primary
            || group == quartz_secondary) maxEffects += 3;
        else // default of stone brick
        maxEffects += 2;
      }
    } else {
      podiumLocation = null;
      switchLocation = null;
      maxEffects = 0;
    }

    // maxEffects = 2;
    setStructureValid(primaryvalid || secondaryvalid);
  }