java.io.FileNotFoundException: intech:sounds.json

Версия Minecraft
1.16.5
API
Forge
88
4
6
Здравствуйте, у меня возникла проблема с созданием звуков (1.16.5 FORGE).

Вот часть из лога:
Форматирование (BB-код):
[16окт2021 13:33:16.606] [modloading-worker-3/INFO] [STDERR/]: [com.algorithmlx.intech.common.setup.SoundRegistry:<clinit>:30]: java.io.FileNotFoundException: intech:sounds.json
[16окт2021 13:33:16.606] [modloading-worker-3/INFO] [STDERR/]: [com.algorithmlx.intech.common.setup.SoundRegistry:<clinit>:30]:     at net.minecraft.resources.SimpleReloadableResourceManager.getResource(SimpleReloadableResourceManager.java:63)
[16окт2021 13:33:16.606] [modloading-worker-3/INFO] [STDERR/]: [com.algorithmlx.intech.common.setup.SoundRegistry:<clinit>:30]:     at com.algorithmlx.intech.common.setup.SoundRegistry.<clinit>(SoundRegistry.java:25)
[16окт2021 13:33:16.607] [modloading-worker-3/INFO] [STDERR/]: [com.algorithmlx.intech.common.setup.SoundRegistry:<clinit>:30]:     at com.algorithmlx.intech.InTech.<init>(InTech.java:28)
[16окт2021 13:33:16.614] [modloading-worker-3/INFO] [STDERR/]: [com.algorithmlx.intech.common.setup.SoundRegistry:<clinit>:30]:     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[16окт2021 13:33:16.614] [modloading-worker-3/INFO] [STDERR/]: [com.algorithmlx.intech.common.setup.SoundRegistry:<clinit>:30]:     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
[16окт2021 13:33:16.614] [modloading-worker-3/INFO] [STDERR/]: [com.algorithmlx.intech.common.setup.SoundRegistry:<clinit>:30]:     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[16окт2021 13:33:16.615] [modloading-worker-3/INFO] [STDERR/]: [com.algorithmlx.intech.common.setup.SoundRegistry:<clinit>:30]:     at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
[16окт2021 13:33:16.615] [modloading-worker-3/INFO] [STDERR/]: [com.algorithmlx.intech.common.setup.SoundRegistry:<clinit>:30]:     at java.lang.Class.newInstance(Class.java:442)
[16окт2021 13:33:16.615] [modloading-worker-3/INFO] [STDERR/]: [com.algorithmlx.intech.common.setup.SoundRegistry:<clinit>:30]:     at net.minecraftforge.fml.javafmlmod.FMLModContainer.constructMod(FMLModContainer.java:81)
[16окт2021 13:33:16.621] [modloading-worker-3/INFO] [STDERR/]: [com.algorithmlx.intech.common.setup.SoundRegistry:<clinit>:30]:     at net.minecraftforge.fml.ModContainer.lambda$buildTransitionHandler$4(ModContainer.java:120)
[16окт2021 13:33:16.621] [modloading-worker-3/INFO] [STDERR/]: [com.algorithmlx.intech.common.setup.SoundRegistry:<clinit>:30]:     at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1640)
[16окт2021 13:33:16.621] [modloading-worker-3/INFO] [STDERR/]: [com.algorithmlx.intech.common.setup.SoundRegistry:<clinit>:30]:     at java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1632)
[16окт2021 13:33:16.621] [modloading-worker-3/INFO] [STDERR/]: [com.algorithmlx.intech.common.setup.SoundRegistry:<clinit>:30]:     at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
[16окт2021 13:33:16.621] [modloading-worker-3/INFO] [STDERR/]: [com.algorithmlx.intech.common.setup.SoundRegistry:<clinit>:30]:     at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1067)
[16окт2021 13:33:16.622] [modloading-worker-3/INFO] [STDERR/]: [com.algorithmlx.intech.common.setup.SoundRegistry:<clinit>:30]:     at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1703)
[16окт2021 13:33:16.622] [modloading-worker-3/INFO] [STDERR/]: [com.algorithmlx.intech.common.setup.SoundRegistry:<clinit>:30]:     at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:172)
Вот сам код (в 2 класса):

SoundRegistry:
public class SoundRegistry {
    public static final Map<String, SoundEvent> sounds = new HashMap<>();

    static {
        try {
            InputStream is = Minecraft.getInstance().getResourceManager().getResource(new ResourceLocation(ModId, "sounds.json")).getInputStream();
            for(Map.Entry<String, JsonElement> element : new ArrayList<>(SaveJsonHelper.readObject(is).entrySet())) {
                sounds.put(element.getKey(), addSoundsToRegistry(element.getKey()));
            }
        } catch (IOException e){
            e.printStackTrace();
        }
    }

    private static SoundEvent addSoundsToRegistry(String soundId){
        ResourceLocation shotSoundLocation = new ResourceLocation(ModId, soundId);
        SoundEvent soundEvent = new SoundEvent(shotSoundLocation);
        soundEvent.setRegistryName(shotSoundLocation);
        return soundEvent;
    }

    @SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true)
    public static void registeredSoundEvents(RegistryEvent.Register<SoundEvent> event) {
        for(String audioFile : new ArrayList<>(sounds.keySet())){
            event.getRegistry().register(sounds.get(audioFile));
        }
    }
}


SaveJsonHelper:
public class SaveJsonHelper {
    public static void save (File file, JsonObject obj) {
        try {
            if (!file.exists()) {
                file.getParentFile().mkdirs();
                file.createNewFile();
            }

            Gson gson = (new GsonBuilder()).setPrettyPrinting().create();

            BufferedWriter writer = new BufferedWriter(new FileWriter(file));
            gson.toJson(obj, writer);
            writer.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void save(File file, JsonArray obj) {
        try {
            if (!file.exists()) {
                file.getParentFile().mkdirs();
                file.createNewFile();
            }
            Gson gson = new GsonBuilder().setPrettyPrinting().create();

            BufferedWriter writer = new BufferedWriter(new FileWriter(file));
            gson.toJson(obj, writer);
            writer.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static JsonObject readObject(File file) {
        try {
            return readObject(new FileInputStream(file));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            return null;
        }
    }

    public static JsonObject readObject(InputStream input) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8));
        JsonParser parser = new JsonParser();
        return (JsonObject) parser.parse(reader);
    }

    public static JsonArray readArray(File file) {
        try {
            FileInputStream input = new FileInputStream(file);
            BufferedReader reader = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8));
            JsonParser parser = new JsonParser();
            return (JsonArray) parser.parse(reader);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            return null;
        }
    }
}
 
Сверху