Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

This is a continuation of http://www.minecraftforge.net/forum/index.php/topic,27599.0.html. The original issue was loading a texture from an external location. The proposed solution for this was to use reflection to get the default Minecraft texture pack list, and this seemed to work. Until the project was finally built. I believe issue related to reflection an obfuscation, and therefore, the below code will only work in the development environment.

List defaultResourcePacks = ObfuscationReflectionHelper.getPrivateValue(Minecraft.class, Minecraft.getMinecraft(), "defaultResourcePacks");

Yes, I have looked at examples of using ObfuscationReflectionHelper, and I understand that you can also pass in the obfuscated name, which should make it work. However, this seems very hacky, and could be a problem if the obfuscation names changed. The main point of this suggestion is that I found that FMLClientHandler actually has access to the list of resource packs. The below code will always work, since FML isn't obfuscated.

List defaultResourcePacks = ObfuscationReflectionHelper.getPrivateValue(FMLClientHandler.class, FMLClientHandler.instance(), "resourcePackList");

Currently I believe this is the best solution, but seems like a bit of a workaround. If Minecraft Forge is made to give you access to Minecraft code, you shouldn't need to use reflection on it. I propose adding a method into FMLClientHandler that gives you access to the resource pack list, such as getResourcePacks() or addResourcePack(IResourcePack).

Why expose doing something bad/wrong.

Why not just use the standard structure that FML/Minecraft provides. If you want to override/replace resources just stick them in the resource packs folder...

 

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

  • Author

The reason I need this is because I have made a custom 'add-on' system for the mod, which allows for extension blocks to be added to the mod. These add-ons are placed in a custom folder and loaded by the mod, so using the standard resource pack folder is not an option.

  • Author

Also, I have never made contributions to the Minecraft Forge code before, so I would be grateful if you could help with this, diesieben07. Thank you very much.

Whether or not its a good idea is the exact discussion here.

You CAN do it yourself, what you're asking is for Forge to actively encourage others to do it.

Aside from that, actually taking 10 seconds to LOOK at the code surrounding resource packs shows that you can easily add your own without reflection or anything like it.

Protip: Look at what happens when Minecraft refreshes resources.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

  • Author

I have looked at the way Minecraft loads resources, and cannot find a way of adding a default resource pack. However, two things should be noted. One, I do not want to add a custom resource pack in the regular way, it needs to be added the way that Minecraft forge loads mods. This is because I the resource pack should not appear in the selection menu. Second, If you look at the may minecraft refreshes resources, all of the existing resources are cleared. If a resource pack were to be added in any other way, it would likely not work once refrechResources() was called. Therefore, adding the resource to the default resource packs is the only reliable way of making sure the resource will be treated the way it should.

You;re looking at the right method, study it more, you can add resources all you want.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

  • Author

I have studied this method, but do not see how it is possible to add resources. The method collects resource packs from various locations and reloads them. First, it uses resource packs from Minecraft.defaultResourcePacks, which is where I would like mine to be. Then it gets the packs in Minecraft.mcResourcePackRepository.  I have looked, and it doesn't seem that there is a way to add resources to this class. It only returns a copy of it's lists. Even if I could use it, though, I would still get the side effects mentioned above. The pack would appear in the in-game resource pack list.

  • 9 months later...

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.