Jump to content

Forge with a different .minecraft folder


Fantasix

Recommended Posts

Hey guys !

 

I'm currently trying to make a launcher for a french minecraft server, with a minecraft.jar which include Forge. The download is perfectly working, etc ...

 

The thing is, i've made so the launcher create a new folder in the AppData (.wetope), but it seems that Forge don't like to be launched in another folder than .minecraft.

 

Here's the log I get :

 

 

2012-08-24 22:11:36 [iNFO] [ForgeModLoader] Forge Mod Loader version 3.0.71.289 for Minecraft client:1.3.2, server:1.3.2 loading
2012-08-24 22:11:36 [FINEST] [ForgeModLoader] All core mods are successfully located
2012-08-24 22:11:36 [FINEST] [ForgeModLoader] Discovering coremods
2012-08-24 22:11:36 [FINEST] [ForgeModLoader] Found library file argo-2.25.jar present and correct in lib dir

2012-08-24 22:11:36 [FINEST] [ForgeModLoader] Found library file guava-12.0.1.jar present and correct in lib dir

2012-08-24 22:11:36 [FINEST] [ForgeModLoader] Found library file asm-all-4.0.jar present and correct in lib dir

2012-08-24 22:11:37 [FINEST] [ForgeModLoader] Running coremod plugins
2012-08-24 22:11:37 [FINEST] [ForgeModLoader] Running coremod plugin FMLCorePlugin
2012-08-24 22:11:37 [FINEST] [ForgeModLoader] Coremod plugin FMLCorePlugin run successfully
2012-08-24 22:11:37 [FINEST] [ForgeModLoader] Running coremod plugin FMLForgePlugin
2012-08-24 22:11:37 [FINEST] [ForgeModLoader] Coremod plugin FMLForgePlugin run successfully
2012-08-24 22:11:37 [FINEST] [ForgeModLoader] Validating minecraft
2012-08-24 22:11:37 [FINEST] [ForgeModLoader] Minecraft validated, launching...
2012-08-24 22:11:39 [iNFO] [sTDOUT] 27 achievements
2012-08-24 22:11:39 [iNFO] [sTDOUT] 195 recipes
2012-08-24 22:11:39 [iNFO] [sTDOUT] Setting user: Fantasix, xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
2012-08-24 22:11:39 [iNFO] [sTDOUT] LWJGL Version: 2.4.2
2012-08-24 22:11:41 [iNFO] [ForgeModLoader] Attempting early MinecraftForge initialization
2012-08-24 22:11:41 [iNFO] [ForgeModLoader] Completed early MinecraftForge initialization
2012-08-24 22:11:41 [FINE] [ForgeModLoader] Building injected Mod Containers [cpw.mods.fml.common.FMLDummyContainer, net.minecraftforge.common.ForgeDummyContainer]
2012-08-24 22:11:41 [FINE] [ForgeModLoader] Attempting to load mods contained in the minecraft jar file and associated classes
2012-08-24 22:11:41 [FINE] [ForgeModLoader] Skipping known library file C:\Users\Fantasix\AppData\Roaming\.wetope\bin\lwjgl.jar
2012-08-24 22:11:41 [FINE] [ForgeModLoader] Skipping known library file C:\Users\Fantasix\AppData\Roaming\.wetope\bin\jinput.jar
2012-08-24 22:11:41 [FINE] [ForgeModLoader] Skipping known library file C:\Users\Fantasix\AppData\Roaming\.wetope\bin\lwjgl_util.jar
2012-08-24 22:11:41 [FINE] [ForgeModLoader] Found a minecraft related file at C:\Users\Fantasix\AppData\Roaming\.wetope\bin\minecraft.jar, examining for mod candidates
2012-08-24 22:11:41 [FINE] [ForgeModLoader] Skipping known library file C:\Users\Fantasix\AppData\Roaming\.minecraft\lib\argo-2.25.jar
2012-08-24 22:11:41 [FINE] [ForgeModLoader] Skipping known library file C:\Users\Fantasix\AppData\Roaming\.minecraft\lib\guava-12.0.1.jar
2012-08-24 22:11:41 [FINE] [ForgeModLoader] Skipping known library file C:\Users\Fantasix\AppData\Roaming\.minecraft\lib\asm-all-4.0.jar
2012-08-24 22:11:41 [FINE] [ForgeModLoader] Minecraft jar mods loaded successfully
2012-08-24 22:11:41 [iNFO] [ForgeModLoader] Searching C:\Users\Fantasix\AppData\Roaming\.minecraft\mods for mods
2012-08-24 22:11:41 [FINE] [ForgeModLoader] Examining file minecraft.jar for potential mods
2012-08-24 22:11:42 [FINE] [ForgeModLoader] Identified a FMLMod type mod wetope.WetopeMod
2012-08-24 22:11:42 [WARNING] [ForgeModLoader] Zip file minecraft.jar failed to read properly, it will be ignored
2012-08-24 22:11:42 [iNFO] [ForgeModLoader] Forge Mod Loader has identified 3 mods to load
2012-08-24 22:11:42 [FINE] [ForgeModLoader] Received a system property request ''
2012-08-24 22:11:42 [FINE] [ForgeModLoader] System property request managing the state of 0 mods
2012-08-24 22:11:42 [FINE] [ForgeModLoader] After merging, found state information for 0 mods
2012-08-24 22:11:42 [FINE] [ForgeModLoader] Verifying mod requirements are satisfied
2012-08-24 22:11:42 [FINE] [ForgeModLoader] Mod sorting data:
2012-08-24 22:11:42 [iNFO] [sTDERR] java.lang.NullPointerException
2012-08-24 22:11:42 [iNFO] [sTDERR] 	at cpw.mods.fml.common.FMLModContainer.getName(FMLModContainer.java:106)
2012-08-24 22:11:42 [iNFO] [sTDERR] 	at cpw.mods.fml.common.Loader.sortModList(Loader.java:236)
2012-08-24 22:11:42 [iNFO] [sTDERR] 	at cpw.mods.fml.common.Loader.loadMods(Loader.java:416)
2012-08-24 22:11:42 [iNFO] [sTDERR] 	at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:192)
2012-08-24 22:11:42 [iNFO] [sTDERR] 	at net.minecraft.client.Minecraft.a(Minecraft.java:402)
2012-08-24 22:11:42 [iNFO] [sTDERR] 	at net.minecraft.client.Minecraft.run(Minecraft.java:734)
2012-08-24 22:11:42 [iNFO] [sTDERR] 	at java.lang.Thread.run(Unknown Source)

 

 

I have one of the last build of Forge (#229), and everything is working fine when I do it "normally".

 

PS : Yes, my Mod have a name x)

 

Edit : I just noticed that after examining for mod candidates, it goes to the .minecraft folder instead of staying in the .wetope one. Maybe it is where the error comes from, but I've no idea how to solve it -.-'

 

My supposition: It detects the Mods while it is in the .wetope folder, but after changing for no reason, it tries to load them, or something similar, and so it can't, because it is no longer in the same directory.

 

Thanks for your help,

 

Fantasix

Link to comment
Share on other sites

Well ... Even by copying the content of the .minecraft directory to the .wetope directory, the error still occurs : it goes from .wetope to .minecraft at some point.

 

After some digging on the internet, I found that I was not the only one to have this "kind" of issues with the Launcher-Forge compatibility. (Link here)

 

In my case, I would say that the problem comes from the FMLRelauncher class. Actually, the ReflectionHelper.setPrivateValue at line 179 doesn't seem to change the directory. (I tried with an out.print, it still be the .minecraft directory instead of .wetope).

 

