예제 #1
0
 @Override
 public void onActionPerformed(GuiButton button) {
   if (button.id == 100) canTick = !canTick;
   if (button.id == 101) {
     showLayer = Math.min(showLayer + 1, structureHeight - 1);
     tick = (countPerLevel[showLayer]) * 40;
   }
   if (button.id == 102) {
     showLayer = Math.max(showLayer - 1, -1);
     tick = (showLayer == -1 ? blockCount : countPerLevel[showLayer]) * 40;
   }
   super.onActionPerformed(button);
 }
예제 #2
0
 @Override
 public void onOpened(IGuiLexiconEntry gui) {
   int yOff = 0;
   if (multiblock != null) {
     ItemStack[][][] structure = multiblock;
     structureHeight = structure.length;
     structureWidth = 0;
     structureLength = 0;
     countPerLevel = new int[structureHeight];
     blockCount = 0;
     for (int h = 0; h < structure.length; h++) {
       if (structure[h].length - 1 > structureLength) structureLength = structure[h].length - 1;
       int perLvl = 0;
       for (int l = 0; l < structure[h].length; l++) {
         if (structure[h][l].length - 1 > structureWidth)
           structureWidth = structure[h][l].length - 1;
         for (ItemStack ss : structure[h][l]) if (ss != null) perLvl++;
       }
       countPerLevel[h] = perLvl;
       blockCount += perLvl;
     }
     tick = (showLayer == -1 ? blockCount : countPerLevel[showLayer]) * 40;
     yOff = (structureHeight - 1) * 12 + structureWidth * 5 + structureLength * 5 + 16;
     yOff = Math.max(48, yOff);
     int x = gui.getLeft();
     int y = gui.getTop();
     gui.getButtonList()
         .add(
             new GuiButtonManualNavigation(
                 gui, this, 100, x + 20, y + 10 + yOff / 2 - 5, 10, 10, 4));
     if (structureHeight > 1) {
       gui.getButtonList()
           .add(
               new GuiButtonManualNavigation(
                   gui, this, 101, x + 20, y + 10 + yOff / 2 - 8 - 16, 10, 16, 3));
       gui.getButtonList()
           .add(
               new GuiButtonManualNavigation(
                   gui, this, 102, x + 20, y + 10 + yOff / 2 + 8, 10, 16, 2));
     }
   }
   super.onOpened(gui);
 }