前提
ここに質問の内容を詳しく書いてください。
(例)
javaでマイクラmoddingをしています。
リソースの置き場所に困っています。
ファイル名はあっています。
発生している問題・エラーメッセージ
ファイルが見つからないとのメッセージ(IOException)
該当のソースコード
java
1 private static final ResourceLocation CHESTS =2 new ResourceLocation(MarkerMod.MODID, "chests.json");3-----4 5 void loadJSON() {6 String path = CHESTS.getResourcePath();7 8 System.out.printf(9 "PATH::: %s", path 10 );11 12 try {13 FileReader reader = new FileReader(path);14// JsonObject object = new Gson().fromJson(reader, JsonObject.class);15 16 try {17 // jsonにシリアライズ。18 JsonArray array = new Gson().fromJson(reader, JsonArray.class);19 if (array != null) {20 for (Object o : array) {21 MapInfo info = new Gson().fromJson((String) o, MapInfo.class);22 if (info != null) {23 this.addChest(info);24 } else {25 System.out.printf("-------------------\n---NO DATA-%s----------\n---------", o);26 }27 }28 }29 } catch (ClassCastException e) {30 JsonObject object = new Gson().fromJson(reader, JsonObject.class);31 System.out.printf("%s", object.toString());32 } catch (Exception e) {33 e.printStackTrace();34 }35 } catch (IOException e) {36 e.printStackTrace();37 }38 }39}
試したこと
リソースの置き場所の変更
今:resource/chests.json
試したものresource/texture/chests.jsonnew ResourceLocation(MarkerMod.MODID, "resource/chests.json")
補足情報(FW/ツールのバージョンなど)
build.gradle
gradle
1minecraft { 2 version = "1.8.9-11.15.1.2318-1.8.9" 3 runDir = "run" 4 5 // the mappings can be changed at any time, and must be in the following format. 6 // snapshot_YYYYMMDD snapshot are built nightly. 7 // stable_# stables are built at the discretion of the MCP team. 8 // Use non-default mappings at your own risk. they may not allways work. 9 // simply re-run your setup task after changing the mappings to update your workspace. 10 mappings = "stable_20" 11 // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. 12}
最悪、このファイルをconfigフォルダにコピーするようにして読み込むことも考えています。

0 コメント