Jump to content

Recommended Posts

Posted

I'm trying to add a custom resource which can be changed by resource packs. I am having trouble accessing this resource. How would I go about this? I really have no idea, at the moment, I'm doing this: 

    public static IResource getResource(ResourceLocation location) throws IOException {
        IResourceManager manager = Minecraft.getMinecraft().getResourceManager();
        List<IResource> resources = manager.getAllResources(location);
        return resources.get(resources.size() - 1);
    }

Which, from what I can tell, should maybe work (but it's not), but I feel like there must be a better way to do this...

 

Any help is appreciated...

Developer of Randores (adds 256^3 ores to the game) and Arcane Bags (adds ridiculous storage with ridiculous crafting recipes).

I know Java pretty well... So yeah...

Quote

This is where I'd put an inspirational and/or clever quote, but I can't think of one right now...

This is the output of the totally, 100% working compiler for my programming language, Planet9:

Beginning Compilation...
Failed compilation!
planet9.compiler.error.CompilationException: Compiler not yet implemented
	at planet9.compiler.Compiler.compile(Compiler.java:39)
	at planet9.compiler.app.CompilerApp.main(CompilerApp.java:147)

 

Posted
12 minutes ago, Socratic_Phoenix said:

I'm trying to add a custom resource which can be changed by resource packs. I am having trouble accessing this resource. How would I go about this? I really have no idea, at the moment, I'm doing this: 


    public static IResource getResource(ResourceLocation location) throws IOException {
        IResourceManager manager = Minecraft.getMinecraft().getResourceManager();
        List<IResource> resources = manager.getAllResources(location);
        return resources.get(resources.size() - 1);
    }

Which, from what I can tell, should maybe work (but it's not), but I feel like there must be a better way to do this...

 

Any help is appreciated...

I mean, I'm not the greatest with knowledge since I'm still pretty new to Forge modding,  but I'm pretty sure a resource pack can overwrite a resource by default, so long as it follows the same structure as your resource section is set up.

Posted
1 minute ago, ZombieHDGaming said:

but I'm pretty sure a resource pack can overwrite a resource by default, so long as it follows the same structure as your resource section is set up.

But I tried that and it didn't work...

Developer of Randores (adds 256^3 ores to the game) and Arcane Bags (adds ridiculous storage with ridiculous crafting recipes).

I know Java pretty well... So yeah...

Quote

This is where I'd put an inspirational and/or clever quote, but I can't think of one right now...

This is the output of the totally, 100% working compiler for my programming language, Planet9:

Beginning Compilation...
Failed compilation!
planet9.compiler.error.CompilationException: Compiler not yet implemented
	at planet9.compiler.Compiler.compile(Compiler.java:39)
	at planet9.compiler.app.CompilerApp.main(CompilerApp.java:147)

 

Posted
3 minutes ago, ZombieHDGaming said:

Did you make sure it was under your Mod ID in the resource pack?

Yes, it was formatted exactly the same as my resources in the .jar (assets/id/whatevs), and those resources are still properly accessed...

Developer of Randores (adds 256^3 ores to the game) and Arcane Bags (adds ridiculous storage with ridiculous crafting recipes).

I know Java pretty well... So yeah...

Quote

This is where I'd put an inspirational and/or clever quote, but I can't think of one right now...

This is the output of the totally, 100% working compiler for my programming language, Planet9:

Beginning Compilation...
Failed compilation!
planet9.compiler.error.CompilationException: Compiler not yet implemented
	at planet9.compiler.Compiler.compile(Compiler.java:39)
	at planet9.compiler.app.CompilerApp.main(CompilerApp.java:147)

 

Posted (edited)

Ok, it's a little bit harder than just that.

You need to add your resource Type to Minecraft.

 this.metadataSerializer_.registerMetadataSectionType(new TextureMetadataSectionSerializer(), TextureMetadataSection.class);

thats an example straight from Minecraft.

All this can be found inside the Minecraft class. I will post more as soon as I find a solution as I would also need a function like that.

 

Edit: argh... seems to be the wrong way even though it might work.. have to do a little bit more research on this.

 

Edit 2: 1. I cannot believe how simple it is.
2. You cannot search for a Folder but only for a file.

Edited by JTK222
Posted
58 minutes ago, ZombieHDGaming said:

a resource pack can overwrite a resource by default

 

This is true. Mods' resources can be overwritten by a resource pack.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

Ok so after a bit of reasearch, it seems that  "getAllResources" just returns all version of a resource so, if texture pack 1 has this resource and texture pack 2 you will get booth.

So you will still have to search for single resource files.

Posted
22 hours ago, JTK222 said:

Edit 2: 1. I cannot believe how simple it is.
2. You cannot search for a Folder but only for a file.

What do  you mean by this? All of my ResourceLocations are paths to single files.

 

22 hours ago, JTK222 said:

 

Ok so after a bit of reasearch, it seems that  "getAllResources" just returns all version of a resource so, if texture pack 1 has this resource and texture pack 2 you will get booth.

So you will still have to search for single resource files.

 

I have tried using both getAllResources and getResource, neither of which appear to work. Furthermore, getAllResources does not appear to return all versions of the resources, according to my debugging. I will do additional debugging, but this is still unsolved :( 

Developer of Randores (adds 256^3 ores to the game) and Arcane Bags (adds ridiculous storage with ridiculous crafting recipes).

I know Java pretty well... So yeah...

Quote

This is where I'd put an inspirational and/or clever quote, but I can't think of one right now...

This is the output of the totally, 100% working compiler for my programming language, Planet9:

Beginning Compilation...
Failed compilation!
planet9.compiler.error.CompilationException: Compiler not yet implemented
	at planet9.compiler.Compiler.compile(Compiler.java:39)
	at planet9.compiler.app.CompilerApp.main(CompilerApp.java:147)

 

Posted (edited)
public static IResource getResource(ResourceLocation location) throws IOException {
        IResourceManager manager = Minecraft.getMinecraft().getResourceManager();
        IResource res = manager.getResource(location);
        System.out.println(res.getResourceLocation());
        return res;
}

This code is working perfectly for me.

Using following method to call it:

	try {
            getResource(new ResourceLocation(DRPCoreInfo.MODID, "recipes/test.json"));
        } catch (IOException | URISyntaxException e) {
            e.printStackTrace();
        }

With Following Folder Structure: assets/modid/recipes/test.json

Edited by JTK222
Posted
3 hours ago, JTK222 said:

This code is working perfectly for me.

Yes; your code is indeed correct.

 

The problem was that the program I was using to generate the .zip file (one I wrote myself, actually), was formatting the file in such a way that, although it could be read by the windows zip utility, it couldn't be read by minecraft... 

 

What a convoluted problem... thanks for the help everyone!

Developer of Randores (adds 256^3 ores to the game) and Arcane Bags (adds ridiculous storage with ridiculous crafting recipes).

I know Java pretty well... So yeah...

Quote

This is where I'd put an inspirational and/or clever quote, but I can't think of one right now...

This is the output of the totally, 100% working compiler for my programming language, Planet9:

Beginning Compilation...
Failed compilation!
planet9.compiler.error.CompilationException: Compiler not yet implemented
	at planet9.compiler.Compiler.compile(Compiler.java:39)
	at planet9.compiler.app.CompilerApp.main(CompilerApp.java:147)

 

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.