Esempio n. 1
0
  /**
   * Find mod files in the "mods" folder
   *
   * @param modFolder Folder to search
   * @param modFiles List of mod files to load
   */
  protected void findModFiles(File modFolder, LinkedList<File> modFiles) {
    List<String> supportedVerions = Arrays.asList(SUPPORTED_VERSIONS);

    for (File modFile : modFolder.listFiles(this)) {
      try {
        // Check for a version file
        ZipFile modZip = new ZipFile(modFile);
        ZipEntry version = modZip.getEntry("version.txt");

        if (version != null) {
          // Read the version string
          InputStream versionStream = modZip.getInputStream(version);
          BufferedReader versionReader = new BufferedReader(new InputStreamReader(versionStream));
          String strVersion = versionReader.readLine();
          versionReader.close();

          // Only add the mod if the version matches and we were able to successfully add it to the
          // class path
          if (supportedVerions.contains(strVersion) && addURLToClassPath(modFile.toURI().toURL())) {
            modFiles.add(modFile);
          }
        }

        modZip.close();
      } catch (Exception ex) {
        logger.warning(
            "Error enumerating '"
                + modFile.getAbsolutePath()
                + "': Invalid zip file or error reading file");
      }
    }
  }
  private FancyDial(TextureAtlasSprite icon, PropertiesFile properties) {
    this.icon = icon;
    this.properties = properties;
    name = IconAPI.getIconName(icon);
    x0 = IconAPI.getIconX0(icon);
    y0 = IconAPI.getIconY0(icon);
    width = IconAPI.getIconWidth(icon);
    height = IconAPI.getIconHeight(icon);
    scratchBuffer = ByteBuffer.allocateDirect(4 * width * height);

    int itemsTexture = TexturePackAPI.getTextureIfLoaded(TexturePackAPI.ITEMS_PNG);
    if (itemsTexture < 0) {
      logger.severe("could not get items texture");
      return;
    }
    itemsFBO = new FBO(itemsTexture, x0, y0, width, height);

    if (useScratchTexture) {
      logger.fine("rendering %s to %dx%d scratch texture", name, width, height);
      for (int i = 0; i < scratchFBO.length; i++) {
        scratchFBO[i] = new FBO(width, height);
      }
    } else {
      logger.fine("rendering %s directly to atlas", name);
    }

    boolean debug = false;
    for (int i = 0; ; i++) {
      Layer layer = newLayer(properties, "." + i);
      if (layer == null) {
        if (i > 0) {
          break;
        }
        continue;
      }
      layers.add(layer);
      debug |= layer.debug;
      logger.fine("  new %s", layer);
    }
    keyboard = new InputHandler(name, debug);
    if (layers.size() < 2) {
      logger.error("custom %s needs at least two layers defined", name);
      return;
    }

    outputFrames = properties.getInt("outputFrames", 0);

    int glError = GL11.glGetError();
    if (glError != 0) {
      logger.severe("%s during %s setup", GLU.gluErrorString(glError), name);
      return;
    }
    ok = true;
  }
 void registerAnimation(List<TextureAtlasSprite> animations) {
   if (animations.contains(icon)) {
     return;
   }
   animations.add(icon);
   if (icon.animationFrames == null) {
     icon.animationFrames = new ArrayList<int[]>();
   }
   if (icon.animationFrames.isEmpty()) {
     int[] dummyRGB = new int[width * height];
     Arrays.fill(dummyRGB, 0xffff00ff);
     icon.animationFrames.add(dummyRGB);
   }
   logger.fine("registered %s animation", name);
 }
 public void scrollTo(float f) {
   int i = (itemList.size() / 8 - 5) + 1;
   int j = (int) ((double) (f * (float) i) + 0.5D);
   if (j < 0) {
     j = 0;
   }
   for (int k = 0; k < 9; k++) {
     for (int l = 0; l < 8; l++) {
       int i1 = l + (k + j) * 8;
       if (i1 >= 0 && i1 < itemList.size()) {
         ZooGuiContainerTradingSpecial.getInventory()
             .setInventorySlotContents(l + k * 8, (ItemStack) itemList.get(i1));
       } else {
         ZooGuiContainerTradingSpecial.getInventory().setInventorySlotContents(l + k * 8, null);
       }
     }
   }
 }
 private void finish() {
   for (int i = 0; i < scratchFBO.length; i++) {
     if (scratchFBO[i] != null) {
       scratchFBO[i].delete();
       scratchFBO[i] = null;
     }
   }
   if (itemsFBO != null) {
     itemsFBO.delete();
     itemsFBO = null;
   }
   itemFrames.clear();
   layers.clear();
   ok = false;
 }
  public void loadStacks() {
    itemList = new ArrayList();
    Block ablock[] = {
      Block.blockDiamond,
      Block.blockGold,
      Block.blockLapis,
      Block.blockSnow,
      Block.blockSteel,
      Block.brick,
      Block.cobblestoneMossy,
      Block.enchantmentTable,
      Block.jukebox,
      Block.blockClay
    };
    for (int i = 0; i < ablock.length; i++) {
      itemList.add(new ItemStack(ablock[i]));
    }

    for (int k = 0; k < 3; k++) {
      itemList.add(new ItemStack(Block.leaves.blockID, 1, k));
    }

    addBlocks(itemList);

    Item aitem[] = {
      Item.ingotGold,
      Item.ingotIron,
      Item.record11,
      Item.record13,
      Item.recordBlocks,
      Item.recordCat,
      Item.recordChirp,
      Item.recordFar,
      Item.recordMall,
      Item.recordMellohi,
      Item.recordStal,
      Item.recordStrad,
      Item.recordWard,
      Item.saddle
    };
    for (int l1 = 0; l1 < aitem.length; l1++) {
      itemList.add(new ItemStack(aitem[l1]));
    }

    addItems(itemList);

    for (int i2 = 0; i2 < 3; i2++) {
      itemList.add(new ItemStack(mod_ZooTrade.Coin.shiftedIndex, 1, i2));
    }

    sortGui();
    InventoryPlayer inventoryplayer = minecraft.thePlayer.inventory;
    for (int l2 = 0; l2 < 5; l2++) {
      for (int k3 = 0; k3 < 8; k3++) {
        addSlot(
            new Slot(
                ZooGuiContainerTradingSpecial.getInventory(),
                k3 + l2 * 8,
                8 + k3 * 18,
                18 + l2 * 18));
      }
    }

    for (int i3 = 0; i3 < 3; i3++) {
      for (int l3 = 0; l3 < 9; l3++) {
        addSlot(new Slot(inventoryplayer, l3 + i3 * 9 + 9, 8 + l3 * 18, 127 + i3 * 18));
      }
    }

    for (int j3 = 0; j3 < 9; j3++) {
      addSlot(new Slot(inventoryplayer, j3, 8 + j3 * 18, 184));
    }

    scrollTo(0.0F);
  }