Hope a solution will be found one day :)

Link to comment
Share on other sites

One again you're not setting the minecraft directory properly.

Ive tested many times that setting the minecraft directory works with the new releauncher, so, go try again.

Next post that you have without showing your code and showing that you have tested thoroughly will result in your ban.

 

Just saying it doesnt work and not showing why you think it should it not valid.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Link to comment
Share on other sites

Hum ... Ok :S

 

Here is what i've done so far :

 

-> My main mod class : WetopeMod.java

 

 

package wetope;

import net.minecraft.src.Block;
import net.minecraft.src.CreativeTabs;
import net.minecraft.src.Enchantment;
import net.minecraft.src.EnumEnchantmentType;
import net.minecraft.src.EnumRarity;
import net.minecraft.src.EnumToolMaterial;
import net.minecraft.src.Item;
import net.minecraftforge.client.EnumHelperClient;
import net.minecraftforge.common.EnumHelper;
import net.minecraftforge.common.MinecraftForge;
import wetope.blocks.BlockChair;
import wetope.blocks.BlockCopperOre;
import wetope.blocks.BlockCrusher;
import wetope.blocks.BlockNetherOre;
import wetope.blocks.BlockRecycler;
import wetope.blocks.BlockRedstone;
import wetope.blocks.BlockRedstoneJewel;
import wetope.blocks.BlockShelf;
import wetope.blocks.BlockSilverOre;
import wetope.blocks.BlockTable;
import wetope.enchantments.EnchantementCritical;
import wetope.enchantments.EnchantmentLuckyCharm;
import wetope.enchantments.EnchantmentRage;
import wetope.generators.GeneratorCopperOre;
import wetope.generators.GeneratorNetherOre;
import wetope.generators.GeneratorSilverOre;
import wetope.items.ItemCopperIngot;
import wetope.items.ItemDagger;
import wetope.items.ItemDiamondShard;
import wetope.items.ItemIronStick;
import wetope.items.ItemObsidianAxe;
import wetope.items.ItemObsidianDust;
import wetope.items.ItemObsidianFragment;
import wetope.items.ItemObsidianHoe;
import wetope.items.ItemObsidianPickaxe;
import wetope.items.ItemObsidianShovel;
import wetope.items.ItemObsidianSword;
import wetope.items.ItemRedstoneAxe;
import wetope.items.ItemRedstoneHoe;
import wetope.items.ItemRedstoneJewel;
import wetope.items.ItemRedstonePickaxe;
import wetope.items.ItemRedstoneShovel;
import wetope.items.ItemRedstoneSword;
import wetope.items.ItemSilverIngot;
import wetope.renders.RenderBlockChair;
import wetope.renders.RenderBlockShelf;
import wetope.renders.RenderBlockTable;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.modloader.ModLoaderHelper;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.GameRegistry;

@Mod( modid = "WetopeMod", name="Wetope Mod", version="0.2")
@NetworkMod(channels = { "WetopeMod" }, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class)
public class WetopeMod{

public static final int toolsParticleNumber = 8;
public static final String rootDir = "/wetope/";
public static final String imageDir = rootDir + "images/";
public static final String itemsFile = "items_wetope.png";
public static final String terrainFile = "terrain_wetope.png";

@SidedProxy(clientSide = "wetope.ClientProxy", serverSide = "wetope.CommonProxy")
public static CommonProxy proxy;
@Instance
public static WetopeMod instance;

// Matériaux
public static EnumToolMaterial redstoneMaterial = EnumHelper.addToolMaterial("REDSTONE", 3, 750, 9F, 2, 12);
public static EnumToolMaterial obsidianMaterial = EnumHelper.addToolMaterial("OBSIDIAN", 3, 1800, 6F, 3, 12);

// Types d'enchantement
public static EnumEnchantmentType enchantmentDaggerType = EnumHelper.addEnchantmentType("dagger");

// Raretés
public static EnumRarity rarityLegendary = EnumHelperClient.addRarity("Legendary", 12, "Legendary");
public static EnumRarity rarityMythical = EnumHelperClient.addRarity("Mythical", 10, "Mythical");

// Renders
public static int renderShelf = RenderBlockShelf.renderId;
public static int renderTable = RenderBlockTable.renderId;
public static int renderChair = RenderBlockChair.renderId;

// Outils Redstone
public static final Item redstoneSword = (new ItemRedstoneSword(200, redstoneMaterial)).setIconIndex(48).setItemName("redstoneSword");
public static final Item redstoneShovel = (new ItemRedstoneShovel(201, redstoneMaterial)).setIconIndex(64).setItemName("redstoneShovel");
public static final Item redstonePickaxe= (new ItemRedstonePickaxe(202, redstoneMaterial)).setIconIndex(80).setItemName("redstonePickaxe");
public static final Item redstoneAxe = (new ItemRedstoneAxe(203, redstoneMaterial)).setIconIndex(96).setItemName("redstoneAxe");
public static final Item redstoneHoe = (new ItemRedstoneHoe(204, redstoneMaterial)).setIconIndex(112).setItemName("redstoneHoe");

// Outils Obsidian
public static final Item obsidianSword = (new ItemObsidianSword(205, obsidianMaterial)).setIconIndex(49).setItemName("obsidianSword");
public static final Item obsidianShovel = (new ItemObsidianShovel(206, obsidianMaterial)).setIconIndex(65).setItemName("obsidianShovel");
public static final Item obsidianPickaxe= (new ItemObsidianPickaxe(207, obsidianMaterial)).setIconIndex(81).setItemName("obsidianPickaxe");
public static final Item obsidianAxe = (new ItemObsidianAxe(208, obsidianMaterial)).setIconIndex(97).setItemName("obsidianAxe");
public static final Item obsidianHoe = (new ItemObsidianHoe(209, obsidianMaterial)).setIconIndex(113).setItemName("obsidianHoe");	

// Objets autres
public static final Item redstoneJewel = new ItemRedstoneJewel(210).setIconIndex(0).setItemName("redstoneJewel").setTabToDisplayOn(CreativeTabs.tabMaterials);
public static final Item obsidianFragment = new ItemObsidianFragment(211).setIconIndex(5).setItemName("obsidianFragment").setTabToDisplayOn(CreativeTabs.tabMaterials);
public static final Item ironStick = new ItemIronStick(212).setIconIndex(4).setItemName("ironStick").setTabToDisplayOn(CreativeTabs.tabMaterials);
public static final Item diamondShard = new ItemDiamondShard(213).setIconIndex(7).setItemName("diamondShard").setTabToDisplayOn(CreativeTabs.tabMaterials);
public static final Item obsidianDust = new ItemObsidianDust(214).setIconIndex(6).setItemName("obsidianDust").setTabToDisplayOn(CreativeTabs.tabMaterials);
public static final Item copperIngot = new ItemCopperIngot(215).setIconIndex(10).setItemName("copperIngot").setTabToDisplayOn(CreativeTabs.tabMaterials);
public static final Item silverIngot = new ItemSilverIngot(216).setIconIndex(11).setItemName("silverIngot").setTabToDisplayOn(CreativeTabs.tabMaterials);

// Dagues
public static final Item woodenDagger = (new ItemDagger(220, EnumToolMaterial.WOOD)).setIconIndex(16).setItemName("woodenDagger");
public static final Item stoneDagger = (new ItemDagger(221, EnumToolMaterial.STONE)).setIconIndex(17).setItemName("stoneDagger");
public static final Item ironDagger = (new ItemDagger(222, EnumToolMaterial.IRON)).setIconIndex(18).setItemName("ironDagger");
public static final Item diamondDagger = (new ItemDagger(223, EnumToolMaterial.EMERALD)).setIconIndex(19).setItemName("diamondDagger");
public static final Item goldenDagger = (new ItemDagger(224, EnumToolMaterial.GOLD)).setIconIndex(20).setItemName("goldDagger");
public static final Item redstoneDagger = (new ItemDagger(225, redstoneMaterial)).setIconIndex(128).setItemName("redstoneDagger");
public static final Item obsidianDagger = (new ItemDagger(226, obsidianMaterial)).setIconIndex(129).setItemName("obsidianDagger");

// Blocs
public static final Block blockRedstone = new BlockRedstone(200).setBlockName("blockRedstone").setCreativeTab(CreativeTabs.tabDeco);
public static final Block blockRedstoneJewel = new BlockRedstoneJewel(201).setBlockName("blockRedstoneJewel").setCreativeTab(CreativeTabs.tabDeco);
public static final Block blockCrusher = new BlockCrusher(202).setBlockName("blockCrusher").setCreativeTab(CreativeTabs.tabRedstone);
public static final Block blockRecycler = new BlockRecycler(203).setBlockName("blockRecycler").setCreativeTab(CreativeTabs.tabRedstone);
public static final Block blockCopperOre = new BlockCopperOre(204).setBlockName("blockCopperOre").setCreativeTab(CreativeTabs.tabBlock);
public static final Block blockSilverOre = new BlockSilverOre(205).setBlockName("blockSilverOre").setCreativeTab(CreativeTabs.tabBlock);
public static final Block blockNetherOre = new BlockNetherOre(206, false).setBlockName("blockNetherOre").setCreativeTab(CreativeTabs.tabBlock);
public static final Block blockNetherOreGlowing = new BlockNetherOre(207, true).setBlockName("blockNetherOre");

public static final Block blockShelf = new BlockShelf(250).setBlockName("blockShelf").setCreativeTab(CreativeTabs.tabDeco);
public static final Block blockTable = new BlockTable(251).setBlockName("blockTable").setCreativeTab(CreativeTabs.tabDeco);
public static final Block blockChair = new BlockChair(252).setBlockName("blockChair").setCreativeTab(CreativeTabs.tabDeco);

// Enchantements
public static final Enchantment enchantmentLuckyCharm = new EnchantmentLuckyCharm(100, 1, EnumEnchantmentType.digger).setName("Lucky Charm");
public static final Enchantment enchantmentRage = new EnchantmentRage(101, 10, EnumEnchantmentType.armor_torso).setName("Rage");
public static final Enchantment enchantmentCritical = new EnchantementCritical(102, 10, enchantmentDaggerType).setName("Critical");

@Init
public void load(FMLInitializationEvent evt) {
	proxy.registerRenderInformation();

	ItemLoader.getInstance().load();
	EntityLoader.getInstance().load();

	// Enregistrement des Events Bus
	MinecraftForge.EVENT_BUS.register(new EventHookContainerClass());

	// Enregistrement des générateurs
	GameRegistry.registerWorldGenerator(ModLoaderHelper.buildWorldGenHelper(new GeneratorCopperOre()));
	GameRegistry.registerWorldGenerator(ModLoaderHelper.buildWorldGenHelper(new GeneratorSilverOre()));
	GameRegistry.registerWorldGenerator(ModLoaderHelper.buildWorldGenHelper(new GeneratorNetherOre()));
}

}

 

 

