0

So you surely know the game Minecraft. You can add mod via forge. There is a mod that a really want to have but it give me an error when lauching:

Property exception component:'simpleNGramModel' property:'location' - Bad URL C:\Users\Samuel\Desktop\MultiMC\instances\gfwg\minecraft\config\spells.lmunknown protocol: c

While I absolutly want this mod and I think that the dev had aboonded the project I want and decompile the mod after finding witch function make my minecraft crashes I really don't know what's going wrong (I'm not a big java developper):

edu/cmu/sphinx/util/props/ConfigurationManagerUtils.class

public static URL getResource(String name, PropertySheet ps)
    throws PropertyException
  {
    String location = ps.getString(name);
    if (location == null) {
      throw new InternalConfigurationException(ps.getInstanceName(), name, "Required resource property '" + name + "' not set");
    }
    try
    {
      URL url = resourceToURL(location);
      if (url == null) {
        throw new InternalConfigurationException(ps.getInstanceName(), name, "Can't locate " + location);
      }
      return url;
    }
    catch (MalformedURLException e)
    {
      throw new InternalConfigurationException(e, ps.getInstanceName(), name, "Bad URL " + location + e.getMessage());
    }
  }

  static final Pattern jarPattern = Pattern.compile("resource:(.*)", 2);

  public static URL resourceToURL(String location)
    throws MalformedURLException
  {
    Matcher jarMatcher = jarPattern.matcher(location);
    if (jarMatcher.matches())
    {
      String resourceName = jarMatcher.group(1);
      return ConfigurationManagerUtils.class.getResource(resourceName);
    }
    if (location.indexOf(':') == -1) {
      location = "file:" + location;
    }
    return new URL(location);
  }

for help If I move my minecraft to an another disk (I://) I get this error

Property exception component:'simpleNGramModel' property:'location' - Bad URL I:\MultiMC\instances\gfwg\minecraft\config\spells.lmunknown protocol: i

The original mod thread: http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/2692177-forge-hp-spells-cast-spells-with-your-voice?page=7

PS:I 'm french sorry for mistake

1 Answers1

1
if (location.indexOf(':') == -1) {
  location = "file:" + location;
}

Change that to

if (location.indexOf(':') != -1) {
  location = "file:///" + location.replace('\\', '/');
}

If that fails as well, an alternative solution might be

if (location.indexOf(':') != -1) {
  File f = new File(location);
  return f.toURI().toURL();
}

There is a toURL method in java.io.File as well, but it's deprecated I avoid using deprecated methods.

Lothar
  • 5,323
  • 1
  • 11
  • 27
  • And how to do this – TheStaticTurtle Sep 04 '17 at 14:52
  • @TurtleForGaming What do you mean by that? – Lothar Sep 04 '17 at 15:09
  • I mean edit the source .class file. I manage to open It in a java decompiler to see the source code of the class but how to recompile it. I precise that I have a .java file modified – TheStaticTurtle Sep 04 '17 at 15:20
  • @TurtleForGaming I assume you can copy&paste from the decompiler view. The rest depends on the development environment you're using, but in general terms, you need to create a folder structure that represents the package of the decompiled class, create the java-file in this directory, paste the decompiled source into it, do the changes and compile the class. The concrete single steps might be commands in a shell or mouse clicks in the IDE of your choice, so I can't be more specific here (and has nothing to do with your original question) – Lothar Sep 04 '17 at 15:24
  • It's a bit complicated because it's my mod so I doesn't have access to the source code, dev env. Can I compile only one class file ?? – TheStaticTurtle Sep 04 '17 at 15:29
  • @TurtleForGaming Yes, by adding the mod's jar to the classpath of the compiler/Build paths of the IDE/... – Lothar Sep 04 '17 at 15:30
  • 1
    I really sucks at java but if I give you the file can you build it for me ??. I would be very happy of that. – TheStaticTurtle Sep 04 '17 at 15:47