Navigation

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    Crach ThirstMod

    Sans suite
    1.7.10
    2
    5
    556
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • I
      impuuu last edited by

      Bonjour/Bonsoir 
      j ai installé les source du thirstmod dans mon mod mais quand je tente de lancer le minecraft de dev le jeu crach

      Erreur :

      at java.io.Reader.<init>(Unknown Source)
      at java.io.InputStreamReader.<init>(Unknown Source)
      at com.thetorine.thirstmod.core.content.packs.ContentLoader.parseTemplate(ContentLoader.java:43)
      at com.thetorine.thirstmod.core.content.packs.ContentLoader.<init>(ContentLoader.java:36)
      at com.thetorine.thirstmod.core.main.ThirstMod.loadMain(ThirstMod.java:60)
      at com.thetorine.thirstmod.core.main.ThirstMod.preInit(ThirstMod.java:41)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:532)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
      at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
      at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
      at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
      at com.google.common.eventbus.EventBus.post(EventBus.java:275)
      at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:212)
      at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
      at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
      at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
      at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
      at com.google.common.eventbus.EventBus.post(EventBus.java:275)
      at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119)
      at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:556)
      at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:243)
      at net.minecraft.client.Minecraft.startGame(Minecraft.java:522)
      
      

      le code de la classe thirstMod

      package com.thetorine.thirstmod.core.main;
      
      import java.io.File;
      import java.lang.reflect.Field;
      
      import com.thetorine.thirstmod.core.content.BlockLoader;
      import com.thetorine.thirstmod.core.content.ItemLoader;
      import com.thetorine.thirstmod.core.content.packs.ContentLoader;
      import com.thetorine.thirstmod.core.content.packs.DrinkRegistry;
      import com.thetorine.thirstmod.core.network.*;
      import com.thetorine.thirstmod.core.player.PlayerContainer;
      import com.thetorine.thirstmod.core.utils.Config;
      import com.thetorine.thirstmod.core.utils.Constants;
      
      import cpw.mods.fml.common.Mod;
      import cpw.mods.fml.common.Mod.EventHandler;
      import cpw.mods.fml.common.Mod.Instance;
      import cpw.mods.fml.common.event.*;
      import cpw.mods.fml.common.network.*;
      import cpw.mods.fml.common.*;
      import cpw.mods.fml.relauncher.Side;
      import net.minecraft.creativetab.CreativeTabs;
      import net.minecraft.item.Item;
      import net.minecraftforge.common.*;
      
      @Mod(modid = Constants.MODID, version = Constants.VERSION, name = Constants.NAME)
      public class ThirstMod {
      @Instance(Constants.MODID)
      public static ThirstMod instance;
      public static EventSystem eventHook = new EventSystem();
      public static Config config = new Config();
      
      @SidedProxy(clientSide = Constants.PACKAGE + ".core.client.ClientProxy", serverSide = Constants.PACKAGE + ".core.main.CommonProxy")
      public static CommonProxy commonProxy;
      
      @EventHandler
      public void preInit(FMLPreInitializationEvent event) {
      FMLCommonHandler.instance().bus().register(eventHook);
      MinecraftForge.EVENT_BUS.register(eventHook);
      NetworkRegistry.INSTANCE.registerGuiHandler(this, eventHook);
      loadMain();
      }
      
      @EventHandler
      public void postInit(FMLPostInitializationEvent event) {
      new DrinkRegistry();
      }
      
      @EventHandler
      public void serverClosed(FMLServerStoppedEvent event) {
      if(FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
      PlayerContainer.ALL_PLAYERS.clear();
      }
      }
      
      public void loadMain() {
      new NetworkHandler();
      new BlockLoader();
      new ItemLoader(); 
      new ContentLoader();
      }
      
      public static String getMinecraftDir() {
      try {
      Field mcDataDir = Loader.class.getDeclaredField("minecraftDir");
      if(mcDataDir != null) {
      mcDataDir.setAccessible(true);
      return ((File)mcDataDir.get(null)).getAbsolutePath();
      }
      throw new Exception();
      } catch(Exception e) {
      print("Unable to retrieve Minecraft Directory.");
      return null;
      }
      }
      
      public static void print(String s) {
      System.out.println("[ThirstMod] " + s);
      }
      
      public static CreativeTabs thirstCreativeTab = new CreativeTabs("drinks") {
      @Override
      public Item getTabIconItem() {
      return ItemLoader.chocolateMilk;
      }
      };
      }
      ```</init></init></init>
      1 Reply Last reply Reply Quote 0
      • robin4002
        robin4002 Administrateurs Rédacteurs Moddeurs confirmés last edited by

        Salut;
        C’est le code de la classe ContentLoader qu’il faudrait.

        1 Reply Last reply Reply Quote 0
        • I
          impuuu last edited by

          ok je te donne sa tout de suite

          import java.io.BufferedReader;
          import java.io.File;
          import java.io.FileReader;
          import java.io.IOException;
          import java.io.InputStreamReader;
          import java.util.ArrayList;
          import java.util.Enumeration;
          import java.util.HashMap;
          import java.util.List;
          import java.util.Map;
          import java.util.zip.ZipEntry;
          import java.util.zip.ZipFile;
          
          import com.thetorine.thirstmod.core.content.ItemDrink;
          import com.thetorine.thirstmod.core.content.blocks.DBRecipes;
          import com.thetorine.thirstmod.core.main.ThirstMod;
          
          import cpw.mods.fml.common.registry.GameData;
          import cpw.mods.fml.common.registry.GameRegistry;
          import cpw.mods.fml.common.registry.LanguageRegistry;
          import net.minecraft.item.Item;
          import net.minecraft.item.ItemStack;
          
          public class ContentLoader {
          public List <string>categories = new ArrayList<string>();
          public Map<string, arraylist<templatemodifier="">> templateLoad = new HashMap<string, arraylist<templatemodifier="">>();
          public Map<integer, arraylist<drinkmodifier="">> drinkLoad = new HashMap<integer, arraylist<drinkmodifier="">>();
          public HashMap <string, string="">languageTable = new HashMap<string, string="">();
          public List <file>filesToLoad = new ArrayList<file>();
          public String split;
          
          public ContentLoader() {
          try {
          parseTemplate();
          } catch (IOException e) {
          e.printStackTrace();
          }
          }
          
          public void parseTemplate() throws IOException {
          BufferedReader reader = new BufferedReader(new InputStreamReader(ContentLoader.class.getResourceAsStream("/assets/thirstmod/content/template.txt")));
          List <string>elements = new ArrayList<string>();
          while(reader.ready()) {
          elements.add(reader.readLine());
          }
          String prevCategory = "";
          for(String s : elements) {
          if(s.startsWith(" ")) {
          String[] modifers = s.replaceFirst(" ", "").split(" ");
          TemplateModifier c = new TemplateModifier(modifers[0], modifers[1]);
          addValues(prevCategory, c, 0);
          } else if(!s.contains("//")) {
          prevCategory = s;
          if(s.contains("split")) {
          split = s.split(" ", 2)[1];
          }
          }
          }
          reader.close();
          loadDrinks(new File(ThirstMod.getMinecraftDir(), "/thirstmod/content/"));
          }
          
          public void loadDrinks(File dir) {
          int i = 0;
          if(!dir.exists()) {
          dir.mkdirs();
          return;
          }
          findFiles(dir);
          for(File f : filesToLoad) {
          try {
          if(f.getName().endsWith(".txt")) {
          parseDrink(new BufferedReader(new FileReader(f)), i);
          i++;
          } else if(f.getName().endsWith(".zip")) {
          i = readZip(f, i);
          }
          } catch (Exception e) {
          e.printStackTrace();
          }
          }
          addDrinks();
          }
          
          public void findFiles(File root) {
              File[] files = root.listFiles(); 
              if(files != null) {
              for (File file : files) {
                  if (file.isFile()) {
                      if(file.getName().endsWith(".txt") || file.getName().endsWith(".zip")) {
                      filesToLoad.add(file);
                      }
                  } else if (file.isDirectory()) {
                      findFiles(file);
                  }
              }
              }
          }
          
          public void parseDrink(BufferedReader reader, int currentLoad) throws IOException {
          List <string>elements = new ArrayList<string>();
          while(reader.ready()) {
          elements.add(reader.readLine());
          }
          String prevCategory = "";
          for(String s : elements) {
          if(s.startsWith(" ")) {
          String[] modifers = s.replaceFirst(" ", "").split(split, 2);
          for(TemplateModifier c: templateLoad.get(prevCategory)) {
          if(c.modifier.equals(modifers[0])) {
          DrinkModifier m = new DrinkModifier(modifers[0], parseValue(modifers[1], c.datatype));
          addValues(currentLoad, m, 1);
          }
          }
          } else {
          prevCategory = s;
          if(!categories.contains(s)) {
          categories.add(s);
          }
          }
          }
          reader.close();
          }
          
          public int readZip(File zip, int i) throws IOException {
          int load = i;
          ZipFile zf = new ZipFile(zip);
          Enumeration entries = zf.entries();
          while(entries.hasMoreElements()) {
          ZipEntry entry = entries.nextElement();
          if(entry.getName().endsWith(".txt") && !entry.getName().contains("__MACOSX/._")) {
          BufferedReader reader = new BufferedReader(new InputStreamReader(zf.getInputStream(entry)));
          parseDrink(reader, load);
          reader.close();
          load++;
          }
          }
          zf.close();
          return load;
          }
          
          public void addDrinks() {
          for(int i = 0; i < drinkLoad.size(); i++) {
          String name = "", shortname = "", item = "";
          int color = 0, stacksize = 0, bar_heal = 0, bar_heal_hunger = 0, potionID = 0, duration = 0, itemMetadata = 0;
          float sat_thirst = 0, sat_hunger = 0, poisonChance = 0;
          boolean hasEffect = false, potion_cure = false, alwaysDrinkable = false;
          
          for(DrinkModifier dm : drinkLoad.get(i)) {
          if(dm.modifier.equals("name")) 
          name = (String) dm.value;
          if(dm.modifier.equals("internal_name")) 
          shortname = (String) dm.value;
          if(dm.modifier.equals("item"))
          item = (String) dm.value;
          if(dm.modifier.equals("item_mod_id")) 
          item = ((String) dm.value) + ":" + item; 
          if(dm.modifier.equals("item_metadata"))
          itemMetadata = (Integer) dm.value;
          if(dm.modifier.equals("colour"))
          color = (Integer) dm.value;
          if(dm.modifier.equals("stacksize"))
          stacksize = (Integer) dm.value;
          if(dm.modifier.equals("bar_heal"))
          bar_heal = (Integer) dm.value;
          if(dm.modifier.equals("bar_heal_hunger"))
          bar_heal_hunger = (Integer) dm.value;
          if(dm.modifier.equals("id"))
          potionID = (Integer) dm.value;
          if(dm.modifier.equals("duration"))
          duration = (Integer) dm.value;
          if(dm.modifier.equals("saturation_heal"))
          sat_thirst = (Float) dm.value;
          if(dm.modifier.equals("saturation_heal_hunger"))
          sat_hunger = (Float) dm.value;
          if(dm.modifier.equals("poisonChance"))
          poisonChance = (Float) dm.value;
          if(dm.modifier.equals("effect")) 
          hasEffect = (Boolean) dm.value;
          if(dm.modifier.equals("potion_cure")) 
          potion_cure = (Boolean) dm.value;
          if(dm.modifier.equals("always_drinkable")) 
          alwaysDrinkable = (Boolean) dm.value;
          }
          
          ItemDrink loadedDrink = new ItemDrink(bar_heal, sat_thirst, color, stacksize, hasEffect, alwaysDrinkable, shortname)
          .healFood(bar_heal_hunger, sat_hunger).setPoisoningChance(poisonChance)
          .setPotionEffect(potionID, duration).setCuresPotions(potion_cure);
          
          if(shortname.length() > 0) {
          Item recipeItem = GameData.getItemRegistry().getObject(item);
          if(recipeItem != null) {
          loadedDrink.setRecipeItem(recipeItem);
          GameRegistry.registerItem(loadedDrink, shortname);
          DrinkLists.addDrink(new ItemStack(loadedDrink), bar_heal, sat_thirst);
          ItemStack tempRecipeStack = new ItemStack(recipeItem, 0, itemMetadata);
          DBRecipes.instance().addRecipe(tempRecipeStack.getUnlocalizedName(), itemMetadata, new ItemStack(loadedDrink));
          languageTable.put(String.format("item.%s.name", shortname), name);
          } else {
          ThirstMod.print(
          "Content Loader: Unable to aquire recipe for item id: " + item 
            + "/n Item not added: " + name);
          }
          } 
          }
          injectLanguage();
          }
          
          @SuppressWarnings({ "unchecked", "rawtypes" })
          private void addValues(Object key, Object value, int map) {
          ArrayList tempList = null;
          switch(map) {
          case 0: {
          if (templateLoad.containsKey(key)) {
          tempList = templateLoad.get(key);
          if (tempList == null)
          tempList = new ArrayList<templatemodifier>();
          tempList.add(value);
          } else {
          tempList = new ArrayList<templatemodifier>();
          tempList.add(value);
          }
          templateLoad.put((String) key, tempList);
          break;
          }
          case 1: {
          if (drinkLoad.containsKey(key)) {
          tempList = drinkLoad.get(key);
          if (tempList == null)
          tempList = new ArrayList<templatemodifier>();
          tempList.add(value);
          } else {
          tempList = new ArrayList<templatemodifier>();
          tempList.add(value);
          }
          drinkLoad.put((Integer) key, tempList);
          break;
          }
          }
          }
          
          private Object parseValue(String s, String datatype) {
          if(datatype.equals("string")) {
          return s;
          } else if(datatype.equals("integer")) {
          return Integer.parseInt(s);
          } else if(datatype.equals("float")) {
          return Float.parseFloat(s);
          } else if(datatype.equals("boolean")) {
          return Boolean.parseBoolean(s);
          } else if(datatype.equals("hex")) {
          return Integer.parseInt(s, 16);
          }
          return null;
          }
          
          public void injectLanguage() {
          if(languageTable.size() <= 0) return;
          LanguageRegistry.instance().injectLanguage("en_US", languageTable);
          }
          
          private static class TemplateModifier {
          public String modifier;
          public String datatype;
          
          public TemplateModifier(String s, String s1) {
          this.modifier = s;
          this.datatype = s1;
          }
          }
          
          private static class DrinkModifier {
          public String modifier;
          public Object value;
          
          public DrinkModifier(String modifier, Object value) {
          this.modifier = modifier;
          this.value = value;
          }
          }
          }
          ```</templatemodifier></templatemodifier></templatemodifier></templatemodifier></string></string></string></string></file></file></string,></string,></integer,></integer,></string,></string,></string></string>
          1 Reply Last reply Reply Quote 0
          • robin4002
            robin4002 Administrateurs Rédacteurs Moddeurs confirmés last edited by

            Le fichier suivant est sûrement manquant : /assets/thirstmod/content/template.txt

            1 Reply Last reply Reply Quote 0
            • I
              impuuu last edited by

              merci

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post
              Design by Woryk
              Contact / Mentions Légales / Faire un don

              MINECRAFT FORGE FRANCE © 2018

              Powered by NodeBB