Jump to content

Recommended Posts

Posted (edited)

Hello!

I am getting error 'java.io.FileNotFoundException: skyblock:rooms/storage.json' even though the specified file is present in my resource directory. 

Below I have provided my code and a screenshot showing that the required file exists.

    public static void getStorage() {
        try(BufferedReader reader = new BufferedReader(new InputStreamReader(Minecraft.getInstance().getResourceManager().getResource(
                new ResourceLocation("skyblock:rooms/storage.json")).getInputStream(), StandardCharsets.UTF_8))) {
            JsonObject json = Skyblock.gson.fromJson(reader, JsonObject.class);
        } catch(Exception ignored) { }
    }

image.png.3ec897a3d8f2b750f0dc72511ab89084.png

Edited by Abdymazhit
Posted

So, "skyblock" would be your mod id right? If you specify the location of the resource like that:

ResourceLocation("skyblock:rooms/storage.json")

the game will default the namespace to "minecraft" and in this case it will search for "minecraft:skyblock:rooms/storage.json" which doesn't exists. When getting the ResourceLocation of your mod assets you have to specify your mod id as the first argument, like that: ResourceLocation(your_mod_id, path), where "path" in your case would be "rooms/storage.json"

Check out the port of the BetterEnd fabric mod (WIP): https://www.curseforge.com/minecraft/mc-mods/betterend-forge-port

Posted
  On 12/30/2020 at 12:40 PM, Beethoven92 said:

So, "skyblock" would be your mod id right? If you specify the location of the resource like that:

ResourceLocation("skyblock:rooms/storage.json")

the game will default the namespace to "minecraft" and in this case it will search for "minecraft:skyblock:rooms/storage.json" which doesn't exists. When getting the ResourceLocation of your mod assets you have to specify your mod id as the first argument, like that: ResourceLocation(your_mod_id, path), where "path" in your case would be "rooms/storage.json"

Expand  

I tried this method as well before posting this thread. But, the error was the same. (java.io.FileNotFoundException: skyblock:rooms/storage.json)

new ResourceLocation("skyblock", "rooms/storage.json")

 

Posted
  On 12/30/2020 at 12:40 PM, Beethoven92 said:

So, "skyblock" would be your mod id right? If you specify the location of the resource like that:

ResourceLocation("skyblock:rooms/storage.json")

the game will default the namespace to "minecraft" and in this case it will search for "minecraft:skyblock:rooms/storage.json" which doesn't exists.

Expand  

I don't think so, ResourceLocation will split the string into two piece, modid and the location. And if the modid does not exist (where there's ':' or not, and if it's empty in front of ':') it will assign minecraft modid to it.

Posted

I'm pretty sure you don't need any Minecraft code to do this.

Are you sure that's /assets/skyblock/rooms/ and not /assets.skyblock.rooms/?

You know the code you're currently using will crash on a server, right?

  • Thanks 1

This is my Forum Signature, I am currently attempting to transform it into a small guide for fixing easier issues using spoiler blocks to keep things tidy.

 

As the most common issue I feel I should put this outside the main bulk:

The only official source for Forge is https://files.minecraftforge.net, and the only site I trust for getting mods is CurseForge.

If you use any site other than these, please take a look at the StopModReposts project and install their browser extension, I would also advise running a virus scan.

 

For players asking for assistance with Forge please expand the spoiler below and read the appropriate section(s) in its/their entirety.

  Reveal hidden contents

 

Posted
  On 12/30/2020 at 10:21 PM, poopoodice said:

I don't think so, ResourceLocation will split the string into two piece, modid and the location. And if the modid does not exist (where there's ':' or not, and if it's empty in front of ':') it will assign minecraft modid to it.

Expand  

You are right, personally i never used the automatic split constructor so i forgot this was a possibility!

Check out the port of the BetterEnd fabric mod (WIP): https://www.curseforge.com/minecraft/mc-mods/betterend-forge-port

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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