Basically, it adds tools, items, blocks, etc... Just some basic stuff.

It works fine when I run it with Eclipse.

 

-> The minecraft.jar I get after installing the universalForge (#229) and my wetope folder containing all my classes (obtained thanks to the reobfuscate.bat) :

 

 

1345893242-scr01.png

 

 

-> The content of the .wetope directory (in the AppData folder) :

 

 

1345893242-scr02.png

 

 

-> The launcher I'm using is based on the official one. A french modder modified it a bit so we can easily change the download link of the .jar, or the name of the folder which need to be used (In my case, .wetope).

 

Here is the GameUpdater class :

 

 

/*    */ package net.minecraft;
/*    */
/*     */ import java.applet.Applet;
/*     */ import java.io.BufferedReader;
/*     */ import java.io.BufferedWriter;
/*     */ import java.io.DataInputStream;
/*     */ import java.io.DataOutputStream;
/*     */ import java.io.File;
/*     */ import java.io.FileInputStream;
/*     */ import java.io.FileOutputStream;
/*     */ import java.io.FilePermission;
/*     */ import java.io.FileWriter;
/*     */ import java.io.IOException;
/*     */ import java.io.InputStream;
/*     */ import java.io.InputStreamReader;
/*     */ import java.io.OutputStream;
/*     */ import java.io.PrintStream;
/*     */ import java.io.PrintWriter;
/*     */ import java.io.StringWriter;
/*     */ import java.io.Writer;
/*     */ import java.lang.reflect.Constructor;
/*     */ import java.lang.reflect.Field;
/*     */ import java.lang.reflect.Method;
/*     */ import java.net.HttpURLConnection;
/*     */ import java.net.JarURLConnection;
/*     */ import java.net.SocketPermission;
/*     */ import java.net.URI;
/*     */ import java.net.URL;
/*     */ import java.net.URLClassLoader;
/*     */ import java.net.URLConnection;
/*     */ import java.security.AccessControlException;
/*     */ import java.security.AccessController;
/*     */ import java.security.CodeSource;
/*     */ import java.security.PermissionCollection;
/*     */ import java.security.PrivilegedExceptionAction;
/*     */ import java.security.ProtectionDomain;
/*     */ import java.security.SecureClassLoader;
/*     */ import java.security.cert.Certificate;
/*     */ import java.util.Enumeration;
/*     */ import java.util.Scanner;
/*     */ import java.util.StringTokenizer;
/*     */ import java.util.Vector;
/*     */ import java.util.jar.JarEntry;
/*     */ import java.util.jar.JarFile;
/*     */ import java.util.jar.JarOutputStream;
/*     */ import java.util.jar.Pack200;
import java.util.jar.Pack200.Unpacker;
/*    */
/*    */ public class GameUpdater
/*    */  implements Runnable
/*    */ {
/*    */  public static final int STATE_INIT = 1;
/*    */  public static final int STATE_DETERMINING_PACKAGES = 2;
/*    */  public static final int STATE_CHECKING_CACHE = 3;
/*    */  public static final int STATE_DOWNLOADING = 4;
/*    */  public static final int STATE_EXTRACTING_PACKAGES = 5;
/*    */  public static final int STATE_UPDATING_CLASSPATH = 6;
/*    */  public static final int STATE_SWITCHING_APPLET = 7;
/*    */  public static final int STATE_INITIALIZE_REAL_APPLET = 8;
/*    */  public static final int STATE_START_REAL_APPLET = 9;
/*    */  public static final int STATE_DONE = 10;
/*    */  public int percentage;
/*    */  public int currentSizeDownload;
/*    */  public int totalSizeDownload;
public static boolean forceUpdate = false;
/*    */  public int currentSizeExtract;
/*    */  public int totalSizeExtract;
/*    */  protected URL[] urlList;
/*    */  private static ClassLoader classLoader;
/*    */  protected Thread loaderThread;
/*    */  protected Thread animationThread;
/*    */  public boolean fatalError;
          public boolean pauseAskUpdate;
          public boolean shouldUpdate;
/*    */  public String fatalErrorDescription;
/*  80 */  protected String subtaskMessage = "";
/*  81 */  protected int state = 1;
/*    */
/*  83 */  protected boolean lzmaSupported = false;
/*  84 */  protected boolean pack200Supported = false;
/*    */
/*  86 */  protected String[] genericErrorMessage = { "An error occured while loading the applet.", "Please contact support to resolve this issue.", "<placeholder for error message>" };
/*    */  protected boolean certificateRefused;
/*  90 */  protected String[] certificateRefusedMessage = { "Permissions for Applet Refused.", "Please accept the permissions dialog to allow", "the applet to continue the loading process." };
/*    */
/*  92 */  protected static boolean natives_loaded = false;
/*    */  private String latestVersion;
/*    */  private String mainGameUrl;
/*    */
/*    */  public GameUpdater(String latestVersion, String mainGameUrl)
/*    */  {
/*  97 */    this.latestVersion = latestVersion;
/*  98 */    this.mainGameUrl = mainGameUrl;
/*    */  }
/*    */
/*    */  public void init() {
/* 102 */    this.state = 1;
/*    */    try
/*    */    {
/* 105 */      Class.forName("LZMA.LzmaInputStream");
/* 106 */      this.lzmaSupported = true;
/*    */    }
/*    */    catch (Throwable localThrowable) {
/*    */    }
/*    */    try {
/* 111 */      Pack200.class.getSimpleName();
/* 112 */      this.pack200Supported = true;
/*    */    } catch (Throwable localThrowable1) {
/*    */    }
/*    */  }
/*    */
/*    */  private String generateStacktrace(Exception exception) {
/* 118 */    Writer result = new StringWriter();
/* 119 */    PrintWriter printWriter = new PrintWriter(result);
/* 120 */    exception.printStackTrace(printWriter);
/* 121 */    return result.toString();
/*    */  }
/*    */
/*    */  protected String getDescriptionForState()
/*    */  {
/* 129 */    switch (this.state) {
/*    */    case 1:
/* 131 */      return "Initialisation du téléchargement";
/*    */    case 2:
/* 133 */      return "Détermination des packs à télécharger";
/*    */    case 3:
/* 135 */      return "Vérification du cache pour les fichiers existants";
/*    */    case 4:
/* 137 */      return "Téléchargement des packs";
/*    */    case 5:
/* 139 */      return "Extraction des packs";
/*    */    case 6:
/* 141 */      return "Mise à jour du classpath";
/*    */    case 7:
/* 143 */      return "Changement d'applet";
/*    */    case 8:
/* 145 */      return "Initialisation de l'applet";
/*    */    case 9:
/* 147 */      return "Démarrage de l'applet";
/*    */    case 10:
/* 149 */      return "Chargement terminé";
/*     */   case 11:
               return "Mise à jour de Wetope";
/*    */    }
/* 151 */    return "Phase inconnue";
/*    */  }
/*    */
/*    */  protected String trimExtensionByCapabilities(String file)
/*    */  {
/* 156 */    if (!this.pack200Supported) {
/* 157 */      file = file.replaceAll(".pack", "");
/*    */    }
/*    */
/* 160 */    if (!this.lzmaSupported) {
/* 161 */      file = file.replaceAll(".lzma", "");
/*    */    }
/* 163 */    return file;
/*    */  }
/*    */
/*     */   protected void loadJarURLs() throws Exception {
   /* 165 */     this.state = 2;
   /* 166 */     String jarList = "lwjgl.jar, jinput.jar, lwjgl_util.jar, " + this.mainGameUrl;
   /* 167 */     jarList = trimExtensionByCapabilities(jarList);
   /*     */ 
   /* 169 */     StringTokenizer jar = new StringTokenizer(jarList, ", ");
   /* 170 */     int jarCount = jar.countTokens() + 1;
   /*     */ 
   /* 172 */     this.urlList = new URL[jarCount];
   /*     */ 
   /* 174 */     URL path = new URL("http://s3.amazonaws.com/MinecraftDownload/");
   /*     */ 
   /* 176 */     for (int i = 0; i < jarCount - 1; i++) {
   /* 177 */       String nextToken = jar.nextToken();
   /* 178 */       URL oldPath = path;
   /*     */ 
   /* 181 */       if (nextToken.indexOf("craft.jar") >= 0) {
   /* 182 */         path = new URL("https://dl.dropbox.com/u/100186052/Wetope/");
   /*     */       }
   /*     */ 
   /* 185 */       System.out.println(path + nextToken.replaceAll("minecraft.jar", "minecraft.jar"));
   /* 186 */       if (nextToken.indexOf("craft.jar") >= 0) {
   /* 187 */         this.urlList[i] = new URL(path, nextToken.replaceAll("minecraft.jar", "minecraft.jar"));
   /*     */       }
   /*     */       else {
   /* 190 */         this.urlList[i] = new URL(path, nextToken);
   /*     */       }
   /*     */ 
   /* 194 */       if (nextToken.indexOf("craft.jar") >= 0) {
   /* 195 */         path = oldPath;
   /*     */       }
   /*     */     }
   /*     */ 
   /* 199 */     String osName = System.getProperty("os.name");
   /* 200 */     String nativeJar = null;
   /*     */ 
   /* 202 */     if (osName.startsWith("Win"))
   /* 203 */       nativeJar = "windows_natives.jar.lzma";
   /* 204 */     else if (osName.startsWith("Linux"))
   /* 205 */       nativeJar = "linux_natives.jar.lzma";
   /* 206 */     else if (osName.startsWith("Mac"))
   /* 207 */       nativeJar = "macosx_natives.jar.lzma";
   /* 208 */     else if ((osName.startsWith("Solaris")) || (osName.startsWith("SunOS")))
   /* 209 */       nativeJar = "solaris_natives.jar.lzma";
   /*     */     else {
   /* 211 */       fatalErrorOccured("OS (" + osName + ") not supported", null);
   /*     */     }
   /*     */ 
   /* 214 */     if (nativeJar == null) {
   /* 215 */       fatalErrorOccured("no lwjgl natives files found", null);
   /*     */     } else {
   /* 217 */       nativeJar = trimExtensionByCapabilities(nativeJar);
   /* 218 */       this.urlList[(jarCount - 1)] = new URL(path, nativeJar);
   /*     */     }
   /*     */   }
/*    */
/*     */   public void run()
/*     */   {
/* 224 */     init();
/* 225 */     this.state = 3;
/*     */ 
/* 227 */     this.percentage = 5;
/*     */     try
/*     */     {
/* 230 */       loadJarURLs();
/*     */ 
/* 232 */       String path = (String)AccessController.doPrivileged(new PrivilegedExceptionAction() {
/*     */         public Object run() throws Exception {
/* 234 */           return Util.getWorkingDirectory() + File.separator + "bin" + File.separator;
/*     */         }
/*     */       });
/* 237 */       File dir = new File(path);
/*     */ 
/* 239 */       if (!dir.exists()) {
/* 240 */         dir.mkdirs();
/*     */       }
/*     */ 
/* 243 */       if (this.latestVersion != null) {
/* 244 */         File versionFile = new File(dir, "version");


/*     */ 
/* 246 */         boolean cacheAvailable = false;
/* 247 */         if ((versionFile.exists()) && (
/* 248 */           (this.latestVersion.equals("-1")) || (this.latestVersion.equals(readVersionFile(versionFile))))) {
/* 249 */           cacheAvailable = true;
/* 250 */           this.percentage = 90;
/*     */         }
/*     */ 
/* 254 */         boolean updateWetope = false;
/*     */         try {
/* 256 */           String version_Wetope = "";
/* 257 */           URL url_version = new URL("https://dl.dropbox.com/u/100186052/Wetope/version_Wetope.txt");
/*     */           try {
/* 259 */             BufferedReader in = new BufferedReader(new InputStreamReader(url_version.openStream()));
/* 260 */             version_Wetope = in.readLine();
/*     */           }
/*     */           catch (Exception e) {
/* 263 */             System.err.println(e);
/*     */           }
/* 265 */           File current_version_Wetope = new File(dir, "version_Wetope.txt");
/*     */ 
/* 267 */           if (!current_version_Wetope.exists()) {
/* 268 */             updateWetope = true;
/*     */             try {
/* 270 */               BufferedWriter bw = new BufferedWriter(new FileWriter(current_version_Wetope));
/* 271 */               bw.append(version_Wetope);
/* 272 */               bw.close();
/*     */             } catch (IOException e) {
/* 274 */               System.out.println("Erreur");
/*     */             }
/*     */           }
/*     */           else
/*     */           {
/*     */             try {
/* 280 */               Scanner scanner = new Scanner(current_version_Wetope);
/* 281 */               while (scanner.hasNextLine()) {
/* 282 */                 String line = scanner.nextLine().trim();
/* 283 */                 if (!version_Wetope.equals(line)) {
/* 284 */                   updateWetope = true;
/*     */                   try {
/* 286 */                     BufferedWriter bw = new BufferedWriter(new FileWriter(current_version_Wetope));
/* 287 */                     bw.append(version_Wetope);
/* 288 */                     bw.close();
/*     */                   } catch (IOException e) {
/* 290 */                     System.out.println("Erreur");
/*     */                   }
/*     */                 }
/*     */               }
/*     */ 
/* 295 */               scanner.close();
/*     */             } catch (IOException e) {
/* 297 */               System.out.println("Erreur" + e.getMessage());
/*     */             }
/*     */ 
/*     */           }
/*     */ 
/*     */         }
/*     */         catch (Exception localException1)
/*     */         {
/*     */         }
/*     */ 
/* 308 */         if ((!cacheAvailable) || (updateWetope) || (forceUpdate))  {
/* 309 */           downloadJars(path);
/* 310 */           extractJars(path);
/* 311 */           extractNatives(path);
/*     */ 
/* 313 */           if (this.latestVersion != null) {
/* 314 */             this.percentage = 90;
/* 315 */             writeVersionFile(versionFile, this.latestVersion);
/*     */           }
/*     */         }
/*     */       }
/*     */ 
/* 320 */       updateClassPath(dir);
/* 321 */       this.state = 10;
/*     */     } catch (AccessControlException ace) {
/* 323 */       fatalErrorOccured(ace.getMessage(), ace);
/* 324 */       this.certificateRefused = true;
/*     */     } catch (Exception e) {
/* 326 */       fatalErrorOccured(e.getMessage(), e);
/*     */     } finally {
/* 328 */       this.loaderThread = null;
/*     */     }
/*     */   }
/*     */ 
/*     */   protected String readVersionFile(File file) throws Exception {
/* 333 */     DataInputStream dis = new DataInputStream(new FileInputStream(file));
/* 334 */     String version = dis.readUTF();
/* 335 */     dis.close();
/* 336 */     return version;
/*     */   }
/*     */ 
/*     */   protected void writeVersionFile(File file, String version) throws Exception {
/* 340 */     DataOutputStream dos = new DataOutputStream(new FileOutputStream(file));
/* 341 */     dos.writeUTF(version);
/* 342 */     dos.close();
/*     */   }
/*    */
/*    */  protected void updateClassPath(File dir)
/*    */    throws Exception
/*    */  {
/* 278 */    this.state = 6;
/*    */
/* 280 */    this.percentage = 95;
/*    */
/* 282 */    URL[] urls = new URL[this.urlList.length];
/* 283 */    for (int i = 0; i < this.urlList.length; i++) {
/* 284 */      urls[i] = new File(dir, getJarName(this.urlList[i])).toURI().toURL();
/*    */    }
/*    */
/* 287 */    if (classLoader == null) {
/* 288 */      classLoader = new URLClassLoader(urls) {
/*    */        protected PermissionCollection getPermissions(CodeSource codesource) {
/* 290 */          PermissionCollection perms = null;
/*    */          try
/*    */          {
/* 294 */            Method method = SecureClassLoader.class.getDeclaredMethod("getPermissions", new Class[] { CodeSource.class });
/* 295 */            method.setAccessible(true);
/* 296 */            perms = (PermissionCollection)method.invoke(getClass().getClassLoader(), new Object[] { codesource });
/*    */
/* 298 */            String host = "www.minecraft.net";
/*    */
/* 300 */            if ((host != null) && (host.length() > 0))
/*    */            {
/* 302 */              perms.add(new SocketPermission(host, "connect,accept"));
/*    */            } else codesource.getLocation().getProtocol().equals("file");
/*    */
/* 306 */            perms.add(new FilePermission("<<ALL FILES>>", "read"));
/*    */          }
/*    */          catch (Exception e) {
/* 309 */            e.printStackTrace();
/*    */          }
/*    */
/* 312 */          return perms;
/*    */        }
/*    */      };
/*    */    }
/* 317 */    String path = dir.getAbsolutePath();
/* 318 */    if (!path.endsWith(File.separator)) path = path + File.separator;
/* 319 */    unloadNatives(path);
/*    */
/* 321 */    System.setProperty("org.lwjgl.librarypath", path + "natives");
/* 322 */    System.setProperty("net.java.games.input.librarypath", path + "natives");
/*    */
/* 324 */    natives_loaded = true;
/*    */  }
/*    */
/*    */  private void unloadNatives(String nativePath)
/*    */  {
/* 329 */    if (!natives_loaded) {
/* 330 */      return;
/*    */    }
/*    */    try
/*    */    {
/* 334 */      Field field = ClassLoader.class.getDeclaredField("loadedLibraryNames");
/* 335 */      field.setAccessible(true);
/* 336 */      Vector libs = (Vector)field.get(getClass().getClassLoader());
/*    */
/* 338 */      String path = new File(nativePath).getCanonicalPath();
/*    */
/* 340 */      for (int i = 0; i < libs.size(); i++) {
/* 341 */        String s = (String)libs.get(i);
/*    */
/* 343 */        if (s.startsWith(path)) {
/* 344 */          libs.remove(i);
/* 345 */          i--;
/*    */        }
/*    */      }
/*    */    } catch (Exception e) {
/* 349 */      e.printStackTrace();
/*    */    }
/*    */  }
/*    */
/*    */  public Applet createApplet() throws ClassNotFoundException, InstantiationException, IllegalAccessException
/*    */  {
/* 355 */    Class appletClass = classLoader.loadClass("net.minecraft.client.MinecraftApplet");
/* 356 */    return (Applet)appletClass.newInstance();
/*    */  }
/*    */
/*    */  protected void downloadJars(String path)
/*    */    throws Exception
/*    */  {
/* 384 */    this.state = 4;
/*    */
/* 389 */    int[] fileSizes = new int[this.urlList.length];
/*    */
/* 392 */    for (int i = 0; i < this.urlList.length; i++) {
/* 393 */      System.out.println(this.urlList[i]);
/* 394 */      URLConnection urlconnection = this.urlList[i].openConnection();
/* 395 */      urlconnection.setDefaultUseCaches(false);
/* 396 */      if ((urlconnection instanceof HttpURLConnection)) {
/* 397 */        ((HttpURLConnection)urlconnection).setRequestMethod("HEAD");
/*    */      }
/* 399 */      fileSizes[i] = urlconnection.getContentLength();
/* 400 */      this.totalSizeDownload += fileSizes[i];
/*    */    }
/*    */
/* 403 */    int initialPercentage = this.percentage = 10;
/*    */
/* 406 */    byte[] buffer = new byte[65536];
/* 407 */    for (int i = 0; i < this.urlList.length; i++)
/*    */    {
/* 409 */      int unsuccessfulAttempts = 0;
/* 410 */      int maxUnsuccessfulAttempts = 3;
/* 411 */      boolean downloadFile = true;
/*    */
/* 414 */      while (downloadFile) {
/* 415 */        downloadFile = false;
/*    */
/* 417 */        URLConnection urlconnection = this.urlList[i].openConnection();
/*    */
/* 419 */        if ((urlconnection instanceof HttpURLConnection)) {
/* 420 */          urlconnection.setRequestProperty("Cache-Control", "no-cache");
/* 421 */          urlconnection.connect();
/*    */        }
/*    */
/* 424 */        String currentFile = getFileName(this.urlList[i]);
/* 425 */        InputStream inputstream = getJarInputStream(currentFile, urlconnection);
/* 426 */        FileOutputStream fos = new FileOutputStream(path + currentFile);
/*    */
/* 430 */        long downloadStartTime = System.currentTimeMillis();
/* 431 */        int downloadedAmount = 0;
/* 432 */        int fileSize = 0;
/* 433 */        String downloadSpeedMessage = "";
/*    */        int bufferSize;
/* 435 */        while ((bufferSize = inputstream.read(buffer, 0, buffer.length)) != -1)
/*    */        {
/* 436 */          fos.write(buffer, 0, bufferSize);
/* 437 */          this.currentSizeDownload += bufferSize;
/* 438 */          fileSize += bufferSize;
/* 439 */          this.percentage = (initialPercentage + this.currentSizeDownload * 45 / this.totalSizeDownload);
/* 440 */          this.subtaskMessage = ("Téléchargement de " + currentFile + " " + this.currentSizeDownload * 100 / this.totalSizeDownload + "%");
/*    */
/* 442 */          downloadedAmount += bufferSize;
/* 443 */          long timeLapse = System.currentTimeMillis() - downloadStartTime;
/*    */
/* 445 */          if (timeLapse >= 1000L)
/*    */          {
/* 447 */            float downloadSpeed = downloadedAmount / (float)timeLapse;
/*    */
/* 449 */            downloadSpeed = (int)(downloadSpeed * 100.0F) / 100.0F;
/*    */
/* 451 */            downloadSpeedMessage = " à " + downloadSpeed + " KB/sec";
/*    */
/* 453 */            downloadedAmount = 0;
/*    */
/* 455 */            downloadStartTime += 1000L;
/*    */          }
/*    */
/* 458 */          this.subtaskMessage += downloadSpeedMessage;
/*    */        }
/*    */
/* 461 */        inputstream.close();
/* 462 */        fos.close();
/*    */
/* 465 */        if ((!(urlconnection instanceof HttpURLConnection)) ||
/* 466 */          (fileSize == fileSizes[i]))
/*    */          continue;
/* 468 */        if (fileSizes[i] <= 0)
/*    */        {
/*    */          continue;
/*    */        }
/* 472 */        unsuccessfulAttempts++;
/*    */
/* 474 */        if (unsuccessfulAttempts < maxUnsuccessfulAttempts) {
/* 475 */          downloadFile = true;
/* 476 */          this.currentSizeDownload -= fileSize;
/*    */        }
/*    */        else {
/* 479 */          throw new Exception("Impossible de télécharger " + currentFile);
/*    */        }
/*    */      }
/*    */
/*    */    }
/*    */
/* 485 */    this.subtaskMessage = "";
/*    */  }
/*    */
/*    */  protected InputStream getJarInputStream(String currentFile, final URLConnection urlconnection)
/*    */    throws Exception
/*    */  {
/* 496 */    final InputStream[] is = new InputStream[1];
/*    */
/* 500 */    for (int j = 0; (j < 3) && (is[0] == null); j++) {
/* 501 */      Thread t = new Thread() {
/*    */        public void run() {
/*    */          try {
/* 504 */            is[0] = urlconnection.getInputStream();
/*    */          }
/*    */          catch (IOException localIOException)
/*    */          {
/*    */          }
/*    */        }
/*    */      };
/* 510 */      t.setName("JarInputStreamThread");
/* 511 */      t.start();
/*    */
/* 513 */      int iterationCount = 0;
/* 514 */      while ((is[0] == null) && (iterationCount++ < 5)) {
/*    */        try {
/* 516 */          t.join(1000L);
/*    */        }
/*    */        catch (InterruptedException localInterruptedException)
/*    */        {
/*    */        }
/*    */      }
/* 522 */      if (is[0] != null) continue;
/*    */      try {
/* 524 */        t.interrupt();
/* 525 */        t.join();
/*    */      }
/*    */      catch (InterruptedException localInterruptedException1)
/*    */      {
/*    */      }
/*    */    }
/*    */
/* 532 */    if (is[0] == null) {
/* 533 */      if (currentFile.equals("minecraft.jar")) {
/* 534 */        throw new Exception("Unable to download " + currentFile);
/*    */      }
/* 536 */      throw new Exception("Unable to download " + currentFile);
/*    */    }
/*    */
/* 541 */    return is[0];
/*    */  }
/*    */
/*    */  protected void extractLZMA(String in, String out)
/*    */    throws Exception
/*    */  {
/* 553 */    File f = new File(in);
/* 554 */    FileInputStream fileInputHandle = new FileInputStream(f);
/*    */
/* 557 */    Class clazz = Class.forName("LZMA.LzmaInputStream");
/* 558 */    Constructor constructor = clazz.getDeclaredConstructor(new Class[] { InputStream.class });
/* 559 */    InputStream inputHandle = (InputStream)constructor.newInstance(new Object[] { fileInputHandle });
/*    */
/* 562 */    OutputStream outputHandle = new FileOutputStream(out);
/*    */
/* 564 */    byte[] buffer = new byte[16384];
/*    */
/* 566 */    int ret = inputHandle.read(buffer);
/* 567 */    while (ret >= 1) {
/* 568 */      outputHandle.write(buffer, 0, ret);
/* 569 */      ret = inputHandle.read(buffer);
/*    */    }
/*    */
/* 572 */    inputHandle.close();
/* 573 */    outputHandle.close();
/*    */
/* 575 */    outputHandle = null;
/* 576 */    inputHandle = null;
/*    */
/* 579 */    f.delete();
/*    */  }
/*    */
/*    */  protected void extractPack(String in, String out)
/*    */    throws Exception
/*    */  {
/* 590 */    File f = new File(in);
/* 591 */    FileOutputStream fostream = new FileOutputStream(out);
/* 592 */    JarOutputStream jostream = new JarOutputStream(fostream);
/*    */
/* 594 */    Pack200.Unpacker unpacker = Pack200.newUnpacker();
/* 595 */    unpacker.unpack(f, jostream);
/* 596 */    jostream.close();
/*    */
/* 599 */    f.delete();
/*    */  }
/*    */
/*    */  protected void extractJars(String path)
/*    */    throws Exception
/*    */  {
/* 609 */    this.state = 5;
/*    */
/* 611 */    float increment = 10.0F / this.urlList.length;
/*    */
/* 613 */    for (int i = 0; i < this.urlList.length; i++) {
/* 614 */      this.percentage = (55 + (int)(increment * (i + 1)));
/* 615 */      String filename = getFileName(this.urlList[i]);
/*    */
/* 617 */      if (filename.endsWith(".pack.lzma")) {
/* 618 */        this.subtaskMessage = ("Extracting: " + filename + " to " + filename.replaceAll(".lzma", ""));
/* 619 */        extractLZMA(path + filename, path + filename.replaceAll(".lzma", ""));
/*    */
/* 621 */        this.subtaskMessage = ("Extracting: " + filename.replaceAll(".lzma", "") + " to " + filename.replaceAll(".pack.lzma", ""));
/* 622 */        extractPack(path + filename.replaceAll(".lzma", ""), path + filename.replaceAll(".pack.lzma", ""));
/* 623 */      } else if (filename.endsWith(".pack")) {
/* 624 */        this.subtaskMessage = ("Extracting: " + filename + " to " + filename.replace(".pack", ""));
/* 625 */        extractPack(path + filename, path + filename.replace(".pack", ""));
/* 626 */      } else if (filename.endsWith(".lzma")) {
/* 627 */        this.subtaskMessage = ("Extracting: " + filename + " to " + filename.replace(".lzma", ""));
/* 628 */        extractLZMA(path + filename, path + filename.replace(".lzma", ""));
/*    */      }
/*    */    }
/*    */  }
/*    */
/*    */  protected void extractNatives(String path) throws Exception
/*    */  {
/* 635 */    this.state = 5;
/*    */
/* 637 */    int initialPercentage = this.percentage;
/*    */
/* 639 */    String nativeJar = getJarName(this.urlList[(this.urlList.length - 1)]);
/*    */
/* 641 */    Certificate[] certificate = Launcher.class.getProtectionDomain().getCodeSource().getCertificates();
/*    */
/* 643 */    if (certificate == null) {
/* 644 */      URL location = Launcher.class.getProtectionDomain().getCodeSource().getLocation();
/*    */
/* 646 */      JarURLConnection jurl = (JarURLConnection)new URL("jar:" + location.toString() + "!/net/minecraft/Launcher.class").openConnection();
/* 647 */      jurl.setDefaultUseCaches(true);
/*    */      try {
/* 649 */        certificate = jurl.getCertificates();
/*    */      }
/*    */      catch (Exception localException)
/*    */      {
/*    */      }
/*    */    }
/* 655 */    File nativeFolder = new File(path + "natives");
/* 656 */    if (!nativeFolder.exists()) {
/* 657 */      nativeFolder.mkdir();
/*    */    }
/*    */
/* 660 */    JarFile jarFile = new JarFile(path + nativeJar, true);
/* 661 */    Enumeration entities = jarFile.entries();
/*    */
/* 663 */    this.totalSizeExtract = 0;
/*    */
/* 666 */    while (entities.hasMoreElements()) {
/* 667 */      JarEntry entry = (JarEntry)entities.nextElement();
/*    */
/* 671 */      if ((entry.isDirectory()) || (entry.getName().indexOf('/') != -1)) {
/*    */        continue;
/*    */      }
/* 674 */      this.totalSizeExtract = (int)(this.totalSizeExtract + entry.getSize());
/*    */    }
/*    */
/* 677 */    this.currentSizeExtract = 0;
/*    */
/* 679 */    entities = jarFile.entries();
/*    */
/* 681 */    while (entities.hasMoreElements()) {
/* 682 */      JarEntry entry = (JarEntry)entities.nextElement();
/*    */
/* 684 */      if ((entry.isDirectory()) || (entry.getName().indexOf('/') != -1))
/*    */      {
/*    */        continue;
/*    */      }
/* 688 */      File f = new File(path + "natives" + File.separator + entry.getName());
/* 689 */      if ((f.exists()) &&
/* 690 */        (!f.delete()))
/*    */      {
/*    */        continue;
/*    */      }
/*    */
/* 695 */      InputStream in = jarFile.getInputStream(jarFile.getEntry(entry.getName()));
/* 696 */      OutputStream out = new FileOutputStream(path + "natives" + File.separator + entry.getName());
/*    */
/* 699 */      byte[] buffer = new byte[65536];
/*    */      int bufferSize;
/* 701 */      while ((bufferSize = in.read(buffer, 0, buffer.length)) != -1)
/*    */      {
/* 702 */        out.write(buffer, 0, bufferSize);
/* 703 */        this.currentSizeExtract += bufferSize;
/*    */
/* 705 */        this.percentage = (initialPercentage + this.currentSizeExtract * 20 / this.totalSizeExtract);
/* 706 */        this.subtaskMessage = ("Extracting: " + entry.getName() + " " + this.currentSizeExtract * 100 / this.totalSizeExtract + "%");
/*    */      }
/*    */
/* 709 */      validateCertificateChain(certificate, entry.getCertificates());
/*    */
/* 711 */      in.close();
/* 712 */      out.close();
/*    */    }
/* 714 */    this.subtaskMessage = "";
/*    */
/* 716 */    jarFile.close();
/*    */
/* 718 */    File f = new File(path + nativeJar);
/* 719 */    f.delete();
/*    */  }
/*    */
/*    */  protected static void validateCertificateChain(Certificate[] ownCerts, Certificate[] native_certs)
/*    */    throws Exception
/*    */  {
/* 729 */    if (ownCerts == null) return;
/* 730 */    if (native_certs == null) throw new Exception("Unable to validate certificate chain. Native entry did not have a certificate chain at all");
/*    */
/* 732 */    if (ownCerts.length != native_certs.length) throw new Exception("Unable to validate certificate chain. Chain differs in length [" + ownCerts.length + " vs " + native_certs.length + "]");
/*    */
/* 734 */    for (int i = 0; i < ownCerts.length; i++)
/* 735 */      if (!ownCerts[i].equals(native_certs[i]))
/* 736 */        throw new Exception("Certificate mismatch: " + ownCerts[i] + " != " + native_certs[i]);
/*    */  }
/*    */
/*    */  protected String getJarName(URL url)
/*    */  {
/* 742 */    String fileName = url.getFile();
/*    */
/* 744 */    if (fileName.contains("?")) {
/* 745 */      fileName = fileName.substring(0, fileName.indexOf("?"));
/*    */    }
/* 747 */    if (fileName.endsWith(".pack.lzma"))
/* 748 */      fileName = fileName.replaceAll(".pack.lzma", "");
/* 749 */    else if (fileName.endsWith(".pack"))
/* 750 */      fileName = fileName.replaceAll(".pack", "");
/* 751 */    else if (fileName.endsWith(".lzma")) {
/* 752 */      fileName = fileName.replaceAll(".lzma", "");
/*    */    }
/*    */
/* 755 */    return fileName.substring(fileName.lastIndexOf('/') + 1);
/*    */  }
/*    */
/*    */  protected String getFileName(URL url) {
/* 759 */    String fileName = url.getFile();
/* 760 */    if (fileName.contains("?")) {
/* 761 */      fileName = fileName.substring(0, fileName.indexOf("?"));
/*    */    }
/* 763 */    return fileName.substring(fileName.lastIndexOf('/') + 1);
/*    */  }
/*    */
/*    */  protected void fatalErrorOccured(String error, Exception e) {
/* 767 */    e.printStackTrace();
/* 768 */    this.fatalError = true;
/* 769 */    this.fatalErrorDescription = ("Fatal error occured (" + this.state + "): " + error);
/* 770 */    System.out.println(this.fatalErrorDescription);
/* 771 */    if (e != null)
/* 772 */      System.out.println(generateStacktrace(e));
/*    */  }
/*    */
/*    */  public boolean canPlayOffline()
/*    */  {
/*    */    try
/*    */    {
/* 779 */      String path = (String)AccessController.doPrivileged(new PrivilegedExceptionAction() {
/*    */        public Object run() throws Exception {
/* 781 */          return Util.getWorkingDirectory() + File.separator + "bin" + File.separator;
/*    */        }
/*    */      });
/* 785 */      File dir = new File(path);
/* 786 */      if (!dir.exists()) return false;
/*    */
/* 788 */      dir = new File(dir, "version");
/* 789 */      if (!dir.exists()) return false;
/*    */
/* 791 */      if (dir.exists()) {
/* 792 */        String version = readVersionFile(dir);
/* 793 */        if ((version != null) && (version.length() > 0))
/* 794 */          return true;
/*    */      }
/*    */    }
/*    */    catch (Exception e) {
/* 798 */      e.printStackTrace();
/* 799 */      return false;
/*    */    }
/* 801 */    return false;
/*    */  }
/*    */ }

 

 

And the Util class (Where the working directory is changed) :

 

 

/*     */ package net.minecraft;
/*     */ 
/*     */ import java.io.BufferedReader;
/*     */ import java.io.DataInputStream;
/*     */ import java.io.DataOutputStream;
/*     */ import java.io.File;
/*     */ import java.io.InputStream;
/*     */ import java.io.InputStreamReader;
/*     */ import java.io.PrintStream;
/*     */ import java.lang.reflect.Method;
/*     */ import java.net.URI;
/*     */ import java.net.URL;
/*     */ import java.security.PublicKey;
/*     */ import java.security.cert.Certificate;
/*     */ import javax.net.ssl.HttpsURLConnection;
/*     */ 
/*     */ public class Util
/*     */ {
/*  21 */   private static File workDir = null;
/*     */ 
/*     */   public static File getWorkingDirectory() {
/*  24 */     if (workDir == null) workDir = getWorkingDirectory("wetope");
/*  25 */     return workDir;
/*     */   }
/*     */ 
/*     */    public static File getWorkingDirectory(String applicationName) {
    String userHome = System.getProperty("user.home", ".");
    File workingDirectory;
    if(getPlatform() == OS.solaris || getPlatform() ==  OS.linux)
    {
      workingDirectory = new File(userHome, '.' + applicationName + '/');
    }
    else if(getPlatform() == OS.windows)
    {
      String applicationData = System.getenv("APPDATA");
      if (applicationData != null) workingDirectory = new File(applicationData, "." + applicationName + '/'); else
        workingDirectory = new File(userHome, '.' + applicationName + '/');
    }
    else if(getPlatform() == OS.macos)
    {
      workingDirectory = new File(userHome, "Library/Application Support/" + applicationName);
    }
    else
    {
      workingDirectory = new File(userHome, applicationName + '/');
    }
    
    if ((!workingDirectory.exists()) && (!workingDirectory.mkdirs())) throw new RuntimeException("The working directory could not be created: " + workingDirectory);
    return workingDirectory;
  }
/*     */ 
/*     */   private static OS getPlatform() {
/*  52 */     String osName = System.getProperty("os.name").toLowerCase();
/*  53 */     if (osName.contains("win")) return OS.windows;
/*  54 */     if (osName.contains("mac")) return OS.macos;
/*  55 */     if (osName.contains("solaris")) return OS.solaris;
/*  56 */     if (osName.contains("sunos")) return OS.solaris;
/*  57 */     if (osName.contains("linux")) return OS.linux;
/*  58 */     if (osName.contains("unix")) return OS.linux;
/*  59 */     return OS.unknown;
/*     */   }
/*     */ 
/*     */   public static String excutePost(String targetURL, String urlParameters)
/*     */   {
/*  64 */     HttpsURLConnection connection = null;
/*     */     try
/*     */     {
/*  67 */       URL url = new URL(targetURL);
/*  68 */       connection = (HttpsURLConnection)url.openConnection();
/*  69 */       connection.setRequestMethod("POST");
/*  70 */       connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
/*     */ 
/*  72 */       connection.setRequestProperty("Content-Length", Integer.toString(urlParameters.getBytes().length));
/*  73 */       connection.setRequestProperty("Content-Language", "en-US");
/*     */ 
/*  75 */       connection.setUseCaches(false);
/*  76 */       connection.setDoInput(true);
/*  77 */       connection.setDoOutput(true);
/*     */ 
/*  80 */       connection.connect();
/*  81 */       Certificate[] certs = connection.getServerCertificates();
/*     */ 
/*  83 */       byte[] bytes = new byte[294];
/*  84 */       DataInputStream dis = new DataInputStream(Util.class.getResourceAsStream("minecraft.key"));
/*  85 */       dis.readFully(bytes);
/*  86 */       dis.close();
/*     */ 
/*  88 */       Certificate c = certs[0];
/*  89 */       PublicKey pk = c.getPublicKey();
/*  90 */       byte[] data = pk.getEncoded();
/*     */ 
/*  92 */       for (int i = 0; i < data.length; i++) {
/*  93 */         if (data[i] == bytes[i]) continue; throw new RuntimeException("Public key mismatch");
/*     */       }
/*     */ 
/*  97 */       DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
/*  98 */       wr.writeBytes(urlParameters);
/*  99 */       wr.flush();
/* 100 */       wr.close();
/*     */ 
/* 103 */       InputStream is = connection.getInputStream();
/* 104 */       BufferedReader rd = new BufferedReader(new InputStreamReader(is));
/*     */ 
/* 106 */       StringBuffer response = new StringBuffer();
/*     */       String line;
/* 107 */       while ((line = rd.readLine()) != null)
/*     */       {
/* 108 */         response.append(line);
/* 109 */         response.append('\r');
/*     */       }
/* 111 */       rd.close();
/*     */ 
/* 115 */       String str1 = response.toString();
/*     */       return str1;
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 119 */       e.printStackTrace();
/*     */       return null;
/*     */     }
/*     */     finally
/*     */     {
/* 124 */       if (connection != null)
/* 125 */         connection.disconnect();
/*     */     }
/*     */   }
/*     */ 
/*     */   public static boolean isEmpty(String str) {
/* 131 */     return (str == null) || (str.length() == 0);
/*     */   }
/*     */ 
/*     */   public static void openLink(URI uri) {
/*     */     try {
/* 136 */       Object o = Class.forName("java.awt.Desktop").getMethod("getDesktop", new Class[0]).invoke(null, new Object[0]);
/* 137 */       o.getClass().getMethod("browse", new Class[] { URI.class }).invoke(o, new Object[] { uri });
/*     */     } catch (Throwable e) {
/* 139 */       System.out.println("Failed to open link " + uri.toString());
/*     */     }
/*     */   }
/*     */ 
/*     */   private static enum OS
/*     */   {
/*  18 */     linux, solaris, windows, macos, unknown;
/*     */   }
/*     */ }

/* Location:           C:\Documents and Settings\FLEJA\Bureau\minecraft.jar
* Qualified Name:     net.minecraft.Util
* JD-Core Version:    0.6.0
*/

 

 

The whole stuff works perfectly when I don't add additionnal mods to the .jar file. (There is only the two default ones : FML & Forge).

Moreover, I get the same error when I add the IronChest Mod.

 

One again you're not setting the minecraft directory properly.

Yes, it is possible, but how should I do so ?

 

If you need to see anything else, I can paste it here.

 

Thanks for your help.

 

PS : If i've done any English mistakes, I'm realy sorry for this :S

Link to comment
Share on other sites

Go look at the plethora of other launchers that do exactly what you want.

And do not post mojang code here.

You have to set the MC directory in Minecraft, not just the launcher.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.